-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
|
Is there some documentation that should be added with this? Possibly in https://kit.svelte.dev/docs#ssr-and-javascript-prerender-route-conflicts ? |
I think we need some documentation about creating As for route conflicts caused by this PR are very edge case, as follows:
As users would not include extensions in routing directory, I don't think we need to warn users about this. |
@@ -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}/`; |
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 a sitemap.xml
from sitemap.xml.svelte
?
always
no longer feels like a good name for this since it's not always doing it
This 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 think
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.
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
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
why did this need to change? if you encounter about.html
why are you pushing 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.
Before this change, paths like **/about.html
are modified to **/about.html/index.html
so I changed not to do so.
What's ambiguous about it? I would think that it should create a file named |
.svelte.html
to html files
This comment has been minimized.
This comment has been minimized.
.svelte.html
to html files.html.svelte
to html files
@honai will you be able to take a look at the questions / comments on this PR? |
I'm sorry for the late response. I replied to your comments.
"ambiguous" was an inappropriate description.
The documentation already says that routes are collated alphabetically . I don't think any additional explanation is necessary. What do you think? |
I talked to Rich about this feature briefly. His suggestion was that we create an option for generating |
I'm going to go ahead and close this PR given the different approach that Rich suggested, but please feel free to send a PR with the updated approach and I'll take a look |
Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0#1443 by changing the prerendering behavior. If a route ends with
.html
, write it as a file name instead of creating a folder.Additional Info
I have to add
flush
option to glob to exactly check the dir structure.