Page MenuHomeSealhub

jdd-component.ts
No OneTemporary

jdd-component.ts

import { toKebabCase, toPascalCase } from "js-convert-case";
export function jddComponentTemplate(component_name: string) {
return `import type { FlatTemplatable } from "tempstream";
import { TempstreamJSX } from "tempstream";
import type {
ExtractStructuredComponentArgumentsParsed,
JDDContext,
} from "@sealcode/jdd";
import { Component, ComponentArguments } from "@sealcode/jdd";
const component_arguments = {
title: new ComponentArguments.ShortText(),
content: new ComponentArguments.Markdown(),
} as const;
export class ${toPascalCase(
component_name
)} extends Component<typeof component_arguments> {
getArguments() {
return component_arguments;
}
toHTML(
{
title,
content,
}: ExtractStructuredComponentArgumentsParsed<typeof component_arguments>,
{ render_markdown }: JDDContext
): FlatTemplatable {
return (
<div class="${toKebabCase(component_name)}">
<h2>{title} • ${toPascalCase(component_name)} </h2>
<div>{render_markdown(content)}</div>
</div>
);
}
}
`;
}

File Metadata

Mime Type
text/x-java
Expires
Tue, Dec 24, 14:02 (18 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557215
Default Alt Text
jdd-component.ts (1022 B)

Event Timeline