Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print full post content in RSS description #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/gmnhg/templates.go
Expand Up @@ -79,7 +79,7 @@ var defaultRssTemplate = mustParseTmpl("rss", `{{- $Site := .Site -}}
<link>{{ $AbsURL }}</link>
<pubDate>{{ $p.Metadata.Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</pubDate>
<guid>{{ $AbsURL }}</guid>
<description>{{ html $p.Metadata.Summary }}</description>
<description>{{ printf "%s" $p.Post }}</description>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default Hugo uses the post's "summary" front matter if it exists (that's what is loaded into Metadata.Summary), then it falls back to an auto-generated summary. It should be fine to put in the full post data since people can override the defaults, but I wanted to mention that here.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the difference between us and Hugo is that Hugo autogenerates a summary unlike us.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. I write my own summaries and put it into the front matter (I don't particularly like Hugo's autogenerated summaries), but as long as Metadata.Summary remains available, I can make a custom template that uses the summary data. Or who knows, maybe I should use the default and put the whole post content into RSS.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing I never thought of: since RSS is XML, raw post content which might contain XML has to be escaped.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, yep, gemtext may contain XML content. Passing it through the escaper should be enough.

</item>
{{end}}{{end}}
</channel>
Expand Down