Skip to content
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: routing: flat file system #5670

Closed
wants to merge 1 commit into from

Conversation

misa-lili
Copy link

@misa-lili misa-lili commented Jul 22, 2022

This feature enables routing based on flat-file-system.
Seperator is '--'.

origin: nested file system

/routes
    /pages
        /[pageId]
            /contents
                /[contentId]
                    index.svlete
                index.svelte
            index.svelte
        index.svelte

new feature: flat file system

/routes
    /pages.svelte
    /pages--[pageId].svelte
    /pages--[pageId]--contents.svelte
    /pages--[pageId]--contents--[contentId].svelte

or

/routes
    /pages
        index.svelte
        [pageId].svelte
        [pageId]--contents.svelte
        [pageId]--contents--[contentId].svelte

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Jul 22, 2022

⚠️ No Changeset found

Latest commit: bf84bbd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dummdidumm
Copy link
Member

Thanks, this is an interesting idea. However, we already have two ways of structuring the routes on the file system - you can either do someroute/index.svelte or someroute.svelte, both pointing to /someroute. I'm not sure I would want to introduce a third way to express the same.

@misa-lili
Copy link
Author

Thanks, this is an interesting idea. However, we already have two ways of structuring the routes on the file system - you can either do someroute/index.svelte or someroute.svelte, both pointing to /someroute. I'm not sure I would want to introduce a third way to express the same.

Thanks for your comment. Actually, the two existing methods are functionally enough.

But this is part of my project(nested file system). And I think this looks too complicated.
image

And here is flat file system. It seems much simpler and more intuitive.
image

And I have to do the following todos for this PR.

  • svelte.config.js: config.kit.files.flat?: boolean
  • svelte.config.js: config.kit.files.seperator?: string, default = '--'
  • bind seperator in parse_route_id with config.kit.files.seperator

@benmccann
Copy link
Member

I agree adding more ways is adding too much complication. Potentially we could enable this by exposing a routing API (sveltejs/rfcs#36), but I don't think we'd want to build a new specific syntax in.

I'm going to go ahead and close this. Next time you may want to open an issue to discuss a feature before beginning to implement it or discuss it on Discord

@benmccann benmccann closed this Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants