Sveltekit - Get All Routes/Pages

preview_player
Показать описание
In this video I will be discussing how to get all the routes or all the page in our Sveltekit app.

I'm not claiming this as the best way to do it but it is one of the ways. If you have a better way of doing this then please leave a comment

00:00 Introduction
01:18 Create some Sveltekit pages/routes
02:10 Import all the svelte files
03:26 Populate all the links
08:49 Create a load function
09:32 Create a menu list of all Sveltekit pages
Рекомендации по теме
Комментарии
Автор

This is cool. I think we would want to shorten the title to just the end of the path and capitalize the first letter, but that should be easy enough using String methods. However, I am struggling to conceptualize a way to order the menu so that it is not alphabetical. Hopefully Sveltekit will add this as a default feature eventually, and we won't have to worry about it. 🙂

bmehder
Автор

this is great! i really wish sveltekit should handle this similar to the way 11ty handles it w/ collections. it makes things so much easier

justinoneill
Автор

Well… the issue you pointed out was just closed a few days ago via PR # 4192. Now we just need to figure out how to use the new functionality I guess. 🤔

patricknelson
Автор

Excellent and useful, as always! :) An unrelated query: how to have different background colors on different pages? Is there a way to specify background color from within the page file without access to a body tag? Resetting the layout file to required bg color and then doing the same for <main> in the page seems clunky.

davemorgan
Автор

Awesome, please can you do a video on jwt authentication with sveltekit

thekokoserver
Автор

Very nice, but can we also pull out meta data like file name, created, updated? Also, does this work with the static adaptor?

SteveDavison
Автор

Is this still the preferred way to do it as of May 2023?

supbra