Skip to main content

serve_asset_references

Function serve_asset_references 

Source
pub fn serve_asset_references(
    content: &str,
    metadata: &mut BTreeMap<String, Value>,
    uploads: &AssetUploads,
) -> String
Expand description

Point a record’s asset references at where a hosted source serves them, and record what it uploaded: the one way a plugin that declares assets native and serves them at a URL finishes the record it is about to write.

content is rewritten by rewrite_asset_references over uploads, and metadata gains uploads under MetadataKey::ASSETS_KEY — or loses that key, when uploads is empty, so a record that holds no asset records nothing about assets. When metadata records a template rendering under MetadataKey::TEMPLATE_KEY whose body_digest is still the digest of content, that entry’s body_digest is re-recorded as the digest of the rewritten content and its template, digest and answers_digest are carried as they were — the rule a copy that rewrites references follows (README, “Creating and regenerating from a template”). Any other entry, a hand edit the rendering no longer vouches for included, is carried verbatim.