For a podcast episode or narrated article, embed an AudioObject in the
article's audio property.
article = %SchemaOrg.Article{
headline: "Listen: the schema_org story",
author: %SchemaOrg.Person{name: "Mike Kostov"},
audio: %SchemaOrg.AudioObject{
name: "The schema_org story",
content_url: "https://example.com/audio.mp3",
encoding_format: "audio/mpeg",
duration: "PT22M"
}
}
SchemaOrg.to_json_ld(article)produces:
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "Listen: the schema_org story",
"author": { "@type": "Person", "name": "Mike Kostov" },
"audio": {
"@type": "AudioObject",
"name": "The schema_org story",
"contentUrl": "https://example.com/audio.mp3",
"encodingFormat": "audio/mpeg",
"duration": "PT22M"
}
}encoding_format is the MIME type of the file. For full podcast feeds, see
Schema.org's PodcastEpisode and
PodcastSeries — both are generated types.
Embed it in a page
SchemaOrg.to_script_tag(article) # HTML-safe <script type="application/ld+json"> stringIn a Phoenix HEEx template (needs :phoenix_live_view):
<SchemaOrg.HTML.json_ld data={@article} />