Skip to content

Commit

Permalink
feat: add demo code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
pdanpdan committed Oct 10, 2023
1 parent 43d807e commit 0bb23c3
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 12 deletions.
18 changes: 15 additions & 3 deletions .vitepress/config.ts → .vitepress/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineConfig } from 'vitepress'

import VitePluginVitepressDemo from 'vite-plugin-vitepress-demo'

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "PDanPDan",
Expand All @@ -22,21 +24,31 @@ export default defineConfig({

nav: [
{ text: 'Home', link: '/' },
{ text: 'Examples', link: '/markdown-examples' }
{ text: 'Examples', link: '/markdown-examples/' }
],

sidebar: [
{
text: 'Examples',
items: [
{ text: 'Markdown Examples', link: '/markdown-examples' },
{ text: 'Runtime API Examples', link: '/api-examples' }
{ text: 'Markdown Examples', link: '/markdown-examples/' },
{ text: 'Runtime API Examples', link: '/api-examples/' }
]
}
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/pdanpdan' }
]
},

vite: {
plugins: [
VitePluginVitepressDemo( {
glob: [
'**/*.demo.vue'
]
}),
]
}
})
4 changes: 3 additions & 1 deletion .vitepress/theme/index.ts → .vitepress/theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { h } from 'vue'
import Theme from 'vitepress/theme'
import './style.css'

import { AntdTheme } from 'vite-plugin-vitepress-demo/theme'

export default {
extends: Theme,
Layout: () => {
Expand All @@ -11,6 +13,6 @@ export default {
})
},
enhanceApp({ app, router, siteData }) {
// ...
app.component( 'Demo', AntdTheme )
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"type": "module",

"scripts": {
"docs:dev": "vitepress dev",
"docs:build": "vitepress build",
"docs:preview": "vitepress preview"
},
"devDependencies": {
"vitepress": "1.0.0-rc.20",
"vite-plugin-vitepress-demo": "^2.1.0",
"vitepress": "^1.0.0-rc.20",
"vue": "^3.3.4"
},
"pnpm": {
Expand Down
18 changes: 18 additions & 0 deletions pages/api-examples/example_1.demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<docs>
---
title: Test Title 1
---

Hello World This is Test Docs block code in `docs.vue`.

</docs>

<template>
<div>{{ msg }}</div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
const msg = ref('Hello World')
</script>
5 changes: 5 additions & 0 deletions pages/api-examples.md → pages/api-examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ const { site, theme, page, frontmatter } = useData()
## More

Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).


## Tests

<demo src="./example_1.demo.vue" title="Test title" desc="Test description"></demo>
4 changes: 2 additions & 2 deletions pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ hero:
actions:
- theme: brand
text: Markdown Examples
link: /markdown-examples
link: /markdown-examples/
- theme: alt
text: API Examples
link: /api-examples
link: /api-examples/

features:
- title: Feature A
Expand Down
File renamed without changes.
Loading

0 comments on commit 0bb23c3

Please sign in to comment.