Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Absolute path #39

Open
ButterSus opened this issue Jun 4, 2023 · 1 comment
Open

Absolute path #39

ButterSus opened this issue Jun 4, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ButterSus
Copy link

This preprocessor is great, but using a relative path every time you insert a component is very inconvenient.

It would be better to use absolute path from source directory like this:

{{ #template /absolute-path/to-directory/for-some-file.md  }}

If it's hard to implement absolute path, we can just pass directory in book.toml like this:

[preprocessor.template]
absolute-directory = "~/path-to-directory/..."
@sgoudham
Copy link
Owner

sgoudham commented Jun 7, 2023

Hi 👋

Thanks for submitting an issue and thank you for the kind words! Unfortunately I haven't really had the motivation to continue working on this as I personally switched away from using mdbook. I'd be super grateful if you would like to submit a PR for this type of behaviour as I definitely agree!

One possible implementation would be to detect any path starting with a / as an absolute path but I'm not exactly a fan given how easily you might just type in a / at the beginning of the path.

Another possible approach, as you've mentioned in the issue, is defining it in the TOML and this also sounds like a valid approach! You could definitely keep those absolute paths in memory and see if those keys pop-up inside the substitutions.

I might get around to updating this at some point in the future but I'd be lying if I said I'll definitely work on it. Sorry!

@sgoudham sgoudham added help wanted Extra attention is needed good first issue Good for newcomers enhancement New feature or request labels Jun 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants