File tree Expand file tree Collapse file tree 6 files changed +79
-9
lines changed
Expand file tree Collapse file tree 6 files changed +79
-9
lines changed Original file line number Diff line number Diff line change 1+ import { getArticleIndexes , Article } from "../../../article/article" ;
2+ import ArticleList from "../../../article/components/list" ;
3+
4+ export default function ArticlePage ( { year, month } : { year : string ; month : string } ) {
5+ const articles : Article [ ] = getArticleIndexes ( ) . filter ( article => article . date . trim ( ) . startsWith ( `${ year } -${ month } -` ) ) ;
6+ return < ArticleList articles = { articles } /> ;
7+ }
Original file line number Diff line number Diff line change 1+ "use client" ;
2+ import { useTranslations } from "next-intl" ;
3+
4+ export default function Explains ( { year, month } : { year : string ; month : string } ) {
5+ const t = useTranslations ( ) ;
6+ return (
7+ < >
8+ < section className = "title" >
9+ < h1 > { t ( "pages.article.title" ) + " of " + year + "-" + month } </ h1 >
10+ </ section >
11+ < section className = "description" >
12+ < p > { t ( "pages.article.description.msg1" ) } </ p >
13+ < p > { t ( "pages.article.description.msg2" ) } </ p >
14+ </ section > </ > )
15+ }
Original file line number Diff line number Diff line change 1+ import "../../article/article.css" ; // CSSファイルをインポート
2+ import "../../article/page.css" ;
3+ import Explains from "./components/explains" ;
4+ import ArticlePage from "./components/articlepage" ; // クライアントコンポーネントをインポート
5+ import { getArticleIndexes } from "@/app/article/article" ;
6+
7+ export async function generateStaticParams ( ) {
8+ const indexes = getArticleIndexes ( ) ;
9+ // 静的に生成するパスを返す
10+ return indexes . map ( ( article ) => {
11+ const [ article_year , month ] = article . slug . split ( "/" ) ;
12+ return { article_year, month } ;
13+ } ) ;
14+ }
15+
16+
17+ export default async function Home ( {
18+ params,
19+ } : {
20+ params : Promise < { article_year : string ; month : string ; } > ;
21+ } ) {
22+ const resolvedParams = await params ;
23+ const article_year = parseInt ( resolvedParams . article_year . replace ( "article-" , "" ) ) . toString ( ) ;
24+ const month = resolvedParams . month ;
25+ return (
26+ < >
27+ < Explains year = { article_year } month = { month } />
28+ < ArticlePage year = { article_year } month = { month } />
29+ </ >
30+ ) ;
31+ }
Original file line number Diff line number Diff line change 11import { getArticleIndexes , Article } from "../../article/article" ;
22import ArticleList from "../../article/components/list" ;
33
4- export default function ArticlePage ( ) {
5- const articles : Article [ ] = getArticleIndexes ( ) ;
4+ export default function ArticlePage ( { year } : { year : string } ) {
5+ const articles : Article [ ] = getArticleIndexes ( ) . filter ( article => article . date . trim ( ) . startsWith ( year ) ) ;
66 return < ArticleList articles = { articles } /> ;
77}
Original file line number Diff line number Diff line change 11"use client" ;
22import { useTranslations } from "next-intl" ;
33
4- export default function Explains ( ) {
4+ export default function Explains ( { year } : { year : string } ) {
55 const t = useTranslations ( ) ;
66 return (
77 < >
88 < section className = "title" >
9- < h1 > { t ( "pages.article.title" ) } </ h1 >
9+ < h1 > { t ( "pages.article.title" ) + " of " + year } </ h1 >
1010 </ section >
1111 < section className = "description" >
1212 < p > { t ( "pages.article.description.msg1" ) } </ p >
Original file line number Diff line number Diff line change 1- import "./article.css" ; // CSSファイルをインポート
2- import "./page.css" ;
1+ import "../article /article.css" ; // CSSファイルをインポート
2+ import "../article /page.css" ;
33import Explains from "./components/explains" ;
44import ArticlePage from "./components/articlepage" ; // クライアントコンポーネントをインポート
5+ import { getArticleIndexes } from "@/app/article/article" ;
56
6- export default function Home ( ) {
7+ export async function generateStaticParams ( ) {
8+ const indexes = getArticleIndexes ( ) ;
9+ // 静的に生成するパスを返す
10+ return indexes . map ( ( article ) => {
11+ const [ article_year ] = article . slug . split ( "/" ) ;
12+ return { article_year } ;
13+ } ) ;
14+ }
15+
16+
17+ export default async function Home ( {
18+ params,
19+ } : {
20+ params : Promise < { article_year : string } > ;
21+ } ) {
22+ const resolvedParams = await params ;
23+ const article_year = parseInt ( resolvedParams . article_year . replace ( "article-" , "" ) ) . toString ( ) ;
724 return (
825 < >
9- < Explains />
10- < ArticlePage />
26+ < Explains year = { article_year } />
27+ < ArticlePage year = { article_year } />
1128 </ >
1229 ) ;
1330}
You can’t perform that action at this time.
0 commit comments