Skip to content

k.utils.inlineHtml ​

Inline site-local page assets as data URIs or inline tags

Execution ContextPrerequisitesTypical Use
KScript API, export scriptsTarget site page name or relative URL must existGenerating 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 ​

js
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.

ParameterTypeRequiredDescription
pageNamestringYesPage name

Returns: string | null, HTML with resources inlined; returns null when the page does not exist.

js
const html = k.utils.inlineHtml.convertPageInline("Home")

convertPageUrlInline() ​

Convert a page and inline its resources by Page Relative URL.

ParameterTypeRequiredDescription
pageRelativeUrlstringYesPage relative URL, such as /about

Returns: string | null, HTML with resources inlined; returns null when the page does not exist.

js
const html = k.utils.inlineHtml.convertPageUrlInline("/about")

TypeScript Definitions ​

ts
interface KInlineHTML {
  convertPageInline(PageName: string): string | null;
  convertPageUrlInline(PageRelativeUrl: string): string | null;
}