on master help sign in
schema: add footnote schemas
a46c3e9Matilde Park
components/schema/footnoteItem.markdoc.jsnew file+22
@@ -0,0 +1,22 @@
1+import { Ast, Config, Node, Tag } from "@markdoc/markdoc";
2+
3+export const footnoteItem = {
4+ attributes: {
5+ id: { type: String, render: true, required: true },
6+ href: { type: String, render: false, required: true },
7+ },
8+ transform(node, config) {
9+ node.attributes.class = `footnote-item`;
10+ const anchor = new Ast.Node(
11+ "link",
12+ { class: "footnote-anchor", href: node.attributes.href },
13+ [new Ast.Node("text", { content: "↩" })]
14+ );
15+ node.push(anchor);
16+ return new Tag(
17+ "li",
18+ node.transformAttributes(config),
19+ node.transformChildren(config)
20+ );
21+ },
22+};
components/schema/footnoteRef.markdoc.jsnew file+14
@@ -0,0 +1,14 @@
1+import { Config, Node, Tag } from "@markdoc/markdoc";
2+
3+export const footnoteRef = {
4+ attributes: {
5+ id: { type: String, render: true, required: true },
6+ href: { type: String, render: true, required: true },
7+ label: { type: String, render: false, required: true },
8+ },
9+ transform(node, config) {
10+ const attributes = node.transformAttributes(config);
11+ const link = new Tag("a", attributes, [`${node.attributes.label}`]);
12+ return new Tag(`sup`, { class: "footnote-ref" }, [link]);
13+ },
14+};