Skip to main content

DEFAULT_PREVIEW_TEMPLATE

Constant DEFAULT_PREVIEW_TEMPLATE 

Source
pub const DEFAULT_PREVIEW_TEMPLATE: &str = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"utf-8\" />\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n  <title>{{ title }} \u{2014} preview</title>\n  <script>(function(){try{\n  var s=localStorage.getItem(\'doc-theme\');\n  var t=s||(matchMedia(\'(prefers-color-scheme: light)\').matches?\'light\':\'dark\');\n  document.documentElement.setAttribute(\'data-theme\',t);\n}catch(e){}})();</script>\n  <link rel=\"stylesheet\" href=\"{{ base | safe }}/docgen.css\" />\n  <link rel=\"stylesheet\" href=\"{{ base | safe }}/code.css\" />\n  {% if has_components_css %}<link rel=\"stylesheet\" href=\"{{ base | safe }}/components.css\" />{% endif %}\n  {% if has_math %}<link rel=\"stylesheet\" href=\"{{ base | safe }}/vendor/katex/katex.min.css\" />{% endif %}\n  <style>\n    /* The preview is the published article content with no app chrome:\n       `.docgen-doc-content` already supplies the reading column + prose styles\n       from docgen.css; here we only add the outer padding the `.docgen-content`\n       main would normally provide. */\n    html, body { margin: 0; background: var(--bg); }\n    body.docgen-preview-body { padding: 32px 40px 80px; }\n  </style>\n</head>\n<body class=\"docgen-app docgen-preview-body\">\n  <article class=\"docgen-doc-content\">\n    {{ body | safe }}\n  </article>\n  <!-- island infra: same stack a published page runs, so mermaid diagrams,\n       custom components, and wikilink tooltips hydrate identically here. -->\n  <script>window.DOCGEN_BASE = {{ base | tojson | safe }};</script>\n  <script src=\"{{ base | safe }}/bootstrap.js\"></script>\n  <script src=\"{{ base | safe }}/islands/wikilink.js\"></script>\n  {% if has_mermaid %}<script src=\"{{ base | safe }}/islands/mermaid.js\"></script>{% endif %}\n  {% if has_component_island %}<script src=\"{{ base | safe }}/components.js\"></script>{% endif %}\n  <script src=\"{{ base | safe }}/vendor/alpine/alpine.min.js\" defer></script>\n</body>\n</html>\n";
Expand description

The dev editor’s live-preview document template, embedded at compile time. Content-only (no app chrome): the rendered article wrapped in the SAME asset and island stack a published page uses, so a doc previewed in the editor renders identically to its built page (mermaid, components, tooltips, math).