-
|
Hello again, is there a way to get the eleventy site's "path prefix" inside the For example an eleventy site might be at Normally in our templates we'd use the What I'm doing is creating a custom shortcode, and in that shortcode's output, I want the site's path prefix ready to use, so it's the equivalent of doing the Contrived example: I hope I explained that well. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Which is fine, I can wait for Eleventy 2.0. But for now:
How can I get a hold of this pathPrefix inside a shortcode or other custom code? |
Beta Was this translation helpful? Give feedback.
-
|
Found an issue, looks like it's not possible directly. There will be a feature in eleventy 2.0 which uses HTML Issue: #1641 The workaround is I could define the pathPrefix at the top of the file and then use it in the return object and the shortcode. |
Beta Was this translation helpful? Give feedback.
-
|
Does this work? const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addShortcode("blah", () => {
let htmlBaseUrlFilter = eleventyConfig.getFilter("htmlBaseUrl");
return `<a href="${htmlBaseUrlFilter(theLink)}">test</a>`
});
}; |
Beta Was this translation helpful? Give feedback.
Does this work?