Page MenuHomeSealhub

No OneTemporary

diff --git a/src/component-arguments.ts b/src/component-arguments.ts
index 2f73330..79184ea 100644
--- a/src/component-arguments.ts
+++ b/src/component-arguments.ts
@@ -1,62 +1,70 @@
export type ExtractComponentArgumentValue<C> = C extends ComponentArgument<
infer T
>
? T
: never;
export type ExtractStructuredComponentArgumentsValues<C> = {
[property in keyof C]: ExtractComponentArgumentValue<C[property]>;
};
export abstract class ComponentArgument<ARG extends any> {
ARG!: ARG; // this is for some reason necessary to make the ExtractComponentArgumentValue work. It seems like this argument has to appear somewhere in the structure of the class to make it work. Possibly it can be made into some function argument or smth
abstract getTypeName(): string;
}
export class ShortText extends ComponentArgument<string> {
getTypeName() {
return "short-text";
}
}
export class MarkdownArgument extends ComponentArgument<string> {
getTypeName() {
return "markdown";
}
}
export class List<
T extends ComponentArgument<unknown>
> extends ComponentArgument<Array<ExtractComponentArgumentValue<T>>> {
constructor(public item_type: T) {
super();
}
getTypeName() {
return "list";
}
}
export class Structured<
T extends Record<string, ComponentArgument<unknown>>
> extends ComponentArgument<{
[property in keyof T]: ExtractComponentArgumentValue<T[property]>;
}> {
constructor(public structure: T) {
super();
}
getTypeName() {
return "structured";
}
}
export class Image extends ComponentArgument<string> {
constructor(public path_to_image_on_fs: string) {
super();
}
getTypeName() {
return "image";
}
}
+
+export const ComponentArguments = {
+ Image,
+ Structured,
+ List,
+ Markdown: MarkdownArgument,
+ ShortText,
+};
diff --git a/src/components/markdown.ts b/src/components/markdown.ts
index 7f8aca5..cfca251 100644
--- a/src/components/markdown.ts
+++ b/src/components/markdown.ts
@@ -1,24 +1,23 @@
import { FlatTemplatable } from "tempstream";
import { Component } from "../component";
import {
ExtractStructuredComponentArgumentsValues,
MarkdownArgument,
} from "../component-arguments";
import { marked } from "marked";
const component_arguments = <const>{ markdown: new MarkdownArgument() };
-type A = ExtractStructuredComponentArgumentsValues<typeof component_arguments>;
export class Markdown extends Component<typeof component_arguments> {
getArguments() {
return component_arguments;
}
toHTML({
markdown,
}: ExtractStructuredComponentArgumentsValues<
typeof component_arguments
>): FlatTemplatable {
return marked.parse(markdown);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 23, 00:47 (23 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
547428
Default Alt Text
(2 KB)

Event Timeline