diff --git a/build/build.js b/build/build.js
index c8b9ab545..ceb5d7ae7 100644
--- a/build/build.js
+++ b/build/build.js
@@ -3,8 +3,8 @@ import { promises as fs } from 'fs';
import * as rollup from 'rollup';
import commonjs from '@rollup/plugin-commonjs';
import nodeResolve from '@rollup/plugin-node-resolve';
-import uglify from '@rollup/plugin-terser';
import replace from '@rollup/plugin-replace';
+import terser from '@rollup/plugin-terser';
import chokidar from 'chokidar';
import { relative } from './util.js';
@@ -54,6 +54,7 @@ async function build(opts) {
output: opts.globalName ? { name: opts.globalName } : {},
file: dest,
strict: false,
+ sourcemap: opts.sourcemap,
});
});
}
@@ -68,15 +69,14 @@ async function buildCore() {
})
);
- if (isProd) {
- promises.push(
- build({
- input: 'src/core/index.js',
- output: 'docsify.min.js',
- plugins: [uglify()],
- })
- );
- }
+ promises.push(
+ build({
+ input: 'src/core/index.js',
+ output: 'docsify.min.js',
+ plugins: [terser()],
+ sourcemap: true,
+ })
+ );
await Promise.all(promises);
}
@@ -102,17 +102,16 @@ async function buildAllPlugin() {
});
});
- if (isProd) {
- plugins.forEach(item => {
- promises.push(
- build({
- input: 'src/plugins/' + item.input,
- output: 'plugins/' + item.name + '.min.js',
- plugins: [uglify()],
- })
- );
- });
- }
+ plugins.forEach(item => {
+ promises.push(
+ build({
+ input: 'src/plugins/' + item.input,
+ output: 'plugins/' + item.name + '.min.js',
+ plugins: [terser()],
+ sourcemap: true,
+ })
+ );
+ });
await Promise.all(promises);
}
diff --git a/build/mincss.js b/build/mincss.js
index 3d480c1d8..45c0dc173 100644
--- a/build/mincss.js
+++ b/build/mincss.js
@@ -9,7 +9,7 @@ const files = fs
files.forEach(file => {
file = path.resolve('lib/themes', file);
cssnano
- .process(fs.readFileSync(file))
+ .process(fs.readFileSync(file), { from: file })
.then(result => {
file = file.replace(/\.css$/, '.min.css');
fs.writeFileSync(file, result.css);
diff --git a/docs/_media/example-with-yaml.md b/docs/_media/example-with-yaml.md
index 081bedde2..bfb280d74 100644
--- a/docs/_media/example-with-yaml.md
+++ b/docs/_media/example-with-yaml.md
@@ -3,4 +3,4 @@ author: John Smith
date: 2020-1-1
---
-> This is from the `example.md`
+> This is from the `example-with-yaml.md`
diff --git a/docs/embed-files.md b/docs/embed-files.md
index f06d121f8..60172d8ae 100644
--- a/docs/embed-files.md
+++ b/docs/embed-files.md
@@ -44,6 +44,8 @@ You will get:
## Markdown with YAML Front Matter
+Front Matter, commonly utilized in blogging systems like Jekyll, serves to define metadata for a document. The [front-matter.js](https://www.npmjs.com/package/front-matter) package facilitates the extraction of metadata (front matter) from documents.
+
When using Markdown, YAML front matter will be stripped from the rendered content. The attributes cannot be used in this case.
```markdown
diff --git a/docs/index.html b/docs/index.html
index 4b2a50996..0a7f78140 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -187,9 +187,7 @@
},
},
plugins: [
- function () {
- DocsifyCarbon.create('CEBI6KQE', 'docsifyjsorg');
- },
+ DocsifyCarbon.create('CEBI6KQE', 'docsifyjsorg'),
function (hook, vm) {
hook.beforeEach(html => {
if (/githubusercontent\.com/.test(vm.route.file)) {
@@ -219,6 +217,7 @@
+
diff --git a/package-lock.json b/package-lock.json
index d8ebddbe0..52401e1ea 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -46,7 +46,7 @@
"eslint-plugin-playwright": "^0.16.0",
"eslint-plugin-prettier": "^4.2.1",
"globals": "^13.20.0",
- "husky": "^8.0.3",
+ "husky": "^9.0.11",
"jest": "^27.4.7",
"lint-staged": "^13.2.2",
"mkdirp": "^3.0.0",
@@ -7681,15 +7681,15 @@
}
},
"node_modules/husky": {
- "version": "8.0.3",
- "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz",
- "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==",
+ "version": "9.0.11",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz",
+ "integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==",
"dev": true,
"bin": {
- "husky": "lib/bin.js"
+ "husky": "bin.mjs"
},
"engines": {
- "node": ">=14"
+ "node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
diff --git a/package.json b/package.json
index 98eb97210..54efbff52 100644
--- a/package.json
+++ b/package.json
@@ -97,7 +97,7 @@
"eslint-plugin-playwright": "^0.16.0",
"eslint-plugin-prettier": "^4.2.1",
"globals": "^13.20.0",
- "husky": "^8.0.3",
+ "husky": "^9.0.11",
"jest": "^27.4.7",
"lint-staged": "^13.2.2",
"mkdirp": "^3.0.0",
diff --git a/server.configs.js b/server.configs.js
index 2f0889c72..0360bd6a7 100644
--- a/server.configs.js
+++ b/server.configs.js
@@ -24,6 +24,8 @@ export const devConfig = {
files: ['CHANGELOG.md', 'docs/**/*', 'lib/**/*'],
port: 3000,
rewriteRules,
+ reloadDebounce: 1000,
+ reloadOnRestart: true,
server: {
...prodConfig.server,
routes: {
diff --git a/src/core/config.js b/src/core/config.js
index 9d9f8e31d..e3a191157 100644
--- a/src/core/config.js
+++ b/src/core/config.js
@@ -47,17 +47,19 @@ export default function (vm) {
return this.__themeColor;
},
set themeColor(value) {
- this.__themeColor = value;
- console.warn(
- stripIndent(/* html */ `
- $docsify.themeColor is deprecated. Use a --theme-color property in your style sheet. Example:
-
- `).trim()
- );
+ if (value) {
+ this.__themeColor = value;
+ console.warn(
+ stripIndent(`
+ $docsify.themeColor is deprecated. Use a --theme-color property in your style sheet. Example:
+
+ `).trim()
+ );
+ }
},
},
diff --git a/src/core/event/index.js b/src/core/event/index.js
index 6df41a83a..aa6ddae7e 100644
--- a/src/core/event/index.js
+++ b/src/core/event/index.js
@@ -31,7 +31,7 @@ export function Events(Base) {
// Move focus to content
if (query.id || source === 'navigate') {
- this.focusContent();
+ this.#focusContent();
}
if (loadNavbar) {
@@ -139,19 +139,15 @@ export function Events(Base) {
#enableScrollEvent = true;
#coverHeight = 0;
- #skipLink(el) {
- el = dom.getNode(el);
-
- if (el === null || el === undefined) {
- return;
- }
-
- dom.on(el, 'click', evt => {
- const target = dom.getNode('#main');
+ #skipLink(elm) {
+ elm = typeof elm === 'string' ? dom.find(elm) : elm;
+ elm?.addEventListener('click', evt => {
evt.preventDefault();
- target && target.focus();
- this.#scrollTo(target);
+ dom.getNode('main')?.scrollIntoView({
+ behavior: 'smooth',
+ });
+ this.#focusContent({ preventScroll: true });
});
}
@@ -177,7 +173,7 @@ export function Events(Base) {
.begin();
}
- focusContent() {
+ #focusContent(options = {}) {
const { query } = this.route;
const focusEl = query.id
? // Heading ID
@@ -188,7 +184,7 @@ export function Events(Base) {
dom.find('#main');
// Move focus to content area
- focusEl && focusEl.focus();
+ focusEl && focusEl.focus(options);
}
#highlight(path) {