File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 11---
22import " @/styles/globals.css" ;
3+ import { getCollection } from ' astro:content' ;
34import { CONFIG } from " @/config" ;
45
56export type Props = {
@@ -14,9 +15,18 @@ const {
1415 image = CONFIG .meta .image ,
1516 pageType = " website" ,
1617} = Astro .props ;
17- const title = [Astro .props .title , CONFIG .meta .title ]
18- .filter (Boolean )
19- .join (" | " );
18+
19+ const posts = await getCollection (' blog' );
20+
21+ const getTitle = (slug ) => {
22+ const post = posts .find ((p ) => p .slug === slug );
23+ return post ?.data .title || null ; // Return null if not found
24+ };
25+
26+ const title = [getTitle (Astro .params .slug ), Astro .props .title , CONFIG .meta .title ]
27+ .filter (Boolean )
28+ .join (" | " );
29+
2030const resolvedImage = image ?.src
2131 ? {
2232 src: new URL (image .src , Astro .site ).toString (),
You can’t perform that action at this time.
0 commit comments