Skip to content

Commit 4ab5dec

Browse files
committed
fix(website): have the actual page title on open graph and twitter tags
1 parent af31122 commit 4ab5dec

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

website/.vitepress/config.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,10 @@ export default defineConfig({
6060
// Open Graph
6161
['meta', { property: 'og:type', content: 'website' }],
6262
['meta', { property: 'og:site_name', content: taskName }],
63-
['meta', { property: 'og:title', content: taskName }],
64-
['meta', { property: 'og:description', content: taskDescription }],
6563
['meta', { property: 'og:image', content: ogImage }],
66-
['meta', { property: 'og:url', content: ogUrl }],
6764
// Twitter Card
6865
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
6966
['meta', { name: 'twitter:site', content: '@taskfiledev' }],
70-
['meta', { name: 'twitter:title', content: taskName }],
71-
['meta', { name: 'twitter:description', content: taskDescription }],
7267
['meta', { name: 'twitter:image', content: ogImage }],
7368
[
7469
'meta',
@@ -96,6 +91,15 @@ export default defineConfig({
9691
.replace(/index$/, '')}`
9792
head.push(['link', { rel: 'canonical', href: canonicalUrl }])
9893

94+
// Dynamic Open Graph and Twitter meta tags
95+
const pageTitle = pageData.frontmatter.title || pageData.title || taskName
96+
const pageDescription = pageData.frontmatter.description || pageData.description || taskDescription
97+
head.push(['meta', { property: 'og:title', content: `${pageTitle} | Task` }])
98+
head.push(['meta', { property: 'og:description', content: pageDescription }])
99+
head.push(['meta', { property: 'og:url', content: canonicalUrl }])
100+
head.push(['meta', { name: 'twitter:title', content: `${pageTitle} | Task` }])
101+
head.push(['meta', { name: 'twitter:description', content: pageDescription }])
102+
99103
// Noindex pour 404
100104
if (pageData.relativePath === '404.md') {
101105
head.push(['meta', { name: 'robots', content: 'noindex, nofollow' }])

0 commit comments

Comments
 (0)