Embed code

The code that embeds one of this site's pages elsewhere, in three formats, with a preview.

Trust: Unreviewed
Examples
Not recorded
Drift
Not recorded
Last reviewer
No reviewer recorded

Why this level

  • No review is recorded for this page, so its evidence has not been checked by a reviewer.

2 minutes read

On this page

An embed code turns an embedded page into a snippet another site can paste. It offers the iframe itself, a static HTML copy, and the same copy as Markdown, so a site that blocks frames still has something to use. The code is text: no script of ours runs on the host page.

Syntax

::embed-code{src="/embed-example/" title="Example page"}

The src names an embedded page: a site path or an absolute address. The component reads that page's title, description, embedded front matter, and published size and colour scheme, so the snippet and the preview always describe the same view.

Options

Name Type Default What it does
src string none The embedded page to show code for. A site path such as /embed-example/ or an absolute https address.
title string the embedded page's title The frame's accessible name.

Example

Frame

<iframe
  src="https://velella.sh/lateen/embed-example/"
  title="Embed example"
  width="100%"
  height="240"
  loading="lazy"
  sandbox="allow-popups allow-top-navigation-by-user-activation"
></iframe>

HTML

<h2>Embed example</h2>
<ul>
  <li>A small page used by the embed code example.</li>
</ul>
<p><a href="https://velella.sh/lateen/components/embed-code/">Embed example</a></p>

Markdown

## Embed example

- A small page used by the embed code example.

[Embed example](https://velella.sh/lateen/components/embed-code/)

The HTML and Markdown copies do not update by themselves. The frame always shows the current page.

The frame snippet names the page's absolute address, its title, its declared height, loading="lazy", and a sandbox. The HTML and Markdown panels carry the same title, the page's description and embedded.facts, and a link to the full page. They are copies: the note beside them says they do not update when the page changes.

Without JavaScript

Every format is visible at once, one panel after the other. The preview button is absent, and the link to the embedded page opens it in a new tab, so a reader can still see the view before copying the code.

Notes

  • Set url in the site configuration. Without it the component cannot build an absolute address and says so instead of showing code that would not work.
  • A page that publishes several embedded views of the same full page, such as a light and a dark one, gets a variant choice: the snippet and the preview change together.
  • Use the frame snippet for a live view, and the HTML or Markdown copies when the host's security policy blocks frames. Only the frame always shows the current page.
View Markdown

Use with an agent
View Markdown

Open in