Skip to content

Commit

Permalink
fix: vitepress documentation build | update dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jan 30, 2023
1 parent a105803 commit 5663c71
Show file tree
Hide file tree
Showing 8 changed files with 3,583 additions and 1,529 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ coverage

# genereated file
docs/components
docs/.vitepress

# Docs compiled build
styleguide/*
Expand Down
5 changes: 2 additions & 3 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as path from "path";
import * as fs from 'fs'
import { fileURLToPath } from "url";
import { defineConfig } from "vitepress";
// Not supported with vite4, wait for next release "vitepress-plugin-search": "^1.0.4-alpha.16",
// import { SearchPlugin } from 'vitepress-plugin-search'
import { SearchPlugin } from 'vitepress-plugin-search'
import PackageJSON from '../../package.json'
import vueLiveMd from './vue-live-md-it.mjs'

Expand Down Expand Up @@ -100,7 +99,7 @@ export default defineConfig({

outDir: '../styleguide',
vite: {
plugins: [vueDocsPlugin /*, SearchPlugin()*/],
plugins: [vueDocsPlugin, SearchPlugin()],
},

markdown: {
Expand Down
6 changes: 3 additions & 3 deletions docs/.vitepress/theme/components/vue-live-with-layout.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, onMounted, ref, defineComponent } from "vue"
import { h, onMounted, ref, defineComponent, markRaw } from "vue"
import { VueLive } from "vue-live";
import layout from "./vue-live-layout.vue";

Expand All @@ -9,13 +9,13 @@ export default defineComponent({
const props = {...attrs}
onMounted(async () => {
const NcComponents = (await import('../../../../dist/index.esm.js')).NcComponents
props.components = markRaw({...NcComponents})
if ("requires" in props) {
props.requires = {}
props.requires = markRaw({})
await Promise.allSettled(Object.keys(attrs.requires).map(async (key) => {
props.requires[key] = (await attrs.requires[key]).default
}))
}
props.components = {...NcComponents}
ready.value = true
})
// return the render function
Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/vue-live-md-it.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function addVueLive(md, opts) {
// put all requires into a "requires" object
// add this as a prop
const imports = getImports(code)
const requires = imports.map(mod => `'${mod[1]}': import('../../node_modules/${mod[1]}${mod[1].startsWith('vue-material-design') ? '.vue' : ''}')`)
const requires = imports.map(mod => `"${mod[1]}": import("../../node_modules/${mod[1]}${mod[1].startsWith('vue-material-design') ? '.vue' : ''}")`)
const langArray = lang.split(' ')
const langClean = langArray[0]
const codeClean = md.utils.escapeHtml(code).replace(/\`/g, '\\`').replace(/\$/g, '\\$')
Expand All @@ -34,7 +34,7 @@ function addVueLive(md, opts) {
const markdownGenerated = `<vue-live ${jsx}
:layoutProps="{lang:'${langClean}'}"
:code="\`${codeClean}\`"
:requires="{${requires.join(',')}}"
:requires='{${requires.join(',')}}'
${editorProps ? ` :editorProps="${editorProps}"` : ''}
/>`
return markdownGenerated
Expand Down
Loading

0 comments on commit 5663c71

Please sign in to comment.