Skip to content

Commit

Permalink
chore(docs): import vitepress-theme-demoblock
Browse files Browse the repository at this point in the history
  • Loading branch information
akinoccc committed Apr 10, 2024
1 parent 276a03b commit 40b841b
Show file tree
Hide file tree
Showing 8 changed files with 773 additions and 46 deletions.
6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/git_toolbox_prj.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
import { defineConfig } from 'vitepress'
import { demoblockPlugin, demoblockVitePlugin } from 'vitepress-theme-demoblock'

// https://vitepress.dev/reference/site-config
export default defineConfig({
base: '/vue3-styled-components/',
title: 'Vue3 Styled Components',
description: 'A tool for css in js.',
themeConfig: {
demoblock: {
'root': {
'view-source': 'View source',
'hide-source': 'Hide source',
'edit-in-editor': 'Edit in Playground',
'edit-on-github': 'Edit on GitHub',
'copy-code': 'Copy code',
'copy-success': 'Copy success',
'copy-error': 'Copy error',
},
'zh': {
'view-source': '查看源代码',
'hide-source': '隐藏源代码',
'edit-in-editor': '在 Playground 中编辑',
'edit-on-github': '在 Github 中编辑',
'copy-code': '复制代码',
'copy-success': '复制成功',
'copy-error': '复制失败'
}
},

// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Home', link: '/' },
Expand All @@ -26,4 +48,13 @@ export default defineConfig({
{ icon: 'github', link: 'https://github.com/vue-styled-components/vue3-styled-components' },
],
},
markdown: {
config: (md) => {
md.use(demoblockPlugin)
}
},
vite: {
plugins: [demoblockVitePlugin()]
},
vue: {}
})
7 changes: 5 additions & 2 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { h } from 'vue'
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import './style.css'
import 'vitepress-theme-demoblock/dist/theme/styles/index.css'
import { useComponents } from './useComponents'

export default {
extends: DefaultTheme,
Expand All @@ -11,7 +13,8 @@ export default {
// https://vitepress.dev/guide/extending-default-theme#layout-slots
})
},
enhanceApp({ app, router, siteData }) {
// ...
enhanceApp(ctx) {
DefaultTheme.enhanceApp(ctx)
useComponents(ctx.app)
}
} satisfies Theme
8 changes: 8 additions & 0 deletions docs/.vitepress/theme/useComponents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Don't remove this file, because it registers the demo components.
import Demo from 'vitepress-theme-demoblock/dist/client/components/Demo.vue'
import DemoBlock from 'vitepress-theme-demoblock/dist/client/components/DemoBlock.vue'

export function useComponents(app) {
app.component('Demo', Demo)
app.component('DemoBlock', DemoBlock)
}
50 changes: 7 additions & 43 deletions docs/api-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,12 @@
outline: deep
---

# Runtime API Examples
## Demo

This page demonstrates usage of some of the runtime APIs provided by VitePress.

The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files:

```md
<script setup>
import { useData } from 'vitepress'

const { theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>
:::demo
```vue
<template>
<h3>Demo Test</h3>
</template>
```

<script setup>
import { useData } from 'vitepress'

const { site, theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>

## More

Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).
:::
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"vitepress": "^1.0.2"
"vitepress": "^1.0.2",
"vitepress-theme-demoblock": "^3.0.7"
}
}
Loading

0 comments on commit 40b841b

Please sign in to comment.