You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I created a absoluteurl filter that converts a relative URL or an absolute path to an absolute URL. I would like it to behave like Jekyll's absolute_url filter. It prepends a baseurl value to the input.
The filter should do the following:
{{ "/about.html" | absoluteurl }} would produce "https://localhost:8080/about.html" in dev. Whatever is the default of the local server.
{{ "/about.html" | absoluteurl }} would produce "https://www.roboleary.net/about.html" in production when I provide a value of https://www.roboleary.net to baseurl.
Since I cannot obtain the server host name and port, I am unable to do this for dev mode. Instead I return the input url.
Describe the solution you'd like
Access the serverOptions object with details about server.
Describe alternatives you've considered
I tried to use eleventyConfig.getMergingConfigObject().serverOptions in the eleventy config file, however it is empty. I guess that this could be because the server is not initiated yet. Is this a timing issue?
Additional context
This is the current implementation:
functionabsoluteUrl(url,baseUrl,production=true){if(baseUrl===undefined||baseUrl===null){thrownewError(`absoluteUrl - The baseUrl parameter is missing.`);}letabsUrl=url;if(production){try{absUrl=newURL(url,baseUrl).toString();}catch(e){debug("Trying to convert %o to be an absolute url with baseUrl %o and failed, returning: %o (invalid url)",url,baseUrl,url);}}returnabsUrl;}
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I created a
absoluteurl
filter that converts a relative URL or an absolute path to an absolute URL. I would like it to behave like Jekyll'sabsolute_url
filter. It prepends abaseurl
value to the input.The filter should do the following:
{{ "/about.html" | absoluteurl }}
would produce "https://localhost:8080/about.html" in dev. Whatever is the default of the local server.{{ "/about.html" | absoluteurl }}
would produce "https://www.roboleary.net/about.html" in production when I provide a value ofhttps://www.roboleary.net
tobaseurl
.Since I cannot obtain the server host name and port, I am unable to do this for dev mode. Instead I return the input
url
.Describe the solution you'd like
Access the
serverOptions
object with details about server.Describe alternatives you've considered
I tried to use
eleventyConfig.getMergingConfigObject().serverOptions
in the eleventy config file, however it is empty. I guess that this could be because the server is not initiated yet. Is this a timing issue?Additional context
This is the current implementation:
The text was updated successfully, but these errors were encountered: