tdemin / gmnhg

Hugo-to-Gemini Markdown converter
GNU General Public License v3.0
29 stars 1 forks source link

Add RSS support for #26 #27

Closed mntn-xyz closed 3 years ago

mntn-xyz commented 3 years ago

This relies on the site config to provide a custom GeminiBaseURL setting, as well as the site title, copyright, and language. Hopefully this could be useful elsewhere. I have only tested it with a TOML config so far but the others should work. I have also only tested with the default RSS template, I haven't tried to override it yet... so there may be bugs in that feature.

I decided that adding a "GeminiBaseURL" config option is probably the only solution besides a command line switch or extra config file. I've noticed that lots of people run their Gemini site on a separate subdomain from their main site.

Note: I made a change to topLevelPosts, and added an empty string key that holds everything. This gives both the RSS feed and the main index a way to easily access all posts. I had to update the main index template to avoid a change in behavior, but this was helpful for keeping the RSS generation code relatively clean.

mntn-xyz commented 3 years ago

Still haven't done extensive testing, definitely need to test a few things before this is 100% ready... but it's closer now

mntn-xyz commented 3 years ago

OK, I think this is ready. Tested with TOML/YAML/JSON configs and a fairly complex site layout.

Some notes:

tdemin commented 3 years ago

@mntn-xyz are you sure stripping index.gmi in general is a good idea? I am specifically thinking about naive static servers which don't redirect to index.gmi, dropping code 51 (not found) instead.

I don't know of any Gemini server feature comparison tables, unfortunately, neither can I tell the numbers and/or stats on server software people pick. I know Molly Brown will serve index.gmi if it encounters a request to a directory, but more simplistic servers like Satellite (which is what I currently use myself) won't.

mntn-xyz commented 3 years ago

You're right, I'll roll that back. Hugo has the uglyURLs option, I could use uglyGeminiURLs... but it's not too hard for users who want clean URLs to roll their own templates.

mntn-xyz commented 3 years ago

OK, rolled it back and also added documentation.

mntn-xyz commented 3 years ago

Wanted to add one more thing, let me know what you think. If you drop rss.gotmpl in /gmnhg, it will override RSS for the root dir. If you drop it in /gmnhg/_default, it will override it for the whole site.

The convention I am using for overriding specific subdirectories is the same as for regular templates, but you append _rss to the name, like /gmnhg/top/blog_rss.gotmpl.

tdemin commented 3 years ago

LGTM