Skip to content

Commit

Permalink
doc: enable setting need_import flag to false
Browse files Browse the repository at this point in the history
  • Loading branch information
airyland committed Apr 20, 2018
1 parent 3a28b28 commit 57b0b02
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 27 deletions.
95 changes: 69 additions & 26 deletions docs/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const MD = require('markdown-it')
const argv = require('yargs').argv
let langs = ['en', 'zh-CN']
const t = require('./i18n')
const pkg = require('../package.json')

const variables = {}
const variableMap = {}
Expand Down Expand Up @@ -343,6 +344,33 @@ export default {

langs.forEach(lang => {

const needImport = metas.need_import === false ? false : true

const gitMetas = require(`./${lang}/components/${componentName}_git_metas.json`)

// ldjson
const ldjson = {
"@context": "http://schema.org/",
"@type": "SoftwareApplication",
"name": `Vue Component ${componentName}`,
"screenshot": "",
"description": "Vue.js component for VUX",
"url": `/${lang}/components/${componentName}.html`,
"applicationCategory": t('Component', lang),
"author": {
"@type": "Organization",
"name": "VUX",
"url": "https://vux.li"
},
"downloadUrl": "https://vux.li",
"softwareVersion": pkg.version,
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": 5,
"reviewCount": gitMetas.commitCount
}
}

contents.push({
lang: lang,
category: t('Components', lang),
Expand Down Expand Up @@ -404,30 +432,37 @@ export default {
<div class="component-demo" style="width:377px;height:600px;display:inline-block;border:1px solid #ececec;border-radius:5px;overflow:hidden;z-index:2500;">
<iframe src="${urlWithNoTransition}" width="375" height="600" border="0" frameborder="0"></iframe>
</div>
<div class="import-code-box">
<el-tooltip content="${t('click to copy', lang)}" placement="top">
<span
v-clipboard:copy="localImportCode"
v-clipboard:success="onCopy"
v-clipboard:error="onCopyError">
<el-icon class="el-icon-document"></el-icon>
</span>
</el-tooltip>
${localImportCode}
</div>
<div class="import-code-box">
<el-tooltip content="${t('click to copy', lang)}" placement="top">
<span
v-clipboard:copy="globalImportCode"
v-clipboard:success="onCopy"
v-clipboard:error="onCopyError">
<el-icon class="el-icon-document"></el-icon>
</span>
</el-tooltip>
${globalImportCode}
</div>
<template v-if="needImport">
<div class="import-code-box">
<el-tooltip content="${t('click to copy', lang)}" placement="top">
<span
v-clipboard:copy="localImportCode"
v-clipboard:success="onCopy"
v-clipboard:error="onCopyError">
<el-icon class="el-icon-document"></el-icon>
</span>
</el-tooltip>
${localImportCode}
</div>
<div class="import-code-box">
<el-tooltip content="${t('click to copy', lang)}" placement="top">
<span
v-clipboard:copy="globalImportCode"
v-clipboard:success="onCopy"
v-clipboard:error="onCopyError">
<el-icon class="el-icon-document"></el-icon>
</span>
</el-tooltip>
${globalImportCode}
</div>
</template>
<template v-else>
<div class="tip">
<p>${t('donot need import', lang)}</p>
</div>
</template>
<div class="tip" style="width:600px;" v-if="metas.tip">
${ metas.tip ? metas.tip.replace(/`(.*?)`/g, '<code>$1</code>') : '' }
Expand Down Expand Up @@ -689,7 +724,14 @@ export default {
content: 'Vue component ${componentName} for the VUX framework.'
}],
// https://support.google.com/webmasters/answer/189077?hl=en
link: ${JSON.stringify(getAlternate(lang, `/${lang}/components/${componentName}.html`))}
link: ${JSON.stringify(getAlternate(lang, `/${lang}/components/${componentName}.html`))},
script: [
{
innerHTML:'${JSON.stringify(ldjson)}',
type: 'application/ld+json'
}
],
__dangerouslyDisableSanitizers: ['script']
},
filters: {
parseCode (str) {
Expand Down Expand Up @@ -767,7 +809,8 @@ export default {
gitMetas,
componentList,
localImportCode: \`${_localImportCode}\`,
globalImportCode: \`${_globalImportCode}\`
globalImportCode: \`${_globalImportCode}\`,
needImport: ${needImport}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions docs/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const list = {
Component: {
'zh-CN': '组件'
},
'donot need import': {
'en': 'You don\'t need to import this component.',
'zh-CN': '该组件可以直接使用,不需要引入。'
},
Releases: {
'zh-CN': '发布日志'
},
Expand Down
1 change: 0 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"markdown-it": "^8.3.1",
"ream": "^1.0.0-rc.6",
"shelljs": "^0.8.1",
"vue-markdown-loader": "^0.6.2",
"vue-server-renderer": "^2.5.16",
"yargs": "^11.0.0"
}
Expand Down
1 change: 1 addition & 0 deletions src/components/x-icon/metas.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
icon: '&#xe619;'
import_code: '&nbsp;'
need_import: false
extra:
en: |
Expand Down

0 comments on commit 57b0b02

Please sign in to comment.