提交 30db221c 编写于 作者: D DCloud_LXH

feat: update theme to 1.4.14

上级 be5a5771
......@@ -11,7 +11,7 @@ const base = '/uniCloud/'
const config = {
base,
theme: 'vuepress-theme-uni-app-test',
theme: 'vuepress-theme-uniapp-official',
title: 'uniCloud',
description: 'uniCloud Document',
evergreen: process.env.NODE_ENV === 'development',
......@@ -96,24 +96,6 @@ const config = {
.end()
.plugin('img-add-attrs')
.use(require('./markdown/img-add-attrs'))
.end()
.plugin('attrs')
.use(require('markdown-it-attrs'),[{
leftDelimiter: '#{',
rightDelimiter: '}'
}])
.end()
.plugin('task-lists')
.use(require('markdown-it-task-lists'))
.end()
.plugin('inject-json-to-md')
.use(require('./markdown/inject-json-to-md'))
.end()
.plugin('markdown-it-raw-table')
.use(require('markdown-it-raw-table'))
.end()
.plugin('add-base-to-md')
.use(require('./markdown/add-base-to-md'), [{ base }])
}
},
chainWebpack (config, isServer) {
......
......@@ -61,6 +61,7 @@ function replaceHTML(token, replace, env) {
const htmlparser = require('htmlparser2');
const serializer = require('dom-serializer');
const dom = new htmlparser.parseDocument(token.content, {
lowerCaseTags: false,
recognizeCDATA: true,
recognizeSelfClosing: true,
});
......
let cssJson = {};
let utsJson = {};
let utsApiJson = {};
let utsComJson = {};
let utsUnicloudApiJson = {};
let customTypeJson = {};
let vueJson = {};
let manifestJson = {};
let pagesJson = {};
let specialStringJson = {};
let pageInstanceJson = {};
try {
cssJson = require('../utils/cssJson.json');
} catch (error) {}
try {
utsJson = require('../utils/utsJson.json');
} catch (error) {}
try {
utsApiJson = require('../utils/utsApiJson.json');
} catch (error) {}
try {
utsComJson = require('../utils/utsComJson.json');
} catch (error) {}
try {
utsUnicloudApiJson = require('../utils/utsUnicloudApiJson.json');
} catch (error) {}
try {
customTypeJson = require('../utils/customTypeJson.json');
} catch (error) {}
try {
vueJson = require('../utils/vueJson.json');
} catch (error) {}
try {
manifestJson = require('../utils/manifestJson.json');
} catch (error) {}
try {
pagesJson = require('../utils/pagesJson.json');
} catch (error) {}
try {
specialStringJson = require('../utils/specialStringJson.json');
} catch (error) {}
try {
pageInstanceJson = require('../utils/pageInstanceJson.json');
} catch (error) {}
function getRegExp(key) {
return new RegExp(`<!--\\s*${key}.([\\w\\W]+[^\\s])\\s*-->`)
}
const getJSON = text => {
let match = text.match(getRegExp('CSSJSON'));
if (match) {
return {
match,
json: cssJson,
};
}
match = text.match(getRegExp('UTSJSON'));
if (match) {
return {
match,
json: utsJson,
};
}
match = text.match(getRegExp('UTSAPIJSON'));
if (match) {
return {
match,
json: utsApiJson,
};
}
match = text.match(getRegExp('UTSCOMJSON'));
if (match) {
return {
match,
json: utsComJson,
};
}
match = text.match(getRegExp('UTSUNICLOUDAPIJSON'));
if (match) {
return {
match,
json: utsUnicloudApiJson,
};
}
match = text.match(getRegExp('CUSTOMTYPEJSON'));
if (match) {
return {
match,
json: customTypeJson,
};
}
match = text.match(getRegExp('VUEJSON'));
if (match) {
return {
match,
json: vueJson,
};
}
match = text.match(getRegExp('MANIFESTJSON'));
if (match) {
return {
match,
json: manifestJson,
};
}
match = text.match(getRegExp('PAGESJSON'));
if (match) {
return {
match,
json: pagesJson,
};
}
match = text.match(getRegExp('SPECIALSTRINGJSON'));
if (match) {
return {
match,
json: specialStringJson,
};
}
match = text.match(getRegExp('PAGEINSTANCE'));
if (match) {
return {
match,
json: pageInstanceJson,
};
}
return {
match: null,
json: {},
};
};
module.exports = function (md, opts) {
if (Object.keys(cssJson) === 0) return false;
md.core.ruler.after('inline', 'merge-css', function (state) {
const ids = []
let idIdx = 1
for (let index = 0; index < state.tokens.length; index++) {
const blockToken = state.tokens[index];
if (blockToken.type === 'html_block') {
const { match, json } = getJSON(blockToken.content);
if (match) {
const jsonPath = match[1];
const path = jsonPath.split('.');
let temp = json;
path.forEach(key => {
if (!temp) return false;
temp = temp[key];
});
if (!temp) continue;
const parseTokens = md.parse(temp);
parseTokens.forEach(token => {
if (token.type === 'heading_open') {
const id = token.attrGet('id')
if(ids.includes(id)) {
token.attrSet('id', `${id}_${idIdx++}`)
} else {
ids.push(id)
}
}
})
state.tokens.splice(index, 1, ...parseTokens);
index = index + parseTokens.length - 1;
// blockToken.content = temp
}
}
}
return false;
});
};
{
"name": "unidocs-unicloud-zh",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"doc": "docs"
},
"scripts": {
"dev": "vuepress dev docs",
"build": "node --max_old_space_size=4096 ./node_modules/vuepress/cli.js build docs --no-cache",
"build-lite": "cross-env DOCS_LITE=true node --max_old_space_size=4096 ./node_modules/vuepress/cli.js build docs-lite --no-cache",
"check-md":"vuepress check-md2 docs"
},
"repository": {
"type": "git",
"url": "git+https://gitcode.net/dcloud/unidocs-uni-app-x-zh.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://gitcode.net/dcloud/unidocs-uni-app-x-zh/issues"
},
"homepage": "https://gitcode.net/dcloud/unidocs-uni-app-x-zh#readme",
"devDependencies": {
"cross-env": "^7.0.3",
"dom-serializer": "^2.0.0",
"fs-extra": "^10.0.0",
"glob": "^7.1.7",
"htmlparser2": "^9.0.0",
"markdown-it-attrs": "^4.1.6",
"markdown-it-raw-table": "^1.0.0",
"markdown-it-task-lists": "^2.1.1",
"vuepress-theme-uni-app-test": "^1.4.10"
},
"dependencies": {
"@docsearch/js": "^3.1.0",
"node-html-parser": "^6.1.4",
"vuepress": "1.9.9"
}
"name": "unidocs-unicloud-zh",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"doc": "docs"
},
"scripts": {
"dev": "vuepress dev docs",
"build": "node --max_old_space_size=4096 ./node_modules/vuepress/cli.js build docs --no-cache",
"build-lite": "cross-env DOCS_LITE=true node --max_old_space_size=4096 ./node_modules/vuepress/cli.js build docs-lite --no-cache",
"check-md": "vuepress check-md2 docs"
},
"repository": {
"type": "git",
"url": "git+https://gitcode.net/dcloud/unidocs-uni-app-x-zh.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://gitcode.net/dcloud/unidocs-uni-app-x-zh/issues"
},
"homepage": "https://gitcode.net/dcloud/unidocs-uni-app-x-zh#readme",
"devDependencies": {
"cross-env": "^7.0.3",
"dom-serializer": "^2.0.0",
"fs-extra": "^10.0.0",
"glob": "^7.1.7",
"htmlparser2": "^9.0.0"
},
"dependencies": {
"vuepress-theme-uniapp-official": "^1.4.14",
"vuepress": "1.9.9"
}
}
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册