The Creative Coding playground splits its dashboard logic across two small utility modules.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/hetari/creative-coding/llms.txt
Use this file to discover all available pages before exploring further.
src/utils/dashboard.ts exports buildDashboardItems(), which computes the list of cards to render for any dashboard path by walking the SKETCHES registry. src/utils/slug.ts exports slugToLabel() and stripSortPrefix(), which convert raw URL slugs — potentially carrying filesystem sort prefixes — into clean, human-readable display labels. Together these two modules handle all the dynamic layout and labelling logic without any hard-coded category lists.
buildDashboardItems()
buildDashboardItems() is the core engine of the dashboard. Given the full SKETCHES array and the path currently being viewed, it returns a sorted list of DashboardItem objects describing every card that should appear on screen.
Signature
The array of sketch metadata to build from. Defaults to the
SKETCHES constant exported from src/config/sketches.ts. In normal application code you will always pass SKETCHES explicitly, but the default makes the function convenient to call without arguments and easy to test with custom fixtures.The URL path of the dashboard currently being rendered, e.g.
'/', '/gsap', or '/gsap/footer'. Defaults to '/'. The function strips trailing slashes and uses the number of path segments to determine display depth, then returns only the immediate children at that depth.How It Works
The function computes the current nesting depth fromcurrentPath.split('/').filter(Boolean).length. It then iterates over every sketch in the array and checks whether the sketch’s path starts with the same segments as currentPath. For each matching sketch, the child segment at the current depth is extracted and grouped into an internal map.
A child entry is marked as a category (hasDeeper: true) if any sketch in the group has additional path segments beyond the immediate child slot, or as a leaf sketch if the sketch path ends exactly at depth + 1. The minimum order value found within each group becomes the sort key for that card, so folder cards rise to the position of their first sketch.
The resulting items are sorted ascending by order before being returned.
The DashboardItem Interface
| Field | Type | Description |
|---|---|---|
name | string | Raw name used as a key — either the sketch title or the raw path slug for categories. |
path | string | The full path this card links to. |
label | string | Human-readable display text shown on the card, derived from title or slugToLabel(). |
icon | string | '📁' for folder/category cards; '✦' for leaf sketch cards. |
isCategory | boolean | true when the card links to a nested dashboard; false for a sketch route. |
previewMode | 'image' | 'iframe' | Forwarded from SketchMeta.previewMode. Category cards always use 'image'. |
order | number | The sort key used to order cards within the current view. |
resources | string[] | Optional external reference links, forwarded from the leaf SketchMeta. |
Examples
The table below shows the output produced for each call against the current four-sketch registry:| Call | Returns |
|---|---|
buildDashboardItems(SKETCHES, '/') | 3 category cards: shader, images, gsap |
buildDashboardItems(SKETCHES, '/gsap') | 2 category cards: footer, loading |
buildDashboardItems(SKETCHES, '/gsap/footer') | 1 sketch card: Ascii Hand |
buildDashboardItems(SKETCHES, '/shader') | 1 sketch card: Learn |
Nested Path Support
The function supports arbitrary nesting depth. There is no hard-coded limit on the number of category levels. Depth is computed dynamically from the length of the path segment array, so adding a four-level-deep category like'gsap/animations/scroll/pin' requires no changes to buildDashboardItems() — it is handled automatically.
The function only ever returns immediate children of the current path. It never flattens or skips levels. Navigating deeper is always a separate call with the new path.
slugToLabel() and stripSortPrefix()
These two functions live in src/utils/slug.ts and handle the conversion from raw filesystem-style slugs to polished display labels.
Signatures
stripSortPrefix()
Removes a leading numeric sort prefix from a slug segment. The convention — digits followed by a hyphen at the start of a folder or file name — lets contributors control filesystem ordering without that prefix appearing anywhere in the UI.
/^\d+-/ — it matches one or more leading digits followed by a single -. A string that is only digits with no hyphen, or that starts with a letter, is returned unchanged.
slugToLabel()
Converts a URL path segment into a human-readable display label by composing three transformations:
- Strip sort prefix — delegates to
stripSortPrefix() - Replace separators — converts
-and_to spaces - Title-case — capitalises the first letter of every word
stripSortPrefix() returns it unchanged, and slugToLabel() proceeds directly to the separator-replacement and title-casing steps: