From: Lady Date: Tue, 9 Aug 2022 01:04:45 +0000 (-0700) Subject: Support subtitle X-Git-Tag: 0.1.0~2 X-Git-Url: https://git.ladys.computer/Beorn/commitdiff_plain/995e9a7974e310cf77fae5db1669ee428eb47845?ds=sidebyside Support subtitle --- diff --git a/README.markdown b/README.markdown index 2207d3a..a0f3043 100644 --- a/README.markdown +++ b/README.markdown @@ -113,6 +113,7 @@ file extension. A sample `.rsync-filter` might be as follows :— -s .gitignore -s /README* -s /build.js +-s /deno.json -s index#*.xhtml -s #*.rdf ``` diff --git a/build.js b/build.js index 3695329..785b86f 100755 --- a/build.js +++ b/build.js @@ -54,6 +54,7 @@ const AWOL = "http://bblfish.net/work/atom-owl/2006-06-06/"; const DC11 = "http://purl.org/dc/elements/1.1/"; const FOAF = "http://xmlns.com/foaf/0.1/"; const RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; +const RDFS = "http://www.w3.org/2000/01/rdf-schema#"; const SIOC = "http://rdfs.org/sioc/ns#"; const XML = "http://www.w3.org/XML/1998/namespace"; const XHTML = "http://www.w3.org/1999/xhtml"; @@ -523,7 +524,7 @@ const context = { }, rights: { namespace: DC11, localName: "rights", type: "text" }, // source is not supported at this time - // subtitle is not supported at this time + subtitle: { namespace: RDFS, localName: "label", type: "text" }, summary: { namespace: DC11, localName: "abstract", type: "text" }, title: { namespace: DC11, localName: "title", type: "text" }, // updated is provided by the build script @@ -571,6 +572,7 @@ const fillOutHead = (document, metadata, type) => { const { title, author, + subtitle, summary, } = metadata; titleElement.textContent = Object(title) instanceof String @@ -610,6 +612,20 @@ const fillOutHead = (document, metadata, type) => { .href("../../feed.atom")``, ); } else { + // The provided document is not an entry document. + if (subtitle) { + // The entry has a subtitle. + head.appendChild( + LMN.meta({ + name: "description", + content: Object(subtitle) instanceof String + ? summary + : Array.from(subtitle).map(($) => $.textContent).join(""), + })``, + ); + } else { + /* do nothing */ + } head.appendChild( LMN.link .rel("alternate") @@ -1007,6 +1023,7 @@ await (async () => { // this is the run script const { id, title, + subtitle, rights, updated, } = feedMetadata; @@ -1016,6 +1033,7 @@ await (async () => { // this is the run script "bjørn-content", ).item(0); if (contentPlaceholder != null) { + // There is a content placeholder. const { parentNode: contentParent } = contentPlaceholder; const contentElement = contentParent.insertBefore( LMN.nav.about(`${id}`)`${"\n"}`, @@ -1029,6 +1047,17 @@ await (async () => { // this is the run script title, ); addContent(contentHeader, "\n"); + if (subtitle) { + // The feed has a subtitle. + addContent( + contentHeader.appendChild(LMN.p.property(`${RDFS}label`)``), + subtitle, + ); + addContent(contentHeader, "\n"); + } else { + // The feed has no subtitle. + /* do nothing */ + } addContent(contentElement, "\n"); const entriesElement = contentElement.appendChild( LMN.ul.rel(`${AWOL}entry`)`${"\n"}`, @@ -1039,6 +1068,7 @@ await (async () => { // this is the run script LMN.footer`${"\n\t"}`, ); if (rights) { + // The feed has a rights statement. addContent( contentFooter.appendChild( LMN.div.property(`${DC11}rights`)``, @@ -1046,6 +1076,9 @@ await (async () => { // this is the run script rights, ); addContent(contentFooter, "\n\t"); + } else { + // The feed has no rights statement. + /* do nothing */ } contentFooter.appendChild( LMN.p.id("entry.updated")`Last updated: ${LMN.time.property(