web/elements: pass full Markdown object to ak-markdown, get title from metadata
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -6,10 +6,16 @@ import AKGlobal from "../authentik.css";
|
||||
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
||||
import PFList from "@patternfly/patternfly/components/List/list.css";
|
||||
|
||||
export interface MarkdownDocument {
|
||||
html: string;
|
||||
metadata: { [key: string]: string };
|
||||
filename: string;
|
||||
}
|
||||
|
||||
@customElement("ak-markdown")
|
||||
export class Markdown extends LitElement {
|
||||
@property()
|
||||
md?: string;
|
||||
@property({ attribute: false })
|
||||
md?: MarkdownDocument;
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
return [PFList, PFContent, AKGlobal];
|
||||
@ -19,7 +25,8 @@ export class Markdown extends LitElement {
|
||||
if (!this.md) {
|
||||
return html``;
|
||||
}
|
||||
const finalHTML = this.md.replace("<ul>", `<ul class="pf-c-list">`);
|
||||
return html`${unsafeHTML(finalHTML)}`;
|
||||
const finalHTML = this.md?.html.replace("<ul>", "<ul class=\"pf-c-list\">");
|
||||
return html`${this.md?.metadata.title ? html`<h2>${this.md.metadata.title}</h2>` : html``}
|
||||
${unsafeHTML(finalHTML)}`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user