From 71dc2c5c4ed61c1f50d2f41c3284d186af53785d Mon Sep 17 00:00:00 2001 From: jeremywu <15975785+JeremyWuuuuu@users.noreply.github.com> Date: Sun, 19 Sep 2021 00:12:50 +0800 Subject: [PATCH] chore(docs): website UI updates (#3477) --- .../crowdin/en-US/component/demo-block.json | 2 +- docs/.vitepress/plugins.js | 12 +- .../vitepress/components/globals/vp-demo.vue | 147 ------------------ .../vitepress/components/icons/copy-icon.vue | 8 + .../vitepress/components/vp-demo.vue | 70 +++++++-- docs/.vitepress/vitepress/utils.ts | 12 +- 6 files changed, 69 insertions(+), 182 deletions(-) delete mode 100644 docs/.vitepress/vitepress/components/globals/vp-demo.vue create mode 100644 docs/.vitepress/vitepress/components/icons/copy-icon.vue diff --git a/docs/.vitepress/crowdin/en-US/component/demo-block.json b/docs/.vitepress/crowdin/en-US/component/demo-block.json index adbc5d01f8..836c292822 100644 --- a/docs/.vitepress/crowdin/en-US/component/demo-block.json +++ b/docs/.vitepress/crowdin/en-US/component/demo-block.json @@ -2,7 +2,7 @@ "view-source": "View source", "edit-on-github": "Edit on Github", "edit-in-codepen": "Edit in Codepen.io", - "copy-button-text": "Copy", + "copy-code": "Copy code", "switch-button-option-text": "Switch to Options API", "switch-button-setup-text": "Switch to Composition API", "copy-success": "Copied!", diff --git a/docs/.vitepress/plugins.js b/docs/.vitepress/plugins.js index 6b2462b815..9641729a67 100644 --- a/docs/.vitepress/plugins.js +++ b/docs/.vitepress/plugins.js @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ +const localMd = require('markdown-it')() const mdContainer = require('markdown-it-container') const path = require('path') const fs = require('fs') @@ -19,8 +20,6 @@ module.exports = (md) => { const m = tokens[idx].info.trim().match(/^demo\s*(.*)$/) if (tokens[idx].nesting === 1) { const description = m && m.length > 1 ? m[1] : '' - const content = - tokens[idx + 1].type === 'fence' ? tokens[idx + 1].content : '' const sourceFileToken = tokens[idx + 2] let source = '' @@ -47,16 +46,13 @@ const demos = import.meta.globEager('../../examples/${ } if (!source) throw new Error(`Incorrect source file: ${sourceFile}`) - const { html, js, css, cssPreProcessor, jsPreProcessor } = generateCodePenSnippet(source) - return ` - ${description ? `` : ''} - - ` + )}" path="${sourceFile}" html="${html}" js="${js}" css="${css}" css-pre-processor="${cssPreProcessor}" js-pre-processor="${jsPreProcessor}" raw-source="${encodeURIComponent( + source + )}" description="${encodeURIComponent(localMd.render(description))}">` } return '' diff --git a/docs/.vitepress/vitepress/components/globals/vp-demo.vue b/docs/.vitepress/vitepress/components/globals/vp-demo.vue deleted file mode 100644 index 4b9f0d5590..0000000000 --- a/docs/.vitepress/vitepress/components/globals/vp-demo.vue +++ /dev/null @@ -1,147 +0,0 @@ - - - - - diff --git a/docs/.vitepress/vitepress/components/icons/copy-icon.vue b/docs/.vitepress/vitepress/components/icons/copy-icon.vue new file mode 100644 index 0000000000..867af831ba --- /dev/null +++ b/docs/.vitepress/vitepress/components/icons/copy-icon.vue @@ -0,0 +1,8 @@ + diff --git a/docs/.vitepress/vitepress/components/vp-demo.vue b/docs/.vitepress/vitepress/components/vp-demo.vue index ab3507492a..e93aefa816 100644 --- a/docs/.vitepress/vitepress/components/vp-demo.vue +++ b/docs/.vitepress/vitepress/components/vp-demo.vue @@ -1,5 +1,13 @@