-- showcase-microdata Soupault Plugin -- SPDX-FileCopyrightText: 2026 toastal -- SPDX-License-Identifier: MPL-2.0 -- -- Applies Schema.org showcase markup on /real-world-showcase/ only. The -- page holds one section per peer (h2 with the peers-plugin Person span), -- each with a definition list of project → repository URL: -- article#Article → mainEntity ItemList -- dt + dd pair → wrapped in itemListElement SoftwareSourceCode -- dt → name -- dd link href → codeRepository -- per-item author → link to the h2 Person span, which gets an -- id so items can reference it Plugin.require_version("5.0.0") function url_path() local url = page_url url = Regex.replace(url, "^[a-z]+://[^/]+", "") if url == "" then url = "/" elseif not String.starts_with(url, "/") then url = "/" .. url end return url end function hidden_link(itemprop, href, parent) local elem = HTML.create_element("link") HTML.set_attribute(elem, "itemprop", itemprop) HTML.set_attribute(elem, "href", href) HTML.append_child(parent, elem) return elem end path = url_path() if path == "/real-world-showcase" or path == "/real-world-showcase/" then main = HTML.select_one(page, "main#Main") if not HTML.is_element(main) then Plugin.fail(format("No main#Main found in “%s”, skipping showcase markup", page_file)) end article = HTML.select_one(page, "article#Article") if not HTML.is_element(article) then Plugin.fail(format("No article#Article found in “%s”, cannot apply ItemList scope", page_file)) end HTML.set_attribute(article, "itemscope", "") HTML.set_attribute(article, "itemprop", "mainEntity") HTML.set_attribute(article, "itemtype", "https://schema.org/ItemList") h1 = HTML.select_one(main, "h1[itemprop=\"headline\"]") if not HTML.is_element(h1) then h1 = HTML.select_one(main, "h1") end if HTML.is_element(h1) then HTML.set_attribute(h1, "itemprop", "name") headline = HTML.create_element("meta") HTML.set_attribute(headline, "itemprop", "headline") HTML.set_attribute(headline, "content", String.trim(HTML.strip_tags(h1))) HTML.prepend_child(main, headline) else Log.warning(format("No h1 found in “%s”, skipping WebPage.headline compensation", page_file)) end sections = HTML.select(article, "section#Content > section") if Table.is_empty(sections) then Log.warning(format("No showcase peer sections found in “%s”", page_file)) end local idx = 1 while sections[idx] do local section = sections[idx] local peer = HTML.select_one(section, "h2 span.peer") if not HTML.is_element(peer) then Log.warning("Showcase section without peer, skipping its projects") else local peer_name = String.trim(HTML.strip_tags(peer)) local peer_id = "showcase-peer-" .. peer_name HTML.set_attribute(peer, "id", peer_id) local dts = HTML.select(section, "dl dt") local dds = HTML.select(section, "dl dd") if Table.is_empty(dts) then Log.warning(format("Showcase peer “%s” without projects", peer_name)) end local jdx = 1 while dts[jdx] do local dt = dts[jdx] local dd = dds[jdx] local project = HTML.create_element("div") HTML.insert_before(dt, project) HTML.append_child(project, dt) HTML.set_attribute(dt, "itemprop", "name") if HTML.is_element(dd) then HTML.append_child(project, dd) local link = HTML.select_one(dd, "a[href]") if HTML.is_element(link) then hidden_link("codeRepository", HTML.get_attribute(link, "href"), project) else Log.warning("Showcase project without repository link, skipping codeRepository") end else Log.warning("Showcase project without details, scoping name only") end HTML.set_attribute(project, "itemscope", "") HTML.set_attribute(project, "itemprop", "itemListElement") HTML.set_attribute(project, "itemtype", "https://schema.org/SoftwareSourceCode") hidden_link("author", "#" .. peer_id, project) jdx = jdx + 1 end end idx = idx + 1 end end