Skip to content

Commit 6823d79

Browse files
committed
Add social network previews
1 parent 7949215 commit 6823d79

4 files changed

Lines changed: 25 additions & 11 deletions

File tree

.vitepress/config.mts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,31 @@ gtag('config', 'G-VYGDN3X0PR');`],
166166
}
167167
},
168168

169-
transformHead({ pageData }) {
169+
transformHead({ pageData, siteData }) {
170170
const head: HeadConfig[] = []
171171

172-
if (pageData.frontmatter.image) {
173-
head.push(['meta', { property: 'og:image', content: baseUrl + pageData.frontmatter.image }])
174-
head.push(['meta', { name: 'twitter:image', content: baseUrl + pageData.frontmatter.image }])
175-
head.push(['meta', { name: 'twitter:card', content: 'summary_large_image' }])
172+
const title = pageData.frontmatter.title || siteData.title
173+
const description = pageData.frontmatter.description || siteData.description
174+
const image = pageData.frontmatter.image
175+
const pageUrl = baseUrl + '/' + pageData.relativePath.replace(/index\.md$/, '').replace(/\.md$/, '')
176+
177+
head.push(['meta', { property: 'og:type', content: 'website' }])
178+
head.push(['meta', { property: 'og:url', content: pageUrl }])
179+
180+
if (title) {
181+
head.push(['meta', { property: 'og:title', content: title }])
182+
head.push(['meta', { name: 'twitter:title', content: title }])
176183
}
177184

178-
if (pageData.frontmatter.description) {
179-
head.push(['meta', { property: 'og:description', content: pageData.frontmatter.description }])
180-
head.push(['meta', { name: 'twitter:description', content: pageData.frontmatter.description }])
185+
if (description) {
186+
head.push(['meta', { property: 'og:description', content: description }])
187+
head.push(['meta', { name: 'twitter:description', content: description }])
181188
}
182189

183-
if (pageData.frontmatter.title) {
184-
head.push(['meta', { property: 'og:title', content: pageData.frontmatter.title }])
185-
head.push(['meta', { name: 'twitter:title', content: pageData.frontmatter.title }])
190+
if (image) {
191+
head.push(['meta', { property: 'og:image', content: baseUrl + image }])
192+
head.push(['meta', { name: 'twitter:image', content: baseUrl + image }])
193+
head.push(['meta', { name: 'twitter:card', content: 'summary_large_image' }])
186194
}
187195

188196
return head

index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
layout: home
3+
title: Testo — Modern PHP Testing Framework
4+
description: PHP testing framework without TestCase inheritance. Clean OOP, middleware architecture, PSR-14 events, Assert/Expect facades.
5+
image: /images/og-image.jpg
36

47
hero:
58
name:

public/images/og-image.jpg

406 KB
Loading

ru/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
layout: home
3+
title: Testo — PHP-фреймворк для тестирования
4+
description: PHP-фреймворк для тестирования без наследования от TestCase. Чистый ООП, middleware-архитектура, PSR-14 события, фасады Assert/Expect.
5+
image: /images/og-image.jpg
36

47
hero:
58
name:

0 commit comments

Comments
 (0)