From d94c91f442b78b5a45dc30605fc47dd91ea08d96 Mon Sep 17 00:00:00 2001 From: Ben Hong Date: Tue, 18 Aug 2020 10:04:55 -0400 Subject: [PATCH] docs: reduce priority of 0.x docs (#2577) --- .../shared-utils/__tests__/slugify.spec.ts | 30 +++++++++++++++++++ packages/@vuepress/shared-utils/package.json | 1 - .../@vuepress/shared-utils/src/slugify.ts | 9 ++++-- packages/docs/docs/.vuepress/nav/en.js | 10 +++---- yarn.lock | 4 --- 5 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 packages/@vuepress/shared-utils/__tests__/slugify.spec.ts diff --git a/packages/@vuepress/shared-utils/__tests__/slugify.spec.ts b/packages/@vuepress/shared-utils/__tests__/slugify.spec.ts new file mode 100644 index 0000000000..517fea6cb5 --- /dev/null +++ b/packages/@vuepress/shared-utils/__tests__/slugify.spec.ts @@ -0,0 +1,30 @@ +import slugify from '../src/slugify' + +describe('slugify', () => { + test('should slugify', () => { + const asserts: Record = { + 'Привет': 'привет', + 'Лед üäöß': 'лед-uaoß', + 'hangul 가': 'hangul-가', + 'ع': 'ع', + 'džℍΩ': 'dzhω', + 'カi⁹': 'カi9', + // ㌀ -> アパート' + '㌀': decodeURIComponent('%E3%82%A2%E3%83%8F%E3%82%9A%E3%83%BC%E3%83%88'), + '¼': '_1⁄4', + 'džℍΩカi⁹¼': 'dzhωカi91⁄4', + 'Iлtèrnåtïonɑlíƶatï߀ԉ': 'iлternationɑliƶati߀ԉ', + 'Båcòл ípѕùm ðoɭ߀r ѕït aϻèt âùþê aԉᏧ߀üïlɭê ƃëéf culρá fïlèt ϻiǥnòn cuρiᏧatat ut êлim tòлɢùê.': + 'bacoл-ipѕum-ðoɭ߀r-ѕit-aϻet-auþe-aԉꮷ߀uilɭe-ƃeef-culρa-filet-ϻiǥnon-cuρiꮷatat-ut-eлim-toлɢue', + 'ᴎᴑᴅᴇȷʂ': 'ᴎᴑᴅᴇȷʂ', + 'hambúrguer': 'hamburguer', + 'hŒllœ': 'hœllœ', + 'Fußball': 'fußball', + 'ABCDEFGHIJKLMNOPQRSTUVWXYZé': 'abcdefghijklmnopqrstuvwxyze' + } + + Object.keys(asserts).forEach(input => { + expect(slugify(input)).toBe(asserts[input]) + }) + }) +}) diff --git a/packages/@vuepress/shared-utils/package.json b/packages/@vuepress/shared-utils/package.json index e054171979..b21c72e456 100644 --- a/packages/@vuepress/shared-utils/package.json +++ b/packages/@vuepress/shared-utils/package.json @@ -31,7 +31,6 @@ }, "dependencies": { "chalk": "^2.3.2", - "diacritics": "^1.3.0", "escape-html": "^1.0.3", "fs-extra": "^7.0.1", "globby": "^9.2.0", diff --git a/packages/@vuepress/shared-utils/src/slugify.ts b/packages/@vuepress/shared-utils/src/slugify.ts index 1a1c8dbb12..05883e0072 100644 --- a/packages/@vuepress/shared-utils/src/slugify.ts +++ b/packages/@vuepress/shared-utils/src/slugify.ts @@ -1,14 +1,17 @@ // string.js slugify drops non ascii chars so we have to // use a custom implementation here -import { remove as removeDiacritics } from 'diacritics' // eslint-disable-next-line no-control-regex const rControl = /[\u0000-\u001f]/g const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’–—<>,.?/]+/g +const rCombining = /[\u0300-\u036F]/g export = function slugify (str: string): string { - return removeDiacritics(str) - // Remove control characters + // Split accented characters into components + return str.normalize('NFKD') + // Remove accents + .replace(rCombining, '') + // Remove control characters .replace(rControl, '') // Replace special characters .replace(rSpecial, '-') diff --git a/packages/docs/docs/.vuepress/nav/en.js b/packages/docs/docs/.vuepress/nav/en.js index afe3be63c0..402ee99ae7 100644 --- a/packages/docs/docs/.vuepress/nav/en.js +++ b/packages/docs/docs/.vuepress/nav/en.js @@ -54,8 +54,12 @@ module.exports = [ ] }, { - text: 'Miscellaneous', + text: 'Resources', items: [ + { + text: '0.x Docs', + link: 'https://v0.vuepress.vuejs.org/' + }, { text: 'Migrate from 0.x', link: '/miscellaneous/migration-guide.html' @@ -67,9 +71,5 @@ module.exports = [ ] } ] - }, - { - text: '0.x', - link: 'https://v0.vuepress.vuejs.org/' } ] diff --git a/yarn.lock b/yarn.lock index daf6b8818b..099cf8daa9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5125,10 +5125,6 @@ dezalgo@^1.0.0: asap "^2.0.0" wrappy "1" -diacritics@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/diacritics/-/diacritics-1.3.0.tgz#3efa87323ebb863e6696cebb0082d48ff3d6f7a1" - didyoumean@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/didyoumean/-/didyoumean-1.2.1.tgz#e92edfdada6537d484d73c0172fd1eba0c4976ff"