Skip to content

Commit ded1b4e

Browse files
authored
docs: make it easy to share with LLMs (#3003)
Co-authored-by: Oli Morris <[email protected]>
1 parent 73833a0 commit ded1b4e

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

doc/.vitepress/config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { defineConfig } from "vitepress";
33
import { execSync } from "node:child_process";
44
import { withMermaid } from "vitepress-plugin-mermaid";
55
import llmstxt from "vitepress-plugin-llms";
6+
import { copyOrDownloadAsMarkdownButtons } from "vitepress-plugin-llms";
67

78
const inProd = process.env.NODE_ENV === "production";
89

@@ -78,6 +79,11 @@ export default withMermaid(
7879
vite: {
7980
plugins: [llmstxt()],
8081
},
82+
markdown: {
83+
config(md) {
84+
md.use(copyOrDownloadAsMarkdownButtons);
85+
},
86+
},
8187
mermaid: {
8288
securityLevel: "loose", // Allows more flexibility
8389
theme: "base", // Use base theme to allow CSS variables to take effect
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { defineClientComponent, useData } from "vitepress";
2+
import { computed, defineComponent } from "vue";
3+
4+
const ClientCopyOrDownloadAsMarkdownButtons = defineClientComponent(() => {
5+
return import("vitepress-plugin-llms/vitepress-components/CopyOrDownloadAsMarkdownButtons.vue");
6+
});
7+
8+
export default defineComponent({
9+
name: "CopyOrDownloadAsMarkdownButtons",
10+
setup() {
11+
const { page } = useData();
12+
13+
const shouldShow = computed(() => {
14+
// Hide component if path starts with /zh
15+
return !page.value.relativePath.startsWith("zh");
16+
});
17+
18+
return () => {
19+
if (!shouldShow.value) return null;
20+
21+
return <ClientCopyOrDownloadAsMarkdownButtons />;
22+
};
23+
},
24+
});

doc/.vitepress/theme/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import DefaultTheme from "vitepress/theme";
2+
import CopyOrDownloadAsMarkdownButtons from "vitepress-plugin-llms/vitepress-components/CopyOrDownloadAsMarkdownButtons.vue";
3+
24
import "./vaporwave.css";
35

46
export default {
57
extends: DefaultTheme,
8+
enhanceApp({ app }) {
9+
app.component(
10+
"CopyOrDownloadAsMarkdownButtons",
11+
CopyOrDownloadAsMarkdownButtons,
12+
);
13+
},
614
};

doc/.vitepress/theme/vaporwave.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
--vw-blue: #118dc3;
88
--vw-yellow: #eea825;
99

10-
.VPMenu {
10+
.VPMenu,
11+
.dropdown-menu {
1112
background-color: var(--vp-c-bg) !important;
1213
}
1314

0 commit comments

Comments
 (0)