build.format / trailingSlash / Astro.url / Astro.props.url interactions all seem bolloxed #12833
Open
1 task done
Labels
needs triage
Issue needs to be triaged
Astro Info
If this issue only occurs in one browser, which browser is a problem?
(browser independent)
Describe the Bug
I am trying to figure out how source files and generated files and URLs interrelate with the various choices for
build.format
(directory
,file
, andpreserve
) andtrailingSlash
(always
,never
, andignore
) and nothing makes any sense.At the URL below I've made a simple exercise case that shows
Astro.url
andAstro.props.url
(and the corresponding.url
property of an imported page) for directory-index and non-directory index files, with a site base of/site_base/
(note trailing slash).Here's what I get:
Astro.url
devAstro.url
buildAstro.props.url
directory
always
directory
ignore
file
never
file
ignore
preserve
ignore
directory
always
directory
ignore
file
never
file
ignore
preserve
ignore
Some things don't make sense to me?
Astro.props.url
fromalways
toignore
drops the trailing slash fromAstro.props.url
but NOT fromAstro.url
?Astro.url
differs between dev and prod??/site_base/
and a generated file ofindex.html
,Astro.props.url
of /site_base.html seems completely wrong.Astro.url
usesanother_page/
instead ofanother_page.html
; meanwhileAstro.props.url
usesanother_page
(no trailing slash)!Astro.url
doesn't matchAstro.props.url
.Also, when using
file
output mode, the dev server has different behavior if you request.../another_file
vs.../another_file/
vs.../another_file.html
, which can't be right since in prod those would all be the same static file. (For the above examples, I always requested.../another_file.html
.)Finally, very strange things happen with
file
+always
ordirectory
+never
, but I'm ignoring that because those are arguably not very sensible combinations??What's the expected result?
A sane, consistent, and well documented approach to the necessary three way mapping between source file layout, output file layout, and assumed URL, without strange variations.
I'm sort of surprised I don't see more people having problems with this, maybe it's because I'm missing something major? Or I guess relatively few people access these metadata fields, people just hardcode URLs?
This is related to the question of how to construct links in Astro -- the docs just say to link to the URL, but to do that you need to know what the URL should be.
Potentially related:
Astro.url.pathname
includes trailing dash when building for SSG but not on dev mode #5630Link to Minimal Reproducible Example
https://github.com/egnor/astro_bug_report
Participation
The text was updated successfully, but these errors were encountered: