Skip to main content

Module oembed

Module oembed 

Source
Expand description

oEmbed 1.0 emitter (issue #586, port 4 of 5).

Port of the site’s Python-pipeline OembedPlugin: for every shareable (public, titled) page, emit an oEmbed 1.0 link-type document so consumers (chat unfurlers, editors, CMSs) can render rich previews without scraping the page.

§Files emitted

For a page at <site>/blog/post.html the plugin writes the sibling document <site>/blog/post.oembed.json:

{
  "version": "1.0",
  "type": "link",
  "title": "Post title",
  "provider_name": "<site_name>",
  "provider_url": "<base_url>",
  "author_name": "<frontmatter author, when present>"
}

During the fused transform pass each page whose oEmbed sibling exists also gains the standard discovery link in <head>:

<link rel="alternate" type="application/json+oembed"
      href="<base>/blog/post.oembed.json" title="Post title">

§Opt-in

Off by default, per the tracker. Following the same registration-gated convention as crate::search_index::VectorSearchPlugin, the plugin is not part of register_default_plugins — sites opt in by registering it explicitly:

use ssg::oembed::OembedPlugin;
use ssg::plugin::PluginManager;
let mut pm = PluginManager::new();
pm.register(OembedPlugin::default());

§Lifecycle & determinism

JSON documents are written in after_compile; the discovery <link> is injected via transform_html which the pipeline runs after after_compile (see run_fused_transforms), so the sibling-exists check is reliable. Output contains no timestamps and serde_json’s BTreeMap-backed maps serialise keys sorted — byte-identical across rebuilds.

Structs§

OembedPlugin
Plugin that emits per-page oEmbed 1.0 documents plus the discovery <link> tag.

Functions§

build_oembed
Builds one oEmbed 1.0 link-type document.