mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-12 23:32:53 +01:00
fix: fix errors and reformat code
This commit is contained in:
@@ -11,21 +11,22 @@ import { h } from 'hastscript'
|
||||
* @returns {import('mdast').Parent} The created admonition component.
|
||||
*/
|
||||
export function AdmonitionComponent(properties, children, type) {
|
||||
if (!Array.isArray(children) || children.length === 0)
|
||||
return h("div",
|
||||
{ class: 'hidden' },
|
||||
'Invalid admonition directive. (Admonition directives must be of block type ":::note{name="name"} <content> :::")'
|
||||
);
|
||||
if (!Array.isArray(children) || children.length === 0)
|
||||
return h(
|
||||
'div',
|
||||
{ class: 'hidden' },
|
||||
'Invalid admonition directive. (Admonition directives must be of block type ":::note{name="name"} <content> :::")',
|
||||
)
|
||||
|
||||
let label = null
|
||||
if (properties && properties['has-directive-label']) {
|
||||
label = children[0]; // The first child is the label
|
||||
children = children.slice(1);
|
||||
label.tagName = "div"; // Change the tag <p> to <div>
|
||||
label = children[0] // The first child is the label
|
||||
children = children.slice(1)
|
||||
label.tagName = 'div' // Change the tag <p> to <div>
|
||||
}
|
||||
|
||||
return h(`blockquote`,
|
||||
{ class: `admonition bdm-${type}` },
|
||||
[ h("span", { class: `bdm-title` }, label ? label : type.toUpperCase()), ...children]
|
||||
);
|
||||
}
|
||||
return h(`blockquote`, { class: `admonition bdm-${type}` }, [
|
||||
h('span', { class: `bdm-title` }, label ? label : type.toUpperCase()),
|
||||
...children,
|
||||
])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user