Skip to content

Commit 5982b57

Browse files
authored
feat: Update OG title and description from pagedata (#27)
* feat: update og from pagedata * fix: give default value to title and description
1 parent 1c40325 commit 5982b57

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

.vitepress/shared.mts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from "vitepress";
1+
import { defineConfig, HeadConfig } from "vitepress";
22
import { search as koSearch } from "./ko.mts";
33

44
export const shared = defineConfig({
@@ -28,6 +28,17 @@ export const shared = defineConfig({
2828
]
2929
],
3030

31+
transformHead: ({ pageData }) => {
32+
const head: HeadConfig[] = [];
33+
const title = pageData.frontmatter.title || 'Frontend Fundamentals';
34+
const description = pageData.frontmatter.description || 'Guidelines for easily modifiable frontend code';
35+
36+
head.push(['meta', { property: 'og:title', content: title }]);
37+
head.push(['meta', { property: 'og:description', content: description }]);
38+
39+
return head;
40+
},
41+
3142
themeConfig: {
3243
logo: "/images/ff-symbol.svg",
3344

0 commit comments

Comments
 (0)