You can now view the source file for any blog post on my site by replacing the trailing slash with .txt in the URL. You can also replace the trailing slash with the original file extension of the source. Most of my blog posts are composed in Markdown, so the extention will usually be .md, but my setup also supports the occasional .ojs or .html post. But .txt will always work.
https://chromamine.com/2024/08/making-blog-post-source-files-available-with-11ty/
@harris hmm, so there's not really a way to the what the appropriate extension is, then? I mean, those three formats seem different enough that it's easy to just put .txt and guess from the contents, but...
@aburka Yeah, unfortunately not. I think it would be nice in the future to redirect from .txt to the correct extension and provide a link on-page to the source,—but both those ideas were out-of-scope for tonight
@harris anyway, thanks for bringing View Source back!
@harris this is neat. I wonder if you could use Content Negotiation to automatically serve the relevant file? https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation