File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import { distanceToNow, formatDate } from '@/lib/date-formatting'
2929import { MDXElements } from '@/lib/mdx-elements'
3030import { getAllPostsIds , getPostData } from '@/lib/posts'
3131import { i18nConfig } from '@/config/i18n.mjs'
32+ import { loadCatalog } from '../../i18n'
3233
3334export default function Post ( { source, frontmatter, postId, translation } ) {
3435 const date = new Date ( frontmatter . date )
@@ -123,7 +124,7 @@ export async function getStaticPaths() {
123124 }
124125}
125126
126- export async function getStaticProps ( { params } ) {
127+ export async function getStaticProps ( { params, locale } ) {
127128 const postData = getPostData ( params . id )
128129 const filePath = path . join ( process . cwd ( ) , 'src/posts' , postData . file )
129130 const source = fs . readFileSync ( filePath , 'utf8' )
@@ -136,11 +137,14 @@ export async function getStaticProps({ params }) {
136137 } ,
137138 } )
138139
140+ const translation = await loadCatalog ( locale ?? 'en' )
141+
139142 return {
140143 props : {
141144 source : mdxSource ,
142145 frontmatter : data ,
143146 postId : params . id ,
147+ translation,
144148 } ,
145149 }
146150}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { Link } from '@/components/mdx'
2020import { distanceToNow , formatDate } from '@/lib/date-formatting'
2121import { getSortedPostsMetadata } from '@/lib/posts'
2222import { generateRssFeed } from '@/lib/rss-feed'
23+ import { loadCatalog } from '../../i18n'
2324
2425const SinglePost = ( { page } ) => {
2526 const date = new Date ( page . date )
@@ -109,12 +110,14 @@ export default function Blog({ allPostsData }) {
109110 )
110111}
111112
112- export async function getStaticProps ( { params , locale = 'en' } ) {
113+ export async function getStaticProps ( { locale = 'en' } ) {
113114 const allPostsData = getSortedPostsMetadata ( )
114115 generateRssFeed ( allPostsData )
116+ const translation = await loadCatalog ( locale )
115117 return {
116118 props : {
117119 allPostsData,
120+ translation,
118121 } ,
119122 }
120123}
You can’t perform that action at this time.
0 commit comments