k.utils.inlineHtml
Inline site-local page assets as data URIs or inline tags
| Execution Context | Prerequisites | Typical Use |
|---|---|---|
| KScript API, export scripts | Target site page name or relative URL must exist | Generating self-contained single-file HTML for emails or offline export |
k.utils.inlineHtml inlines site-local referenced resources stored in the current site database (images, files, CSS stylesheets/backgrounds, and scripts—covering <img>, <picture>, <script src>, <link href>, <style>, and inline style attributes) into data URIs or inline tags for single-file HTML export.
Resource Scope
Only site-local assets stored in the current site database (Images, Files, Scripts, and Styles) are inlined; external URLs starting with http://, https://, or protocol-relative // are explicitly skipped and never fetched.
Quick Start
k.api.get("exportSingleHtml", () => {
const html = k.utils.inlineHtml.convertPageInline("Home")
return { length: html ? html.length : 0, html }
})convertPageInline()
Convert a page and inline its resources by Page Name.
| Parameter | Type | Required | Description |
|---|---|---|---|
pageName | string | Yes | Page name |
Returns: string | null, HTML with resources inlined; returns null when the page does not exist.
const html = k.utils.inlineHtml.convertPageInline("Home")convertPageUrlInline()
Convert a page and inline its resources by Page Relative URL.
| Parameter | Type | Required | Description |
|---|---|---|---|
pageRelativeUrl | string | Yes | Page relative URL, such as /about |
Returns: string | null, HTML with resources inlined; returns null when the page does not exist.
const html = k.utils.inlineHtml.convertPageUrlInline("/about")TypeScript Definitions
interface KInlineHTML {
convertPageInline(PageName: string): string | null;
convertPageUrlInline(PageRelativeUrl: string): string | null;
}