RSS feed items with no title

Removes the title for items that have none & fixes the XSL to make more sense for those items.
This commit is contained in:
JP Hastings-Spital 2025-01-31 17:40:08 +00:00
parent e9d7dbfbdc
commit 6198c735aa
2 changed files with 50 additions and 18 deletions

View file

@ -25,10 +25,10 @@
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" (.Permalink | absURL) .MediaType | safeHTML }}
{{- end -}}
{{ printf "<atom:link href=%q rel=\"search\" type=\"application/opensearchdescription+xml\" />" ("/opensearch.xml" | absURL) | safeHTML }}
{{- range $i, $page := (first 42 $pages) -}}
{{- range $i, $page := $pages -}}
{{- if $page.Params.inReplyTo -}}{{ continue }}{{- end -}}
<item>
<title>{{ .Title | default (delimit (slice "An untitled" (.Date.Format "January") (.Type | singularize)) " ") }}</title>
<item>{{ with .Title }}
<title>{{ . }}</title>{{ else }}<title></title>{{ end }}
<link>{{ .Permalink | absURL }}</link>
{{ if .Page.Params.Audio }}<enclosure url="{{ .Permalink | absURL }}{{ .Page.Params.Audio }}" length="{{ (os.Stat (path.Join .File.Dir .Page.Params.Audio)).Size }}" type="audio/mpeg" />{{end}}
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>

View file

@ -34,6 +34,9 @@
.item {
max-width: 768px;
}
p {
position: relative;
}
a {
color: #4166f5;
text-decoration: none;
@ -44,6 +47,19 @@
a:hover {
text-decoration: underline;
}
a:has(time) {
display: block;
text-align: right;
}
article:not(:first-of-type):not(:has(hgroup)) p::before {
content: '';
display: block;
position: absolute;
top: -1.4em;
left: calc(50% - 1.5em);
width: 3em;
border-top: 1px solid rgba(128,128,128,0.5);
}
</style>
</head>
<body>
@ -68,23 +84,39 @@
<h2>Recent Posts</h2>
<xsl:for-each select="/rss/channel/item">
<article>
<hgroup>
<h3>
<a hreflang="en" target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="link"/>
<xsl:if test="title != ''">
<hgroup>
<h3>
<a hreflang="en" target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>
<xsl:value-of select="title"/>
</a>
</h3>
<time>
<xsl:attribute name="datetime">
<xsl:value-of select="pubDate" />
</xsl:attribute>
<xsl:value-of select="title"/>
</a>
</h3>
<time>
<xsl:attribute name="datetime">
<xsl:value-of select="pubDate" />
</xsl:attribute>
<xsl:value-of select="substring(pubDate, 0, 17)" />
</time>
</hgroup>
<xsl:value-of select="substring(pubDate, 0, 17)" />
</time>
</hgroup>
</xsl:if>
<p><xsl:value-of select="description"/></p>
<xsl:if test="title = ''">
<a hreflang="en" target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>
<time>
<xsl:attribute name="datetime">
<xsl:value-of select="pubDate" />
</xsl:attribute>
<xsl:value-of select="substring(pubDate, 0, 17)" />
</time>
</a>
</xsl:if>
</article>
</xsl:for-each>
</main>