Skip to content

Commit 5d01b04

Browse files
Merge branch 'dev'
2 parents 13380db + fcaa4c2 commit 5d01b04

File tree

16 files changed

+245
-81
lines changed

16 files changed

+245
-81
lines changed

next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
44
reactStrictMode: true,
5-
output: "export",
5+
// output: "export",
66
images: { unoptimized: true },
77
trailingSlash: true,
88
};

package-lock.json

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"gray-matter": "^4.0.3",
1313
"highlight.js": "^11.11.1",
1414
"i18next": "^25.0.1",
15+
"i18next-browser-languagedetector": "^8.1.0",
16+
"i18next-http-backend": "^3.0.2",
1517
"install": "^0.13.0",
1618
"negotiator": "^1.0.0",
1719
"next": "15.3.1",

public/article-2025/04/grok3/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Researching about Grok AI
33
date: "2025-04-30"
4-
descrption: "Grokに自分自身について説明してもらった"
4+
description: "Grokに自分自身について説明してもらった"
55
---
66

77
# Grok3 についての詳細な記事
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: May Introduction
3+
date: "2025-04-30"
4+
description: ""
5+
---

src/app/article/article.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,18 @@ export function getArticleIndexes() {
5959
const fileContents = fs.readFileSync(articlePath, "utf-8");
6060
const { data } = matter(fileContents);
6161

62+
// 言語を判定 (デフォルトは "ja")
63+
const langMatch = articlePath.match(/article(?:-(\w+))?\.md$/);
64+
const lang = langMatch && langMatch[1] ? langMatch[1] : "ja";
65+
6266
return {
6367
slug: `${year}/${month}/${articleId}`,
6468
title: data.title || "Untitled", // タイトルがない場合のデフォルト値
6569
date: data.date || "Unknown date", // 日付がない場合のデフォルト値
6670
thumbnail: thumbnailPath,
6771
articlePath,
72+
description: data.description || "No description available", // description を追加
73+
lang, // 言語を追加
6874
};
6975
})
7076
.filter(
@@ -89,6 +95,8 @@ export type Article = {
8995
date: string;
9096
thumbnail: string | null;
9197
articlePath: string;
98+
description: string; // description を追加
99+
lang: string; // lang を追加
92100
};
93101

94102
// 該当箇所の置き換え
@@ -137,14 +145,14 @@ export function generateArticleButton(article: Article): ReactNode {
137145
alt={article.title}
138146
width={300}
139147
height={200}
140-
objectFit="cover"
141148
placeholder={LoadingImage as PlaceholderValue}
142149
className="article-thumbnail"
143150
/>
144151
)}
145152
<div className="article-content">
146153
<h2>{article.title}</h2>
147154
<p>{article.date}</p>
155+
<p>{article.description}</p>
148156
</div>
149157
</article>
150158
</Link>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { ReactNode } from "react";
2+
import { generateArticleButton, Article } from "../article";
3+
import useTranslation from "@/i18n/i18n";
4+
5+
interface ArticleListProps {
6+
articles: Article[];
7+
}
8+
9+
export default function ArticleList({ articles }: ArticleListProps) {
10+
const { t } = useTranslation;
11+
const language = t("info.lang");
12+
13+
// 言語で記事をフィルタリング
14+
const filteredArticles = articles.filter((article) => article.lang === language);
15+
16+
return (
17+
<>
18+
<section>
19+
<p>{language}</p>
20+
</section>
21+
<section className="articles">
22+
{filteredArticles.map(
23+
(article: Article): ReactNode => generateArticleButton(article)
24+
)}
25+
</section>
26+
</>
27+
);
28+
}

src/app/article/page.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
import "@/app/i18n/configs";
2-
import useTranslation from "i18next";
3-
import { generateArticleButton, getArticleIndexes, Article } from "./article";
1+
import useTranslation from "@/i18n/i18n";
2+
import { getArticleIndexes, Article } from "./article";
43
import "./article.css"; // CSSファイルをインポート
5-
import { ReactNode } from "react";
4+
import ArticleList from "./components/list";
65

76
export default async function Home() {
87
const { t } = useTranslation;
98
const articles: Article[] = getArticleIndexes();
109
return (
1110
<>
1211
<section className="title">
13-
<h1>{t("article.title")}</h1>
12+
<h1>{t("pages.article.title")}</h1>
1413
</section>
1514
<section className="description">
16-
<p>{t("article.description.msg1")}</p>
17-
<p>{t("article.description.msg2")}</p>
18-
</section>
19-
<section className="articles">
20-
{articles.map(
21-
(article: Article): ReactNode => generateArticleButton(article)
22-
)}
15+
<p>{t("pages.article.description.msg1")}</p>
16+
<p>{t("pages.article.description.msg2")}</p>
2317
</section>
18+
<ArticleList articles={articles} />
2419
</>
2520
);
2621
}

src/app/globals.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ footer {
153153
width: 100%;
154154
background-color: color-mix(in srgb, var(--primary), transparent 50%);
155155
backdrop-filter: blur(4px);
156+
padding-bottom: 4em;
156157
}
157158

158159
a {
@@ -200,4 +201,24 @@ a {
200201

201202
.back-to-top svg {
202203
fill: var(--foreground);
204+
}
205+
206+
.language-button {
207+
padding: 0.5rem 1rem;
208+
margin-right: 0.5rem;
209+
background-color: var(--gray-200);
210+
color: var(--foreground);
211+
border: none;
212+
border-radius: 4px;
213+
cursor: pointer;
214+
transition: background-color 0.3s ease, color 0.3s ease;
215+
}
216+
217+
.language-button.active {
218+
background-color: var(--link-color);
219+
color: var(--background);
220+
}
221+
222+
.language-button:last-child {
223+
margin-right: 0;
203224
}

src/app/i18n/en.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)