-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[feat] render routes ending with .html.svelte
to html files
#1939
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,7 @@ export async function prerender({ cwd, out, log, config, build_data, fallback, a | |
*/ | ||
function normalize(path) { | ||
if (config.kit.trailingSlash === 'always') { | ||
return path.endsWith('/') ? path : `${path}/`; | ||
return path.endsWith('/') || path.endsWith('.html') ? path : `${path}/`; | ||
} else if (config.kit.trailingSlash === 'never') { | ||
return !path.endsWith('/') || path === '/' ? path : path.slice(0, -1); | ||
} | ||
|
@@ -143,7 +143,7 @@ export async function prerender({ cwd, out, log, config, build_data, fallback, a | |
const is_html = response_type === REDIRECT || type === 'text/html'; | ||
|
||
const parts = path.split('/'); | ||
if (is_html && parts[parts.length - 1] !== 'index.html') { | ||
if (is_html && !parts[parts.length - 1].endsWith('.html')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did this need to change? if you encounter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before this change, paths like |
||
parts.push('index.html'); | ||
} | ||
|
||
|
@@ -172,7 +172,7 @@ export async function prerender({ cwd, out, log, config, build_data, fallback, a | |
const is_html = result.headers['content-type'] === 'text/html'; | ||
|
||
const parts = dependency_path.split('/'); | ||
if (is_html && parts[parts.length - 1] !== 'index.html') { | ||
if (is_html && !parts[parts.length - 1].endsWith('.html')) { | ||
parts.push('index.html'); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why just
.html
? What if the user wants to generate asitemap.xml
fromsitemap.xml.svelte
?always
no longer feels like a good name for this since it's not always doing itThis sort of feels like it should accept a function to let the user decide like #2008 and #2007. Then you could have it do whatever you want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Svelte files are designed to compose components made with HTML/CSS/JS so users won't generate files other than
.html
file, I think.But endpoints like
sitemap.xml.js
are considered, so I think this option should be changed, as you say.Can I change this option to something like
never | ignore | (path: string) => boolean
, in this PR? Or do you think it would be better to change it as a separate PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right that you'd use an endpoint
This probably shouldn't be a function after all. It gets stringified during build and could be confusing to users
I think a better logic here might be to do it only if the last path segment does not contain
.
, but let me ask the other maintainers what they thinkThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that might not be a great solution either. E.g. that wouldn't work with the URL https://bundlephobia.com/package/svelte@3.42.1
I think we just leave this as is and say you should not use the option
always
if you're generating.html
files