lumeland / lume

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

Relative URLs yielded from multi-page generates do not work as expected #324

Closed Protonull closed 1 year ago

Protonull commented 1 year ago

Version

1.13.1

Platform

Linux

What steps will reproduce the bug?

// file: /_config.ts
import lume from "https://deno.land/x/lume@v1.13.1/mod.ts";
export default lume();
// file: /example/[test].tmpl.ts
export default async function* () {
    yield {
        url: "./thing.html",
        content: "Hello, World!"
    };
}

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

Every time, no additional requirements or conditions.

What is the expected behavior?

You'd expect that a ./ url would be relative to the encapsulating file, which is how import works, thus you'd expect the resulting URL from the example to resolve to /example/thing.html, which also mirrors NextJS' dynamic routes:

Screenshot from 2022-11-23 20-51-04

What do you see instead?

Lume instead treats the multi-page generator as a folder; the resulting URL from the example is actually /example/[test]/thing.html, or, if you disable prettyUrls, /example/[test].html/thing.html. This means that ./ has a radically different meaning in different circumstances within the same file, such as:

// file: /example/[test].tmpl.ts

import { exampleUtility } from "./utils.ts"; // resolves to: /example/utils.ts

export default async function* () {
    yield {
        url: "./thing.html", // resolves to: /example/[test]/thing.html
        content: "Hello, World!"
    };
}

Additional information

No response

oscarotero commented 1 year ago

It make sense. I'll fix it, meanwhile you can use ../thing.html.