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 }} {{ printf "<atom:link href=%q rel=\"self\" type=%q />" (.Permalink | absURL) .MediaType | safeHTML }}
{{- end -}} {{- end -}}
{{ printf "<atom:link href=%q rel=\"search\" type=\"application/opensearchdescription+xml\" />" ("/opensearch.xml" | absURL) | safeHTML }} {{ 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 -}} {{- if $page.Params.inReplyTo -}}{{ continue }}{{- end -}}
<item> <item>{{ with .Title }}
<title>{{ .Title | default (delimit (slice "An untitled" (.Date.Format "January") (.Type | singularize)) " ") }}</title> <title>{{ . }}</title>{{ else }}<title></title>{{ end }}
<link>{{ .Permalink | absURL }}</link> <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}} {{ 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> <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>

View file

@ -34,6 +34,9 @@
.item { .item {
max-width: 768px; max-width: 768px;
} }
p {
position: relative;
}
a { a {
color: #4166f5; color: #4166f5;
text-decoration: none; text-decoration: none;
@ -44,6 +47,19 @@
a:hover { a:hover {
text-decoration: underline; 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> </style>
</head> </head>
<body> <body>
@ -68,23 +84,39 @@
<h2>Recent Posts</h2> <h2>Recent Posts</h2>
<xsl:for-each select="/rss/channel/item"> <xsl:for-each select="/rss/channel/item">
<article> <article>
<hgroup> <xsl:if test="title != ''">
<h3> <hgroup>
<a hreflang="en" target="_blank"> <h3>
<xsl:attribute name="href"> <a hreflang="en" target="_blank">
<xsl:value-of select="link"/> <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:attribute>
<xsl:value-of select="title"/> <xsl:value-of select="substring(pubDate, 0, 17)" />
</a> </time>
</h3> </hgroup>
<time> </xsl:if>
<xsl:attribute name="datetime">
<xsl:value-of select="pubDate" />
</xsl:attribute>
<xsl:value-of select="substring(pubDate, 0, 17)" />
</time>
</hgroup>
<p><xsl:value-of select="description"/></p> <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> </article>
</xsl:for-each> </xsl:for-each>
</main> </main>