Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with global path prefix? #5

Open
mbforbes opened this issue Feb 23, 2022 · 2 comments
Open

Usage with global path prefix? #5

mbforbes opened this issue Feb 23, 2022 · 2 comments
Labels
help welcome 🙏 Extra attention is needed type: enhancement 🧗‍♂️ New feature or request

Comments

@mbforbes
Copy link

Hi there,

Thank you for writing this plugin!

I'm not sure whether there's a natural way for it to play nicely with eleventy's global path prefix.

The path prefix mechanism prepends something to all URLs in case your website doesn't start at /. E.g., building with eleventy --pathprefix 'website-3' would produce URLs that start with /website-3/.

When I build with a --pathprefix, then link_to still produces URLs without the prefix.

I thought to pipe them through eleventy's filter for adding path prefixes, url, like so:

{% link_to "/posts/paralysis/" | url %}

This produces the correct URL, but I get an error in the build log that link_to is looking for the new path, and couldn't find it:

[link_to] Couldn't find any content with slug '/website-3/posts/paralysis/'

I'm not sure whether there is a workaround, or whether the plugin would require changes to support the path prefix?

Many thanks for your time!

@nhoizey nhoizey added help welcome 🙏 Extra attention is needed type: enhancement 🧗‍♂️ New feature or request labels Mar 8, 2022
@nhoizey
Copy link
Owner

nhoizey commented Mar 8, 2022

Hi @mbforbes, that's a good issue to solve indeed! 👍

I wonder if there's a way to get the pass prefix in the plugin code. Would you have an idea about that?

@mbforbes
Copy link
Author

mbforbes commented Mar 8, 2022

Thank you for the reply, @nhoizey! 🙏

That's a great question. Haven't touched plugin code so I hadn't even considered that it might be awkward to plumb through, but looking now I see the plugin doesn't refer to anything eleventy! From the docs it looks like this is a top-level config option, so we'd need access to the eleventy config object somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help welcome 🙏 Extra attention is needed type: enhancement 🧗‍♂️ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants