blog_post_id.ts

The post id type, its grammar, and its SvelteKit param matcher, kept free of runtime imports because SvelteKit loads param matchers eagerly on the client and imports src/params.ts with plain Node at build time, outside Vite - so no $app/* or other Vite-resolved imports here, and only type imports, which are erased.

view source

Declarations
#

4 declarations

blog_post_id_param
#

blog_post_id.ts view source

(param: string): string | undefined import {blog_post_id_param} from '@fuzdev/fuz_blog/blog_post_id.js';

The SvelteKit param matcher for the generated [post=blog_post_id] redirect route. Register it under the blog_post_id name in the app's src/params.ts, e.g. export const params = defineParams({blog_post_id: blog_post_id_param});. Without it, the route would match every /<dirname>/<segment> path, so client-side navigation to a static file under the blog path would hit the redirect.

param

type string

returns

string | undefined

BLOG_POST_ID_SOURCE
#

blog_post_id.ts view source

"[1-9]\\d*" import {BLOG_POST_ID_SOURCE} from '@fuzdev/fuz_blog/blog_post_id.js';

Regex source for a post id: a positive integer without leading zeros. Shared by the post directory name pattern and the param matcher so they can't drift.

BlogPostId
#

blog_post_id.ts view source

BlogPostId

type number & Flavor<"BlogPostId">

import type {BlogPostId} from '@fuzdev/fuz_blog/blog_post_id.js';

A post's positive integer id, the first part of its <id>-<slug> directory name. Ids are unique within a blog and may have gaps.

external types

Flavored<number, 'BlogPostId'>

is_blog_post_id_param
#

blog_post_id.ts view source

(param: string): boolean import {is_blog_post_id_param} from '@fuzdev/fuz_blog/blog_post_id.js';

Checks if param is a bare post id like 1, within the safe integer range so it round-trips through Number.

param

type string

returns

boolean

Imported by
#