Skip to content

Commit 199a47f

Browse files
mlenkeitospo-renovate[bot]
andcommitted
Release 2.0.17
Co-authored-by: Maximilian Lenkeit <[email protected]> Co-authored-by: ospo-renovate[bot] <40221+ospo-renovate[bot]@users.noreply.github.tools.sap>
1 parent 0832d8c commit 199a47f

File tree

6 files changed

+328
-14
lines changed

6 files changed

+328
-14
lines changed

.github/workflows/gh-pages.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
name: Build VitePress site
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v5
1616
with:
1717
fetch-depth: 0
1818
- uses: actions/setup-node@v4
@@ -24,6 +24,8 @@ jobs:
2424
run: npm install
2525
- name: Build website
2626
run: npm run docs:build
27+
env:
28+
VP_DOMAIN: https://documentation.apeirora.eu/
2729

2830
- name: Upload Build Artifact
2931
uses: actions/upload-pages-artifact@v3

.vitepress/config.mts

Lines changed: 34 additions & 3 deletions
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 markdownItFootnote from 'markdown-it-footnote'
33
import { withMermaid } from "vitepress-plugin-mermaid";
44
import blogSidebar from './theme/blog-sidebar';
@@ -12,6 +12,14 @@ const BASE = process.env.VP_BASE || '/'
1212
if (!path.posix.isAbsolute(BASE)) {
1313
throw new Error(`Base path '${BASE}' must be absolute, check environment variable VP_BASE`);
1414
}
15+
const resolveAbsoluteUrl = (relativeUrl: string) => {
16+
const domain = process.env.VP_DOMAIN
17+
if (domain) {
18+
return new URL(relativeUrl, domain).toString()
19+
} else {
20+
return path.posix.resolve(BASE, relativeUrl)
21+
}
22+
}
1523

1624
// https://vitepress.dev/reference/site-config
1725
export default withMermaid(defineConfig({
@@ -122,7 +130,12 @@ export default withMermaid(defineConfig({
122130
`.trim())
123131
}
124132

125-
const hasH1 = /^\s*#\s+.+/m.test(content)
133+
// we check if the first n(200) characters contain the
134+
// Markdown for h1. note that the same sequence may show
135+
// up regularly in e.g. YAML comments in codeblocks, messing
136+
// with the logic. so we just hope no one uses this so early
137+
// in a document.
138+
const hasH1 = /^\s*#\s+.+/m.test(content.slice(0, 200))
126139
if (data.title && !hasH1) {
127140
injectedChunks.unshift(`# ${data.title}`)
128141
}
@@ -137,5 +150,23 @@ export default withMermaid(defineConfig({
137150
}
138151
]
139152
},
140-
ignoreDeadLinks: false
153+
ignoreDeadLinks: false,
154+
transformHead: ({ pageData }) => {
155+
const title = (() => {
156+
if (pageData.frontmatter.title) {
157+
return `${pageData.frontmatter.title} | Apeiro Reference Architecture`
158+
} else if (pageData.title) {
159+
return `${pageData.title} | Apeiro Reference Architecture`
160+
} else {
161+
return 'Apeiro Reference Architecture'
162+
}
163+
})()
164+
const head: HeadConfig[] = [
165+
['meta', { property: 'og:title', content: title }],
166+
['meta', { property: 'og:description', content: pageData.description || '' }],
167+
['meta', { property: 'og:url', content: resolveAbsoluteUrl(pageData.relativePath.replace('index.md', '').replace('.md', '')) }],
168+
['meta', { property: 'og:image', content: resolveAbsoluteUrl('./img/og-image.png') }],
169+
]
170+
return head
171+
}
141172
}))

0 commit comments

Comments
 (0)