11---
2- import PostContent from ' @apps/posts/PostContent' ;
3- import { getTranslations } from ' @backend/i18n' ;
4- import { fetchPost , fetchPosts } from ' @backend/tina' ;
5- import Container from ' @components/Container.astro' ;
6- import config from ' @config' ;
7- import Layout from ' @layouts/Layout.astro' ;
8- import { hasPostsContent } from ' @utils/config' ;
9- import _ from ' underscore' ;
2+ import PostContent from " @apps/posts/PostContent" ;
3+ import { getTranslations } from " @backend/i18n" ;
4+ import { fetchPost , fetchPosts } from " @backend/tina" ;
5+ import Container from " @components/Container.astro" ;
6+ import config from " @config" ;
7+ import { getLocalizedContent } from " @i18n/utils" ;
8+ import Layout from " @layouts/Layout.astro" ;
9+ import { hasPostsContent } from " @utils/config" ;
10+ import _ from " underscore" ;
1011
1112const { slug } = Astro .params ;
1213const post = await fetchPost (slug );
1314
14- const { t } = await getTranslations (Astro .currentLocale );
15+ const locale = Astro .currentLocale ;
16+
17+ const localePost = getLocalizedContent (post , locale .replaceAll (" -" , " _" )); // this is to deal with Tina's field naming restrictions
18+
19+ const { t } = await getTranslations (locale );
1520
1621export const getStaticPaths = async () => {
1722 if (! hasPostsContent (config )) {
@@ -25,32 +30,27 @@ export const getStaticPaths = async () => {
2530
2631 _ .each (locales , (lang ) => {
2732 _ .each (posts , (post ) => {
28- staticPaths .push ({ params: {
29- lang ,
30- slug: post ?._sys .filename
31- }});
33+ staticPaths .push ({
34+ params: {
35+ lang ,
36+ slug: post ?._sys .filename ,
37+ },
38+ });
3239 });
3340 });
3441
3542 return staticPaths ;
3643};
3744---
3845
39- <Layout
40- footer
41- t ={ t }
42- tab =' posts'
43- title ={ slug }
44- >
45- <Container
46- className =' pb-16 w-full'
47- >
46+ <Layout footer t ={ t } tab =" posts" title ={ localePost ?.title } >
47+ <Container className =" pb-16 w-full" >
4848 <PostContent
4949 content ={ post ?.body }
5050 title ={ post ?.title }
5151 author ={ post ?.author }
5252 date ={ post ?.date }
53- client:only =' react'
53+ client:only =" react"
5454 />
5555 </Container >
5656</Layout >
0 commit comments