@dosgato/templating
Advanced tools
Comparing version 0.0.84 to 0.0.85
import { ContextBase, DataData, PageData, PageRecord, PageRecordOptionalData } from './component.js'; | ||
import { AssetLink, DataFolderLink, DataLink, LinkDefinition, PageLink } from './links.js'; | ||
export declare function printHeader(ctx: ContextBase, content: string): string; | ||
export declare function advanceHeader(ctx: ContextBase, content?: string): { | ||
export declare function printHeader(ctx: ContextBase, content: string | undefined | null, attributes?: Record<string, string>): string; | ||
export declare function advanceHeader(ctx: ContextBase, content: string | undefined | null): { | ||
headerLevel: number; | ||
@@ -6,0 +6,0 @@ }; |
@@ -1,11 +0,12 @@ | ||
import { isBlank } from 'txstate-utils'; | ||
export function printHeader(ctx, content) { | ||
import { htmlEncode, isBlank } from 'txstate-utils'; | ||
export function printHeader(ctx, content, attributes) { | ||
if (isBlank(content)) | ||
return ''; | ||
const level = (ctx.headerLevel ?? 0) + 1; | ||
const attr = attributes ? ' ' + Object.entries(attributes).map(([key, val]) => `${key}="${htmlEncode(val)}"`).join(' ') : ''; | ||
if (level < 1) | ||
return `<h1>${content}</h1>`; | ||
return `<h1${attr}>${content}</h1>`; | ||
if (level > 6) | ||
return `<h6>${content}</h6>`; | ||
return `<h${level}>${content}</h${level}>`; | ||
return `<h6${attr}>${content}</h6>`; | ||
return `<h${level}${attr}>${content}</h${level}>`; | ||
} | ||
@@ -12,0 +13,0 @@ export function advanceHeader(ctx, content) { |
@@ -30,6 +30,11 @@ import { ComponentData, PageData } from './component.js'; | ||
* - page: DialogPageProp, the current page so that you can reference the full page data or | ||
* make a further graphql query based on its id/path. | ||
* make a further graphql query based on its id/path. Component dialogs only, page and data | ||
* dialogs do not receive this prop | ||
* - templateProperties: the template properties for the current page template, so you can make | ||
* things like color pickers that visually match the colors of the current page template | ||
* things like color pickers that visually match the colors of the current page template. | ||
* Data dialogs do not receive this. | ||
* - environmentConfig: base URLs in case you need to generate a link to the API or something | ||
* | ||
* In addition to the props, you may import the `dialogQuery` function (see below) to send | ||
* requests to the API. | ||
*/ | ||
@@ -68,3 +73,3 @@ dialog?: new (...args: any[]) => any; | ||
* This is a type for the data that will be passed to dialog Svelte components as | ||
* the `page` prop. | ||
* the `page` prop. Note that page template dialogs do NOT receive this prop. | ||
*/ | ||
@@ -71,0 +76,0 @@ export interface DialogPageProp { |
{ | ||
"name": "@dosgato/templating", | ||
"version": "0.0.84", | ||
"version": "0.0.85", | ||
"description": "A library to support building templates for dosgato CMS.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
80494
1830