fix: 使用新的 @awesome-fe/translate 版本
This commit is contained in:
parent
9b60ef0392
commit
45890e6df8
|
@ -101,7 +101,7 @@
|
||||||
"@angular/platform-browser-dynamic": "11.0.0",
|
"@angular/platform-browser-dynamic": "11.0.0",
|
||||||
"@angular/router": "11.0.0",
|
"@angular/router": "11.0.0",
|
||||||
"@angular/service-worker": "11.0.0",
|
"@angular/service-worker": "11.0.0",
|
||||||
"@awesome-fe/translate": "0.2.6",
|
"@awesome-fe/translate": "1.0.0",
|
||||||
"@webcomponents/custom-elements": "1.2.1",
|
"@webcomponents/custom-elements": "1.2.1",
|
||||||
"rxjs": "^6.5.3",
|
"rxjs": "^6.5.3",
|
||||||
"tslib": "^2.0.0",
|
"tslib": "^2.0.0",
|
||||||
|
@ -113,9 +113,9 @@
|
||||||
"@angular/compiler-cli": "11.0.0",
|
"@angular/compiler-cli": "11.0.0",
|
||||||
"@types/html-minifier": "^3.5.3",
|
"@types/html-minifier": "^3.5.3",
|
||||||
"@types/jasmine": "~3.6.0",
|
"@types/jasmine": "~3.6.0",
|
||||||
"@types/lunr": "^2.3.2",
|
|
||||||
"@types/klaw-sync": "^6.0.0",
|
"@types/klaw-sync": "^6.0.0",
|
||||||
"@types/lodash": "^4.14.133",
|
"@types/lodash": "^4.14.133",
|
||||||
|
"@types/lunr": "^2.3.2",
|
||||||
"@types/mkdirp": "^0.5.2",
|
"@types/mkdirp": "^0.5.2",
|
||||||
"@types/node": "^12.7.9",
|
"@types/node": "^12.7.9",
|
||||||
"@types/puppeteer": "^1.12.4",
|
"@types/puppeteer": "^1.12.4",
|
||||||
|
@ -142,8 +142,8 @@
|
||||||
"hast-util-to-string": "^1.0.0",
|
"hast-util-to-string": "^1.0.0",
|
||||||
"html": "^1.0.0",
|
"html": "^1.0.0",
|
||||||
"html-minifier": "^3.5.21",
|
"html-minifier": "^3.5.21",
|
||||||
"http-server-spa": "^1.3.0",
|
|
||||||
"http-server": "^0.11.1",
|
"http-server": "^0.11.1",
|
||||||
|
"http-server-spa": "^1.3.0",
|
||||||
"ignore": "^3.3.3",
|
"ignore": "^3.3.3",
|
||||||
"image-size": "^0.5.1",
|
"image-size": "^0.5.1",
|
||||||
"jasmine": "~3.6.0",
|
"jasmine": "~3.6.0",
|
||||||
|
@ -157,8 +157,8 @@
|
||||||
"karma-coverage": "~2.0.3",
|
"karma-coverage": "~2.0.3",
|
||||||
"karma-jasmine": "~4.0.0",
|
"karma-jasmine": "~4.0.0",
|
||||||
"karma-jasmine-html-reporter": "^1.5.0",
|
"karma-jasmine-html-reporter": "^1.5.0",
|
||||||
"light-server": "^2.6.2",
|
|
||||||
"klaw-sync": "^6.0.0",
|
"klaw-sync": "^6.0.0",
|
||||||
|
"light-server": "^2.6.2",
|
||||||
"lighthouse": "6.1.0",
|
"lighthouse": "6.1.0",
|
||||||
"lighthouse-logger": "^1.2.0",
|
"lighthouse-logger": "^1.2.0",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
|
@ -167,7 +167,6 @@
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"protractor": "~7.0.0",
|
"protractor": "~7.0.0",
|
||||||
"puppeteer": "5.1.0",
|
|
||||||
"puppeteer": "^1.12.2",
|
"puppeteer": "^1.12.2",
|
||||||
"rehype": "^6.0.0",
|
"rehype": "^6.0.0",
|
||||||
"rehype-slug": "^2.0.0",
|
"rehype-slug": "^2.0.0",
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
const {addIdForHeaders, markAndSwapAll} = require('@awesome-fe/translate');
|
const {Marker, defaultSelectors, DomDocumentFragment} = require('@awesome-fe/translate');
|
||||||
|
|
||||||
const {JSDOM} = require('jsdom');
|
|
||||||
|
|
||||||
const selectorGroups = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'section', 'p', 't'];
|
|
||||||
|
|
||||||
function mark(text) {
|
function mark(text) {
|
||||||
const dom = new JSDOM(text);
|
const marker = new Marker([...defaultSelectors, (node) => node.isTagOf('header') || node.isTagOf('section')]);
|
||||||
const body = dom.window.document.body;
|
const doc = DomDocumentFragment.parse(text);
|
||||||
addIdForHeaders(body);
|
marker.addIdForHeaders(doc);
|
||||||
markAndSwapAll(body, selectorGroups);
|
marker.markAndSwapAll(doc);
|
||||||
return body.innerHTML;
|
return doc.toHtml();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
864
aio/yarn.lock
864
aio/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue