Skip to content

Commit 2a43a47

Browse files
improvements to docs open graph (#50)
1 parent a7add72 commit 2a43a47

File tree

1 file changed

+69
-12
lines changed

1 file changed

+69
-12
lines changed

docs/.vitepress/config.mts

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ const analyticsHeaders: HeadConfig[] =
1515
]
1616
: [];
1717

18+
const siteTitle = "OutboxKit";
19+
const siteDescription = "Toolkit to implement the transactional outbox pattern";
20+
1821
// https://vitepress.dev/reference/site-config
1922
export default defineConfig({
20-
title: "OutboxKit",
21-
description: "Toolkit to implement the transactional outbox pattern",
23+
title: siteTitle,
24+
description: siteDescription,
2225
head: [
2326
...analyticsHeaders,
2427
[
@@ -50,10 +53,16 @@ export default defineConfig({
5053
],
5154
["link", { rel: "manifest", manifest: "/manifest.json" }],
5255
["meta", { property: "og:image", content: "/banner.webp" }],
53-
["meta", { property: "og:image:alt", content: "OutboxKit - Toolkit to implement the transactional outbox pattern" }],
56+
[
57+
"meta",
58+
{
59+
property: "og:image:alt",
60+
content:
61+
"OutboxKit - Toolkit to implement the transactional outbox pattern",
62+
},
63+
],
5464
["meta", { property: "og:image:width", content: "1920" }],
55-
["meta", { property: "og:image:height", content: "1080" }],
56-
["meta", { property: "og:description", content: "Toolkit to implement the transactional outbox pattern" }],
65+
["meta", { property: "og:image:height", content: "1080" }]
5766
],
5867
themeConfig: {
5968
// https://vitepress.dev/reference/default-theme-config
@@ -69,7 +78,10 @@ export default defineConfig({
6978
items: [
7079
{ text: "Quickstart", link: "/intro/quickstart" },
7180
{ text: "What is OutboxKit?", link: "/intro/what-is-outboxkit" },
72-
{ text: "Transactional outbox pattern", link: "/intro/transactional-outbox-pattern" },
81+
{
82+
text: "Transactional outbox pattern",
83+
link: "/intro/transactional-outbox-pattern",
84+
},
7385
{ text: "Concepts", link: "/intro/concepts" },
7486
],
7587
},
@@ -79,7 +91,10 @@ export default defineConfig({
7991
items: [
8092
{ text: "Core overview", link: "/core/overview" },
8193
{ text: "Producing messages", link: "/core/producing-messages" },
82-
{ text: "Polling trigger optimization", link: "/core/polling-trigger-optimization" },
94+
{
95+
text: "Polling trigger optimization",
96+
link: "/core/polling-trigger-optimization",
97+
},
8398
],
8499
},
85100
{
@@ -94,7 +109,10 @@ export default defineConfig({
94109
text: "PostgreSQL",
95110
collapsed: true,
96111
items: [
97-
{ text: "PostgreSQL provider overview", link: "/postgresql/overview" },
112+
{
113+
text: "PostgreSQL provider overview",
114+
link: "/postgresql/overview",
115+
},
98116
{ text: "Polling", link: "/postgresql/polling" },
99117
],
100118
},
@@ -111,17 +129,23 @@ export default defineConfig({
111129
collapsed: true,
112130
items: [
113131
{ text: "Observability overview", link: "/observability/overview" },
114-
{ text: "Built-in instrumentation", link: "/observability/built-in-instrumentation" },
115-
{ text: "Helpers", link: "/observability/helpers" }
132+
{
133+
text: "Built-in instrumentation",
134+
link: "/observability/built-in-instrumentation",
135+
},
136+
{ text: "Helpers", link: "/observability/helpers" },
116137
],
117138
},
118139
{
119140
text: "Building a provider",
120141
collapsed: true,
121142
items: [
122-
{ text: "Building a provider overview", link: "/building-a-provider/overview" },
143+
{
144+
text: "Building a provider overview",
145+
link: "/building-a-provider/overview",
146+
},
123147
{ text: "Polling", link: "/building-a-provider/polling" },
124-
{ text: "Push", link: "/building-a-provider/push" }
148+
{ text: "Push", link: "/building-a-provider/push" },
125149
],
126150
},
127151
],
@@ -148,4 +172,37 @@ export default defineConfig({
148172
hostname: "https://outboxkit.yakshavefx.dev",
149173
lastmodDateOnly: false,
150174
},
175+
transformPageData(pageData) {
176+
pageData.frontmatter.head ??= [];
177+
pageData.frontmatter.head.push([
178+
"meta",
179+
{
180+
name: "og:title",
181+
content:
182+
pageData.frontmatter.layout === "home"
183+
? siteTitle
184+
: `${pageData.title} | ${siteTitle}`,
185+
},
186+
]);
187+
188+
const pageDescription =
189+
pageData.frontmatter.layout === "home"
190+
? siteDescription
191+
: pageData.frontmatter.description || pageData.description;
192+
193+
if (!!pageDescription) {
194+
pageData.frontmatter.head.push([
195+
"meta",
196+
{
197+
name: "og:description",
198+
content:
199+
pageData.frontmatter.layout === "home"
200+
? siteDescription
201+
: pageData.frontmatter.description || pageData.description,
202+
},
203+
]);
204+
}
205+
206+
return pageData;
207+
},
151208
});

0 commit comments

Comments
 (0)