@@ -12,8 +12,15 @@ import rehypeStringify from "rehype-stringify";
1212import { unified } from "unified" ;
1313import "highlight.js/styles/gradient-dark.css" ;
1414import { ReactNode } from "react" ;
15+ import { PlaceholderValue } from "next/dist/shared/lib/get-img-props" ;
16+
1517const 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+
1724export 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