File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
import " @/styles/globals.css" ;
3
- import { getCollection } from ' astro:content' ;
3
+ import { getEntryBySlug } from ' astro:content' ;
4
4
import { CONFIG } from " @/config" ;
5
5
6
6
export type Props = {
@@ -16,16 +16,16 @@ const {
16
16
pageType = " website" ,
17
17
} = Astro .props ;
18
18
19
- const posts = await getCollection (' blog' );
19
+ const getTitle = async (slug ) => {
20
+ if (Astro .props .title ) return Astro .props .title ;
20
21
21
- const getTitle = (slug ) => {
22
- const post = posts .find ((p ) => p .slug === slug );
23
- return post ?.data .title || null ; // Return null if not found
22
+ if (! slug ) return CONFIG .meta .title ; // Fallback if no slug is provided
23
+
24
+ const post = await getEntryBySlug (' blog' , slug );
25
+ return post ?.data .title || CONFIG .meta .title ;
24
26
};
25
27
26
- const title = [getTitle (Astro .params .slug ), Astro .props .title , CONFIG .meta .title ]
27
- .filter (Boolean )
28
- .join (" | " );
28
+ const title = await getTitle (Astro .params ?.slug );
29
29
30
30
const resolvedImage = image ?.src
31
31
? {
You can’t perform that action at this time.
0 commit comments