Skip to content

Commit 33cb833

Browse files
committed
full changed with Roughfts
1 parent 5d01b04 commit 33cb833

File tree

19 files changed

+211
-266
lines changed

19 files changed

+211
-266
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: 0 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
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",
1715
"install": "^0.13.0",
1816
"negotiator": "^1.0.0",
1917
"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-
description: "Grokに自分自身について説明してもらった"
4+
descrption: "Grokに自分自身について説明してもらった"
55
---
66

77
# Grok3 についての詳細な記事

public/article-2025/05/may-introduction/article-en.md

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

src/app/article/article.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,12 @@ 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-
6662
return {
6763
slug: `${year}/${month}/${articleId}`,
6864
title: data.title || "Untitled", // タイトルがない場合のデフォルト値
6965
date: data.date || "Unknown date", // 日付がない場合のデフォルト値
7066
thumbnail: thumbnailPath,
7167
articlePath,
72-
description: data.description || "No description available", // description を追加
73-
lang, // 言語を追加
7468
};
7569
})
7670
.filter(
@@ -95,8 +89,6 @@ export type Article = {
9589
date: string;
9690
thumbnail: string | null;
9791
articlePath: string;
98-
description: string; // description を追加
99-
lang: string; // lang を追加
10092
};
10193

10294
// 該当箇所の置き換え
@@ -145,14 +137,14 @@ export function generateArticleButton(article: Article): ReactNode {
145137
alt={article.title}
146138
width={300}
147139
height={200}
140+
objectFit="cover"
148141
placeholder={LoadingImage as PlaceholderValue}
149142
className="article-thumbnail"
150143
/>
151144
)}
152145
<div className="article-content">
153146
<h2>{article.title}</h2>
154147
<p>{article.date}</p>
155-
<p>{article.description}</p>
156148
</div>
157149
</article>
158150
</Link>

src/app/article/components/list.tsx

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

src/app/article/page.tsx

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

67
export default async function Home() {
78
const { t } = useTranslation;
89
const articles: Article[] = getArticleIndexes();
910
return (
1011
<>
1112
<section className="title">
12-
<h1>{t("pages.article.title")}</h1>
13+
<h1>{t("article.title")}</h1>
1314
</section>
1415
<section className="description">
15-
<p>{t("pages.article.description.msg1")}</p>
16-
<p>{t("pages.article.description.msg2")}</p>
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+
)}
1723
</section>
18-
<ArticleList articles={articles} />
1924
</>
2025
);
2126
}

src/app/globals.css

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

159158
a {
@@ -201,24 +200,4 @@ a {
201200

202201
.back-to-top svg {
203202
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;
224203
}

src/app/i18n/configs.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use client';
2+
3+
import i18n from "i18next";
4+
import { initReactI18next } from "react-i18next";
5+
6+
// 言語jsonファイルのimport
7+
import translation_en from "./en.json";
8+
import translation_ja from "./ja.json";
9+
10+
// リソースの定義
11+
const resources = {
12+
ja: {
13+
translation: translation_ja,
14+
},
15+
en: {
16+
translation: translation_en,
17+
},
18+
};
19+
20+
// クライアントサイドでのローカルストレージチェック
21+
const getInitialLanguage = () => {
22+
try {
23+
if (typeof window !== 'undefined' && window.localStorage) {
24+
const savedLang = localStorage.getItem("language");
25+
return savedLang || "ja";
26+
}
27+
} catch (error) {
28+
console.error("Error accessing localStorage:", error);
29+
}
30+
return "ja";
31+
};
32+
33+
// i18nextの初期化(ブラウザ環境でのみ実行)
34+
if (!i18n.isInitialized) {
35+
i18n
36+
.use(initReactI18next)
37+
.init({
38+
resources,
39+
lng: typeof window !== 'undefined' ? getInitialLanguage() : "ja",
40+
fallbackLng: "en",
41+
interpolation: {
42+
escapeValue: false,
43+
},
44+
react: {
45+
useSuspense: false,
46+
},
47+
})
48+
.catch(error => {
49+
console.error("Error initializing i18n:", error);
50+
});
51+
}
52+
53+
export default i18n;

0 commit comments

Comments
 (0)