We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f05fa89 commit a153eebCopy full SHA for a153eeb
1 file changed
src/components/BaseHead.astro
@@ -1,5 +1,6 @@
1
---
2
import "@/styles/globals.css";
3
+import { getCollection } from 'astro:content';
4
import { CONFIG } from "@/config";
5
6
export type Props = {
@@ -14,9 +15,18 @@ const {
14
15
image = CONFIG.meta.image,
16
pageType = "website",
17
} = Astro.props;
-const title = [Astro.props.title, CONFIG.meta.title]
18
- .filter(Boolean)
19
- .join(" | ");
+
+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
30
const resolvedImage = image?.src
31
? {
32
src: new URL(image.src, Astro.site).toString(),
0 commit comments