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 +5 -0
- package/package.json +1 -1
- package/tags/banner.js +12 -1
- package/test/tags.test.js +1 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hexo-design-cards",
|
|
3
|
-
"version": "0.1.
|
|
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
|
-
|
|
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
|
|