Builds and parses the site's page paths, by the one rule they all follow: the path is a hierarchy, @name is a user (@name@host one whose account lives on another instance), and any other word under the root is a dump category or an app page, /playlists holding the playlist categories. Under a user each segment is a fixed tab name, and under dumps or playlists a slug. A view of a page is one more segment, and a default view is the bare path. A category narrowing a list on another page, a profile's or a search's, is a query, ?category=, not a segment, and so is the order of a list of playlists, ?sort=, the default order being the bare path, and the playlists page's list of the viewer's own, ?mine=1.

The client links every page through the builders (src/utils/shared/urls.ts wraps the dump and playlist ones), the emails prefix them with the frontend's URL, and the server's matchers (the Open Graph tags, the previews and backlinks of links to this site) read paths with parsePagePath. Migration 0021 rewrote the v3 links in stored text with the builders.

Functions

f
categoryPath(
kind: CategoryKind,
slug: string
): string

Returns the path of the page of the category of kind at slug: a dump category's feed (feedPath), or a playlist category's playlists (playlistsPath). The category chips link to it.

f
communityPath(view?: DigestCadence): string

Returns the path of the community page on view, the week by default.

f
dumpPath(
dump: OwnedItem,
view?: "edit"
): string

Returns the path of a dump's page, /@owner/dumps/<slug>, or of its editor, one segment more.

f
feedPath(
categorySlug?: string,
tab?: FeedTab,
view?: FollowView
): string

Returns the path of a feed: every dump's at the root, or a category's at /<slug>, on tab, or on the viewer's default tab without one. The follow tab takes a view, the users followed by default.

f
parsePagePath(pathname: string): PagePath | null

Returns what a page path under a user names: a profile (with its tab), a dump or a playlist (or its editor). It returns null for any other path, a feed or an app page, and for one under a user that no page answers. The names are decoded but not looked up, so the user or the item may not exist.

f
parsePlaylistsTab(params: URLSearchParams): PlaylistsTab

Returns the tab of the playlists page its query names: the viewer's own playlists with a mine, else the order sort names, as parsePlaylistSort reads it.

f
playlistPath(
playlist: OwnedItem,
view?: "edit"
): string

Returns the path of a playlist's page, /@owner/playlists/<slug>, or of the page with its editor open, one segment more.

f
playlistSortQuery(
sort?: PlaylistSort,
extra?: URLSearchParams
): string

Returns the query string that puts a list of playlists in the order sort names, with its ?, or "" for the default order. extra holds the list's other parameters, such as a profile's category.

f
playlistsPath(
categorySlug?: string,
tab?: PlaylistsTab
): string

Returns the path of the page of every public playlist, /playlists, or of a playlist category's at /playlists/<slug>, on the tab tab names: an order, the default one without it, or the viewer's own playlists.

f
searchPath(
tab?: SearchTab,
query?: string
): string

Returns the path of the search page on tab, searching query when it is given.

f
userPath(
username: string,
tab?: ProfileTab,
view?: FollowView
): string

Returns the path of username's profile, of one of its tabs, or of a view of the follow tab. The default view, users, is the bare tab.

Interfaces

Type Aliases

Variables

v
COMMUNITY_VIEWS: readonly DigestCadence[]

The views of the community page, one per digest cadence: the week at /community, the month at /community/monthly.

v
FEED_TABS: "hot" | "new" | "journal" | "follow"[]

The feed tabs, in the tab bar's order. Each is a path segment: /hot for every dump, /music/hot for a category. They are reserved at the root, so no category can take one.

v
FOLLOW_VIEWS: "users" | "playlists"[]

The views of a follow tab, of what is followed: the users, at the bare tab, or the playlists. A profile's lists them, /@name/follow and /@name/follow/playlists, and a feed's shows their dumps, /follow and /follow/playlists.

v
PLAYLISTS_TABS: any[]

The tabs of the playlists page, in the tab bar's order: each order of every public playlist, ?sort=, then the viewer's own playlists, ?mine=1, which only a signed-in user is offered.

v
PROFILE_TABS:
"dumps"
| "upvoted"
| "playlists"
| "follow"
| "invitees"
| "manage"
[]

The tabs of a profile, each a segment after /@name. The bare /@name is the overview.

v
SEARCH_TABS: "dumps" | "users" | "playlists"[]

The tabs of the search page: the dumps at /search, the others at /search/<tab>.