You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2025/08/23 11:27:33 UTC
(echarts-handbook) 01/03: infra: (1) Support declare id for each heading. A unique id is used for the external link to a heading in an article. Previously id is auto-generated by heading text, which is unstable and varies across different languages. (2) add built-in variable `${apiPath}`
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch geo-base-map
in repository https://gitbox.apache.org/repos/asf/echarts-handbook.git
commit 342c5f9823524bae5e5baad76de4119826939b53
Author: 100pah <su...@gmail.com>
AuthorDate: Sat Aug 23 19:26:24 2025 +0800
infra: (1) Support declare id for each heading. A unique id is used for the external link to a heading in an article. Previously id is auto-generated by heading text, which is unstable and varies across different languages. (2) add built-in variable `${apiPath}`
---
configs/config.asf.js | 1 +
configs/config.dev.js | 3 +++
configs/config.gh.js | 1 +
configs/config.local.js | 1 +
configs/config.localsite.js | 1 +
package-lock.json | 18 ++++++++++++++++++
package.json | 3 ++-
pages/_.vue | 15 ++++++++++++---
8 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/configs/config.asf.js b/configs/config.asf.js
index f86e00a..be05fde 100644
--- a/configs/config.asf.js
+++ b/configs/config.asf.js
@@ -6,5 +6,6 @@ export default {
'https://echarts.apache.org/examples/${lang}/editor.html?c=',
mainSitePath: 'https://echarts.apache.org/',
optionPath: 'https://echarts.apache.org/option.html#',
+ apiPath: 'https://echarts.apache.org/api.html#',
gitRepo: 'apache/echarts-handbook'
}
diff --git a/configs/config.dev.js b/configs/config.dev.js
index 7539c76..e2cf1c1 100644
--- a/configs/config.dev.js
+++ b/configs/config.dev.js
@@ -1,5 +1,6 @@
export default {
routerBase: '/echarts-handbook/dist',
+
rootPath: 'http://localhost:3000/echarts-handbook/dist/',
exampleViewPath:
'http://localhost/echarts-examples/public/${lang}/view.html?c=',
@@ -7,5 +8,7 @@ export default {
'http://localhost/echarts-examples/public/${lang}/editor.html?c=',
mainSitePath: 'http://localhost/echarts-website/',
optionPath: 'http://localhost/echarts-website/option.html#',
+ apiPath: 'http://localhost/echarts/charts-website/api.html#',
+
gitRepo: 'apache/echarts-handbook'
}
diff --git a/configs/config.gh.js b/configs/config.gh.js
index 870ee1a..5098a1b 100644
--- a/configs/config.gh.js
+++ b/configs/config.gh.js
@@ -6,5 +6,6 @@ export default {
'https://echarts.apache.org/examples/${lang}/editor.html?c=',
mainSitePath: 'https://echarts.apache.org/',
optionPath: 'https://echarts.apache.org/option.html#',
+ apiPath: 'https://echarts.apache.org/api.html#',
gitRepo: 'apache/echarts-handbook'
}
diff --git a/configs/config.local.js b/configs/config.local.js
index 103546c..364e42e 100644
--- a/configs/config.local.js
+++ b/configs/config.local.js
@@ -7,5 +7,6 @@ export default {
'http://localhost/echarts-website/examples/${lang}/editor.html?c=',
mainSitePath: 'http://localhost/echarts-website/',
optionPath: 'http://localhost/echarts-website/option.html#',
+ apiPath: 'http://localhost/echarts-website/api.html#',
gitRepo: 'apache/echarts-handbook'
}
diff --git a/configs/config.localsite.js b/configs/config.localsite.js
index f5b703e..abe8e61 100644
--- a/configs/config.localsite.js
+++ b/configs/config.localsite.js
@@ -7,5 +7,6 @@ export default {
'http://localhost/echarts-website/examples/${lang}/editor.html?c=',
mainSitePath: 'http://localhost/echarts-website/',
optionPath: 'http://localhost/echarts-website/option.html#',
+ apiPath: 'http://localhost/echarts-website/api.html#',
gitRepo: 'apache/echarts-handbook'
}
diff --git a/package-lock.json b/package-lock.json
index 61d3693..4daf37f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,6 +18,7 @@
"lodash": "^4.17.21",
"markdown-it": "^12.2.0",
"markdown-it-anchor": "^8.1.2",
+ "markdown-it-attrs": "^4.3.1",
"nuxt": "^2.15.8",
"nuxt-i18n": "^6.28.1",
"prism-themes": "^1.9.0",
@@ -10783,6 +10784,17 @@
"markdown-it": "*"
}
},
+ "node_modules/markdown-it-attrs": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.3.1.tgz",
+ "integrity": "sha512-/ko6cba+H6gdZ0DOw7BbNMZtfuJTRp9g/IrGIuz8lYc/EfnmWRpaR3CFPnNbVz0LDvF8Gf1hFGPqrQqq7De0rg==",
+ "engines": {
+ "node": ">=6"
+ },
+ "peerDependencies": {
+ "markdown-it": ">= 9.0.0"
+ }
+ },
"node_modules/markdown-it/node_modules/entities": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz",
@@ -28212,6 +28224,12 @@
"integrity": "sha512-PI1qEHHkTNWT+X6Ip9w+paonfIQ+QZP9sCeMYi47oqhH+EsW8CrJ8J7CzV19QVOj6il8ATGbK2nTECj22ZHGvQ==",
"requires": {}
},
+ "markdown-it-attrs": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.3.1.tgz",
+ "integrity": "sha512-/ko6cba+H6gdZ0DOw7BbNMZtfuJTRp9g/IrGIuz8lYc/EfnmWRpaR3CFPnNbVz0LDvF8Gf1hFGPqrQqq7De0rg==",
+ "requires": {}
+ },
"math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
diff --git a/package.json b/package.json
index 1a9ad15..0b8c90e 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"description": "Apache ECharts Handbook",
"license": "Apache-2.0",
"scripts": {
- "dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider nuxt",
+ "dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider DEBUG=nuxt:* nuxt dev",
"start": "cross-env NODE_OPTIONS=--openssl-legacy-provider nuxt start",
"prepare-generate": "node build/generate-contributors.js && node build/generate",
"build:gh": "npm run prepare-generate && cross-env NODE_OPTIONS=--openssl-legacy-provider NUXT_ENV_DEPLOY=gh nuxt generate",
@@ -22,6 +22,7 @@
"lodash": "^4.17.21",
"markdown-it": "^12.2.0",
"markdown-it-anchor": "^8.1.2",
+ "markdown-it-attrs": "^4.3.1",
"nuxt": "^2.15.8",
"nuxt-i18n": "^6.28.1",
"prism-themes": "^1.9.0",
diff --git a/pages/_.vue b/pages/_.vue
index 0f359ec..f02f0ad 100644
--- a/pages/_.vue
+++ b/pages/_.vue
@@ -29,6 +29,7 @@
import '~/components/markdown/global'
import markdown from 'markdown-it'
import anchor from 'markdown-it-anchor'
+import markdownItAttrs from 'markdown-it-attrs'
import Contributors from '~/components/partials/Contributors.vue'
import PostContent from '~/components/partials/PostContent'
import * as base64 from 'js-base64'
@@ -62,6 +63,7 @@ function replaceVars(md: string, lang: string) {
// Replace variables
;[
'optionPath',
+ 'apiPath',
'mainSitePath',
'exampleViewPath',
'exampleEditorPath'
@@ -122,12 +124,13 @@ export default {
// @ts-ignore
this.$el.querySelector('.post-inner')?.querySelectorAll('h2,h3') || []
for (let i = 0; i < headers.length; i++) {
- const title = (headers[i] as HTMLHeadingElement).innerText
+ const headerItem = headers[i] as HTMLHeadingElement
+ const title = headerItem.innerText
// @ts-ignore
this.toc.push({
title,
- depth: +headers[i].nodeName.replace(/\D/g, ''),
- id: slugify(title)
+ depth: +headerItem.nodeName.replace(/\D/g, ''),
+ id: headerItem.id != null ? headerItem.id : slugify(title)
})
}
setTimeout(() => {
@@ -181,6 +184,12 @@ export default {
permalinkSymbol: '#',
permalinkClass: 'permalink'
})
+ .use(markdownItAttrs, {
+ leftDelimiter: '[[[',
+ rightDelimiter: ']]]',
+ // empty array = all attributes are allowed
+ allowedAttributes: ['id']
+ })
.use(function(md) {
const defaultImageRenderer = md.renderer.rules.image!
md.renderer.rules.image = function(tokens, idx, options, env, self) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org