From 343c0054f258c80ba987dfeead5a702d25f47082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Bl=C3=A4ttermann?= Date: Mon, 21 Nov 2022 17:46:05 +0100 Subject: [PATCH] Simplify unnessary adding of id to sections The slugified section ids are useless, because they can not be referenced anywhere anyway. The navigation only works if the section has the same id as the heading. --- website/package-lock.json | 83 -------------------------- website/package.json | 1 - website/plugins/index.mjs | 4 +- website/plugins/remarkWrapSections.mjs | 9 --- 4 files changed, 3 insertions(+), 94 deletions(-) diff --git a/website/package-lock.json b/website/package-lock.json index 30dc082b4..39c51c2fb 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -11,7 +11,6 @@ "@mdx-js/loader": "^2.1.5", "@mdx-js/react": "^2.1.5", "@next/mdx": "^13.0.2", - "@sindresorhus/slugify": "^2.1.1", "@types/node": "18.11.9", "@types/react": "18.0.25", "@types/react-dom": "18.0.8", @@ -297,57 +296,6 @@ "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz", "integrity": "sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg==" }, - "node_modules/@sindresorhus/slugify": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@sindresorhus/slugify/-/slugify-2.1.1.tgz", - "integrity": "sha512-XokPHZ+q6FtQGEi1hnfvARVJJVPEhwHQTPHPPuNHaN6zcHjzYNynhhHMopa1wNPqLAFOwpsbintunEqWecXJMg==", - "dependencies": { - "@sindresorhus/transliterate": "^1.0.0", - "escape-string-regexp": "^5.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@sindresorhus/slugify/node_modules/escape-string-regexp": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", - "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@sindresorhus/transliterate": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/transliterate/-/transliterate-1.6.0.tgz", - "integrity": "sha512-doH1gimEu3A46VX6aVxpHTeHrytJAG6HgdxntYnCFiIFHEM/ZGpG8KiZGBChchjQmG0XFIBL552kBTjVcMZXwQ==", - "dependencies": { - "escape-string-regexp": "^5.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@sindresorhus/transliterate/node_modules/escape-string-regexp": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", - "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@swc/helpers": { "version": "0.4.11", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.11.tgz", @@ -5349,37 +5297,6 @@ "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz", "integrity": "sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg==" }, - "@sindresorhus/slugify": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@sindresorhus/slugify/-/slugify-2.1.1.tgz", - "integrity": "sha512-XokPHZ+q6FtQGEi1hnfvARVJJVPEhwHQTPHPPuNHaN6zcHjzYNynhhHMopa1wNPqLAFOwpsbintunEqWecXJMg==", - "requires": { - "@sindresorhus/transliterate": "^1.0.0", - "escape-string-regexp": "^5.0.0" - }, - "dependencies": { - "escape-string-regexp": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", - "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==" - } - } - }, - "@sindresorhus/transliterate": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/transliterate/-/transliterate-1.6.0.tgz", - "integrity": "sha512-doH1gimEu3A46VX6aVxpHTeHrytJAG6HgdxntYnCFiIFHEM/ZGpG8KiZGBChchjQmG0XFIBL552kBTjVcMZXwQ==", - "requires": { - "escape-string-regexp": "^5.0.0" - }, - "dependencies": { - "escape-string-regexp": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", - "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==" - } - } - }, "@swc/helpers": { "version": "0.4.11", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.11.tgz", diff --git a/website/package.json b/website/package.json index d76090594..1a2505b7f 100644 --- a/website/package.json +++ b/website/package.json @@ -13,7 +13,6 @@ "@mdx-js/loader": "^2.1.5", "@mdx-js/react": "^2.1.5", "@next/mdx": "^13.0.2", - "@sindresorhus/slugify": "^2.1.1", "@types/node": "18.11.9", "@types/react": "18.0.25", "@types/react-dom": "18.0.8", diff --git a/website/plugins/index.mjs b/website/plugins/index.mjs index 7d8cf5605..fe2e29758 100644 --- a/website/plugins/index.mjs +++ b/website/plugins/index.mjs @@ -1,5 +1,7 @@ import remarkWrapSections from './remarkWrapSections.mjs' -const remarkPlugins = [remarkWrapSections] +const remarkPlugins = [ + remarkWrapSections, +] export default remarkPlugins diff --git a/website/plugins/remarkWrapSections.mjs b/website/plugins/remarkWrapSections.mjs index 96bf67f84..c93fc975f 100644 --- a/website/plugins/remarkWrapSections.mjs +++ b/website/plugins/remarkWrapSections.mjs @@ -5,7 +5,6 @@ */ import { visit } from 'unist-util-visit' -import slugify from '@sindresorhus/slugify' const defaultOptions = { element: 'section', @@ -14,13 +13,6 @@ const defaultOptions = { slugify: true, } -function slugifyNode(node) { - if (node.children.length && node.children[0].type === 'text') { - return slugify(node.children[0].value) - } - return null -} - function remarkWrapSection(userOptions = {}) { const options = Object.assign({}, defaultOptions, userOptions) @@ -40,7 +32,6 @@ function remarkWrapSection(userOptions = {}) { if (node.depth === options.depth) { const data = node.data || (node.data = {}) const hProps = data.hProperties || (data.hProperties = {}) - hProps.id = hProps.id ? hProps.id : slugifyNode(node) headingsMap.push({ index, id: hProps.id }) } })