lumeland / lume

🔥 Static site generator for Deno 🦕
https://lume.land
MIT License
1.83k stars 83 forks source link

Unable to use lume option, `prettUrl: false` with meta and sitemap plugins #370

Closed dnk8n closed 1 year ago

dnk8n commented 1 year ago

Version

v1.29.4

Platform

x64 linux

What steps will reproduce the bug?

Unfortunately because my main site is hosted with Deno Fresh (Deno Deploy), my urls come out ugly - https://rethinkcode-z0rjctkawcv0.deno.dev/articles/advanced-transitional-support/index.html

I at least want to allow the sitemap to point to the ugly urls, but can't find a way to do that.

Unless there is a setting I can change in Fresh / Deno Deploy to host static html in a pretty way?

e.g. https://rethinkcode-z0rjctkawcv0.deno.dev/articles/advanced-transitional-support/index.html -> https://rethinkcode-z0rjctkawcv0.deno.dev/articles/advanced-transitional-support

How often does it reproduce? Is there a required condition?

Hosting content produced by Lume by a third party hosting platform

What is the expected behavior?

Be able to reconcile the urls of sitemap, with the actual live behavior by setting prettyUrls: false in lume options

What do you see instead?

sitemap.xml shows https://rethinkcode-z0rjctkawcv0.deno.dev/articles/advanced-transitional-support/ while the page is actually accessible at https://rethinkcode-z0rjctkawcv0.deno.dev/articles/advanced-transitional-support/index.html

Additional information

No response

oscarotero commented 1 year ago

Lume has a Server class to serve static files. But I don't know if it can be combined with Fresh (I guess don't)

If you disable the prettyUrls option in your _config.ts file, the output url will be https://rethinkcode.org/articles/advanced-transitional-support.html, that should work in all environments.

oscarotero commented 1 year ago

Ok, I just saw this: https://github.com/dnk8n/rethinkcode/blob/main/_src/pages.tmpl.js#L36

Pretty URLs option is applied only to generate the URLs of pages that already don't have the url variable defined. If you define the urls of a page as /articles/advanced-transitional-support/ (note the trailing slash), the output file will always contain the /index.html at the end.

More info: https://lume.land/docs/creating-pages/urls/#the-url-variable

You can simply change your code to /articles/${article.slug}.html.

dnk8n commented 1 year ago

I actually worked that out myself just now, and your comments confirm the behavior I observe. Everything now working in latest deploy - rethinkcode-cfx1aavvndyg.deno.dev