build(docs): allow using custom editLink

In Vitepress, allow using a custom `editLink`, if specified in the YAML
frontmatter.
This commit is contained in:
Alois Klink
2023-07-15 23:09:02 +01:00
parent 57ee181fad
commit af9b3f77cb

View File

@@ -35,7 +35,12 @@ export default defineConfig({
themeConfig: {
nav: nav(),
editLink: {
pattern: 'https://github.com/mermaid-js/mermaid/edit/develop/packages/mermaid/src/docs/:path',
pattern: ({ filePath, frontmatter }) => {
if (typeof frontmatter.editLink === 'string') {
return frontmatter.editLink;
}
return `https://github.com/mermaid-js/mermaid/edit/develop/packages/mermaid/src/docs/${filePath}`;
},
text: 'Edit this page on GitHub',
},
sidebar: {