8000 docs: update theme · coreui/coreui-vue@0cfa735 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cfa735

Browse files
committed
docs: update theme
1 parent 3be1428 commit 0cfa735

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

packages/docs/.vuepress/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import include_plugin from 'markdown-it-include'
44
import { defaultTheme } from './theme-coreui'
55

66
import { containerPlugin } from '@vuepress/plugin-container'
7+
import { registerComponentsPlugin } from '@vuepress/plugin-register-components'
78
import { tocPlugin } from '@vuepress/plugin-toc'
9+
import { getDirname, path } from '@vuepress/utils'
10+
11+
const __dirname = getDirname(import.meta.url)
812

913
export default defineUserConfig({
1014
base: `/vue/docs/`,
@@ -63,6 +67,11 @@ export default defineUserConfig({
6367
},
6468
}),
6569
tocPlugin({}),
70+
registerComponentsPlugin({
71+
components: {
72+
ScssDocs: path.resolve(__dirname, './theme-coreui/src/client/components/ScssDocs.vue'),
73+
},
74+
}),
6675
],
6776
theme: defaultTheme({
6877
sidebar: [
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<template>
2+
<div className="highlight">
3+
<pre class="prism-code language-scss" v-html="code" :style="{ 'max-height': '100%' }" />
4+
</div>
5+
</template>
6+
7+
<script lang="ts">
8+
import { defineComponent } from 'vue'
9+
import Prism from 'prismjs'
10+
import 'prismjs/components/prism-jsx'
11+
import 'prismjs/components/prism-scss'
12+
export default defineComponent({
13+
name: 'ScssDocs',
14+
props: {
15+
capture: String,
16+
file: String,
17+
},
18+
setup(props) {
19+
20+
if (typeof window !== 'undefined') {
21+
window.Prism = window.Prism || {};
22+
window.Prism.manual = true;
23+
}
24+
25+
const files = import.meta.glob(`../../../../../../../node_modules/@coreui/coreui/scss/**/*.scss`, {
26+
as: 'raw',
27+
eager: true,
28+
})
29+
const file = files[`../../../../../../../node_modules/@coreui/coreui/scss/${props.file}`]
30+
31+
const captureStart = `// scss-docs-start ${props.capture}`
32+
const captureEnd = `// scss-docs-end ${props.capture}`
33+
const re = new RegExp(`${captureStart}((?:.|\n)*)${captureEnd}`)
34+
const captured = re.exec(file)
35+
const section = captured && captured[1].trim()
36+
const code = section
37+
? Prism.highlight(
38+
section
39+
.replaceAll('--#{$prefix}', '--cui-')
40+
.replaceAll('\n -', '\n-')
41+
.replaceAll('\n @', '\n@'),
42+
Prism.languages.scss,
43+
'scss',
44+
)
45+
: null
46+
return {
47+
code,
48+
}
49+
},
50+
})
51+
</script>

packages/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@coreui/vue-chartjs": "^2.0.1",
1616
"@docsearch/css": "^3.4.0",
1717
"@docsearch/js": "^3.4.0",
18+
"@vuepress/plugin-register-components": "2.0.0-beta.62",
1819
"@vuepress/plugin-toc": "2.0.0-beta.62",
1920
"markdown-it-include": "^2.0.0",
2021
"vue-docgen-cli": "^4.67.0",

0 commit comments

Comments
 (0)
0