summaryrefslogtreecommitdiff
path: root/src/build/special_box.mjs
diff options
context:
space:
mode:
authorache <ache@ache.one>2022-05-02 02:08:35 +0200
committerache <ache@ache.one>2022-05-02 02:08:35 +0200
commit1e6f7a276688d00f222dbe2fa0f189ed3deff3aa (patch)
tree037b6bf1eb3c5566d75eb07d84e9a03016bf43b3 /src/build/special_box.mjs
parentDelete useless classes (diff)
New version of ache.one
Diffstat (limited to 'src/build/special_box.mjs')
-rw-r--r--src/build/special_box.mjs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/build/special_box.mjs b/src/build/special_box.mjs
new file mode 100644
index 0000000..0b284ec
--- /dev/null
+++ b/src/build/special_box.mjs
@@ -0,0 +1,24 @@
+import {visit} from 'unist-util-visit';
+
+// This plugin is an example to let users write HTML with directives.
+// It’s informative but rather useless.
+// See below for others examples.
+/** @type {import('unified').Plugin<[], import('mdast').Root>} */
+export default function specialBox() {
+ return tree => {
+ visit(tree, node => {
+ if (node.type === 'containerDirective' && (
+ node.name === 'attention'
+ || node.name === 'question'
+ || node.name === 'information')) {
+ const data = node.data || (node.data = {});
+
+ data.hName = 'div';
+ data.hProperties = {
+ className: 'special-box ' + node.name,
+ };
+ }
+ });
+ };
+}
+