Skip to content

🧪 Experiment with remix style routing#726

Closed
just-be-dev wants to merge 2 commits into
mainfrom
experiment-remix-routes
Closed

🧪 Experiment with remix style routing#726
just-be-dev wants to merge 2 commits into
mainfrom
experiment-remix-routes

Conversation

@just-be-dev

@just-be-dev just-be-dev commented Mar 25, 2022

Copy link
Copy Markdown
Contributor

This is very rough so please ignore the awful, terrible, no-good things that I did to get it here, ha.

I'm using vite-plugin-remix-routes which itself actually just hooks into @remix-run/dev to do the bulk of the generation. So it's like very indirectly using parts of remix 😄. I made some updates to get stuff I needed so I've included a patch-package patch that's running the results of this PR: vjee/vite-plugin-remix-routes#2

The breadcrumb stuff won't be working with these changes for obvious reasons. I'd say we could hack it into the remix routes plugin, but I'm wondering if we should just try to figure out some more standard-ish way of doing it.

It took me a while to map how our config works to the folder/file structure needed. It's kind of weird, honestly. I mean the good news is that there's a method to the madness which means there is inherent structure. There's docs I could point folks to to get a better understanding of what's happening here, but I don't think it's very intuitive.

Going through this exercise was educational though and I feel like I have a better appreciation for the benefits/drawbacks of remix and certainly a deeper understanding for how vite plugins work, ha. If we don't end up going in this direction (and I'm not certain if we should) then I think this'll at least help us inform some of the page structure on the other side.

Something like this maybe:

pages/
├─ login.tsx
├─ orgs/
│  ├─ projects/
│  │  ├─ access.tsx
│  │  ├─ disks.tsx
│  │  ├─ disks.new.tsx
│  │  ├─ disks.[name].tsx
│  │  ├─ instances.tsx
│  │  ├─ instances.new.tsx
│  │  └─ instances.[name].tsx
│  ├─ projects.new.tsx
│  └─ projects.[name].tsx
└─ orgs.[name].tsx

Or the more basic

pages/
├─ login.tsx
├─ orgs/
│  ├─ projects/
│  │  ├─ disks/
│  │  │  ├─ [diskName].tsx
│  │  │  ├─ new.tsx
│  │  │  └─ index.tsx
│  │  ├─ instances/
│  │  │  ├─ [instanceName].tsx
│  │  │  ├─ new.tsx
│  │  │  └─ index.tsx
│  │  ├─ index.tsx
│  │  ├─ [projectName].tsx
│  │  └─ access.tsx
│  ├─ index.tsx
│  └─ [orgName].tsx

Anyway, feel free to poke around and hit me up if you have questions

@david-crespo

david-crespo commented Mar 25, 2022

Copy link
Copy Markdown
Collaborator

In Remix a route file can export a handle function that can return arbitrary metadata, which then shows up in the matches returned by useMatches(). They do a breadcrumbs example in the docs: https://remix.run/docs/en/v1/api/remix#usematches

We could maybe hack the plugin to do it similarly, but it doesn't seem worth the effort if we intend to eventually do in Remix anyway. Also worth waiting a few weeks to see what the data loading API looks like in RR, maybe there will be something more like this in there.

@just-be-dev

Copy link
Copy Markdown
Contributor Author

Oh, nice, yeah. Hopefully handle makes it into the new router config too, that'd be ideal. I'm going to close this b/c we obviously shouldn't merge it, but it's a nice reference if we ever want to revisit.

@david-crespo david-crespo deleted the experiment-remix-routes branch December 4, 2023 20:54
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.

2 participants