lumeland / lume

πŸ”₯ Static site generator for Deno πŸ¦•
https://lume.land
MIT License
1.86k stars 85 forks source link

Unable to set absolute path for includes #307

Closed ggodlewski closed 1 year ago

ggodlewski commented 1 year ago

Version

1.12.1

Platform

Linux

What steps will reproduce the bug?

I want to keep includes outside of content directory using absolute path. My config is following:

import * as path from "https://deno.land/std@0.57.0/path/mod.ts";
import lume from "lume/mod.ts";
import prism from "lume/plugins/prism.ts";
import postcss from "lume/plugins/postcss.ts";
import metas from "lume/plugins/metas.ts";

const __dirname = path.dirname(path.fromFileUrl(import.meta.url));

const site = lume({
    includes: path.join(__dirname, "theme"),
    src: "./content",
    dest: "./build",
});

site.use(prism());
site.use(postcss());
site.use(metas());

export default site;

I'm getting error:

Caused by Error: Couldn't load this file
- fullPath: /home/gg/workspaces/lumetest/content/home/gg/workspaces/lumetest/theme/layout.njk

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

Always

What is the expected behavior?

Do not concatenate includes path with content path if it starts with /

What do you see instead?

I want to be able to set any path in my filesystem for the includes/theme

Additional information

No response

oscarotero commented 1 year ago

This is not a bug but the expected behavior. Everything in Lume must reside in the src folder. If you want to load files from different places, you can configure remote files. For example:

site.remoteFile("_includes/layout.njk", import.meta.resolve("./theme/layout.njk"));

More info here: https://lume.land/docs/core/remote-files/

shuaixr commented 1 year ago

@oscarotero I really hope lume can have more freedom in path configuration. I can't use a structure like this in lume:

β”œβ”€β”€ _config.ts
β”œβ”€β”€ deno.json
└── src
    β”œβ”€β”€ layouts
    β”‚   β”œβ”€β”€ base.njk
    β”‚   └── index.njk
    └── pages
        └── index.md
oscarotero commented 1 year ago

@shuaixr What's the problem with this structure? You can configure Lume to use the src folder.