blog_post_redirect.ts

Helpers for the [post=blog_post_id] route gro gen writes in each blog with posts, which redirects a bare post id like /blog/1 to the post's canonical /blog/1-my-post. The id path is each feed entry's stable id, so it keeps resolving when a post's slug changes.

view source

Declarations
#

3 declarations

blog_post_redirect
#

blog_post_redirect.ts view source

(feed: { atom: { feed_url: string; }; items: { tags: string[]; title: string; date_published: string; date_modified: string; summary: string; id: string; url: string; pathname: string; blog_post_id: number; slug: string; }[]; ... 6 more ...; author: { ...; }; }, param: string): never import {blog_post_redirect} from '@fuzdev/fuz_blog/blog_post_redirect.js';

The load of the generated [post=blog_post_id] route: redirects a bare post id to the post's canonical path, or 404s. Prerendering writes the redirect as a page with a meta refresh.

feed

the blog's generated feed

param

the post route param

type string

returns

never

throws

  • Redirect - 308 to the post's `pathname` under the base path
  • HttpError - 404 when no post has the id

find_blog_feed_item_by_param
#

blog_post_redirect.ts view source

(feed: { atom: { feed_url: string; }; items: { tags: string[]; title: string; date_published: string; date_modified: string; summary: string; id: string; url: string; pathname: string; blog_post_id: number; slug: string; }[]; ... 6 more ...; author: { ...; }; }, param: string): { ...; } | undefined import {find_blog_feed_item_by_param} from '@fuzdev/fuz_blog/blog_post_redirect.js';

Finds a feed's item by the param of the generated redirect route, which must be a bare post id like 1 - 01 and 1.0 find nothing.

feed

param

type string

returns

BlogFeedItem | undefined

to_blog_post_redirect_entries
#

blog_post_redirect.ts view source

(feed: { atom: { feed_url: string; }; items: { tags: string[]; title: string; date_published: string; date_modified: string; summary: string; id: string; url: string; pathname: string; blog_post_id: number; slug: string; }[]; ... 6 more ...; author: { ...; }; }): { ...; }[] import {to_blog_post_redirect_entries} from '@fuzdev/fuz_blog/blog_post_redirect.js';

The entries of the generated [post=blog_post_id] route: every post's bare id, so prerendering writes a redirect page for each.

feed

returns

{ post: string; }[]

Depends on
#