Skip to content

Commit f1b5e3b

Browse files
save
1 parent 18cee44 commit f1b5e3b

File tree

2 files changed

+166
-1
lines changed

2 files changed

+166
-1
lines changed

public/next-loading.svg

Lines changed: 157 additions & 0 deletions
Loading

src/app/article/article.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ import rehypeStringify from "rehype-stringify";
1212
import { unified } from "unified";
1313
import "highlight.js/styles/gradient-dark.css";
1414
import { ReactNode } from "react";
15+
import { PlaceholderValue } from "next/dist/shared/lib/get-img-props";
16+
1517
const postsDirectory = path.join(process.cwd(), "public");
1618

19+
// SVGファイルをBase64に変換してLoadingImageに代入
20+
const svgFilePath = path.join(process.cwd(), "public", "next-loading.svg");
21+
const LoadingImage =
22+
"data:image/svg+xml," + fs.readFileSync(svgFilePath, "utf-8").toString();
23+
1724
export function getArticleIndexes() {
1825
const years = fs.readdirSync(postsDirectory).filter((year) => {
1926
const yearPath = path.join(postsDirectory, year);
@@ -96,7 +103,7 @@ export async function toHTML(articles: Article[]) {
96103
.use(remarkGfm)
97104
.use(remarkRehype)
98105
.use(rehypePrettyCode, {
99-
defaultLang:"plaintext",
106+
defaultLang: "plaintext",
100107
theme: "github-dark-high-contrast",
101108
keepBackground: true,
102109
})
@@ -131,6 +138,7 @@ export function generateArticleButton(article: Article): ReactNode {
131138
width={300}
132139
height={200}
133140
objectFit="cover"
141+
placeholder={LoadingImage as PlaceholderValue}
134142
className="article-thumbnail"
135143
/>
136144
)}

0 commit comments

Comments
 (0)