aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nuldoc-src/dom.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-11-27 06:29:01 +0900
committernsfisis <nsfisis@gmail.com>2025-11-27 06:29:01 +0900
commit83b1286354e0f5e83927c8fb35a584e587b5530b (patch)
treef8771f7808cd68b295c9e57051b7604de15fe8c8 /services/nuldoc/nuldoc-src/dom.ts
parent327622573dcb8879b9dba934792403a9fb7239a7 (diff)
downloadnsfisis.dev-83b1286354e0f5e83927c8fb35a584e587b5530b.tar.gz
nsfisis.dev-83b1286354e0f5e83927c8fb35a584e587b5530b.tar.zst
nsfisis.dev-83b1286354e0f5e83927c8fb35a584e587b5530b.zip
refactor(nuldoc): Refactor elem()
Diffstat (limited to 'services/nuldoc/nuldoc-src/dom.ts')
-rw-r--r--services/nuldoc/nuldoc-src/dom.ts110
1 files changed, 110 insertions, 0 deletions
diff --git a/services/nuldoc/nuldoc-src/dom.ts b/services/nuldoc/nuldoc-src/dom.ts
index be503a3..5faf184 100644
--- a/services/nuldoc/nuldoc-src/dom.ts
+++ b/services/nuldoc/nuldoc-src/dom.ts
@@ -63,6 +63,116 @@ export function elem(
};
}
+// Helper functions for commonly used elements
+export const a = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("a", attributes, ...children);
+
+export const article = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("article", attributes, ...children);
+
+export const button = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("button", attributes, ...children);
+
+export const div = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("div", attributes, ...children);
+
+export const footer = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("footer", attributes, ...children);
+
+export const h1 = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("h1", attributes, ...children);
+
+export const h2 = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("h2", attributes, ...children);
+
+export const h3 = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("h3", attributes, ...children);
+
+export const h4 = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("h4", attributes, ...children);
+
+export const h5 = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("h5", attributes, ...children);
+
+export const h6 = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("h6", attributes, ...children);
+
+export const header = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("header", attributes, ...children);
+
+export const img = (attributes?: Record<string, string>) =>
+ elem("img", attributes);
+
+export const li = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("li", attributes, ...children);
+
+export const link = (attributes?: Record<string, string>) =>
+ elem("link", attributes);
+
+export const meta = (attributes?: Record<string, string>) =>
+ elem("meta", attributes);
+
+export const nav = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("nav", attributes, ...children);
+
+export const ol = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("ol", attributes, ...children);
+
+export const p = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("p", attributes, ...children);
+
+export const script = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("script", attributes, ...children);
+
+export const section = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("section", attributes, ...children);
+
+export const span = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("span", attributes, ...children);
+
+export const ul = (
+ attributes?: Record<string, string>,
+ ...children: NodeLike[]
+) => elem("ul", attributes, ...children);
+
export function addClass(e: Element, klass: string) {
const classes = e.attributes.class;
if (classes === undefined) {