hexo-design-cards 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.5] - 2026-03-02
4
+
5
+ ### Fixed
6
+ - Banner: added `id` attribute to `<h2>` for TOC anchor navigation (NExT theme TOC click-to-scroll now works)
7
+
3
8
  ## [0.1.4] - 2026-03-02
4
9
 
5
10
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-design-cards",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Beautiful design card tags for Hexo — flow diagrams, header cards, accent cards, comparison cards, quotes, alerts, mini cards, and section banners with customizable colorways.",
5
5
  "main": "index.js",
6
6
  "keywords": [
package/tags/banner.js CHANGED
@@ -1,11 +1,22 @@
1
1
  'use strict';
2
2
  const { getColorway } = require('../lib/colorways');
3
3
 
4
+ function slugify(text) {
5
+ return text
6
+ .trim()
7
+ .toLowerCase()
8
+ .replace(/[^\w\u3130-\u318F\uAC00-\uD7AF\u4E00-\u9FFF\s-]/g, '')
9
+ .replace(/[\s]+/g, '-')
10
+ .replace(/-+/g, '-')
11
+ .replace(/^-|-$/g, '');
12
+ }
13
+
4
14
  // {% banner "Section N: Title" %}
5
15
  module.exports = function(hexo) {
6
16
  hexo.extend.tag.register('banner', function(args) {
7
17
  const cw = getColorway(hexo, this);
8
18
  const text = args.join(' ').replace(/^"|"$/g, '');
9
- return '<div class="dc-banner" style="background:' + cw.c1 + '"><h2>' + text + '</h2></div>';
19
+ const id = slugify(text);
20
+ return '<div class="dc-banner" style="background:' + cw.c1 + '"><h2 id="' + id + '">' + text + '</h2></div>';
10
21
  });
11
22
  };
package/test/tags.test.js CHANGED
@@ -11,7 +11,7 @@ describe('hexo-design-cards tags', function() {
11
11
  const html = mock.callTag('banner', ['Getting Started']);
12
12
  assert(html.includes('dc-banner'));
13
13
  assert(html.includes('Getting Started'));
14
- assert(html.includes('<h2>'));
14
+ assert(html.includes('<h2 id="getting-started">'));
15
15
  });
16
16
  });
17
17