blog.ts

A blog's feed: the post metadata authors write, the configured feed metadata, and the strict feed and entries gro gen derives from them, with the URL derivations from home_page_url. Free of node, gro, and Svelte imports.

view source

Declarations
#

6 declarations

BlogFeed
#

blog.ts view source

value + type

{ id: string; title: string; home_page_url: string; description: string; icon: string; favicon: string; author: { name: string; url?: string | undefined; email?: string | undefined; }; items: { id: string; ... 8 more ...; slug: string; }[]; atom: { ...; }; } import {BlogFeed} from '@fuzdev/fuz_blog/blog.js';

A blog's complete feed, generated by gro gen into src/routes/<dirname>/feed.ts: the configured BlogFeedMetadata, the derived atom.feed_url, and the post entries.

id

type string

title

type string

home_page_url

type string

description

type string

icon

type string

favicon

type string

author

type { name: string; url?: string | undefined; email?: string | undefined; }

items

type BlogFeedItem[]

atom

type { feed_url: string; }

BlogFeedItem
#

blog.ts view source

value + type

{ id: string; title: string; url: string; date_published: string; date_modified: string; summary: string; tags: string[]; pathname: string; blog_post_id: number; slug: string; } import {BlogFeedItem} from '@fuzdev/fuz_blog/blog.js';

A feed entry, derived from a BlogPostMetadata by resolve_blog_feed_item. Strict, so a leaked consumer field fails the generated feed's validation.

id

type string

title

type string

url

type string

date_published

type string

date_modified

type string

summary

type string

tags

type string[]

pathname

type string

blog_post_id

type number

slug

type string

BlogFeedMetadata
#

blog.ts view source

value + type

{ id: string; title: string; home_page_url: string; description: string; icon: string; favicon: string; author: { name: string; url?: string | undefined; email?: string | undefined; }; } import {BlogFeedMetadata} from '@fuzdev/fuz_blog/blog.js';

A blog's configured feed metadata: the Feed fields without items, which come from the posts, and atom, which gro gen derives from home_page_url (see to_blog_feed_url).

id

type string

title

type string

home_page_url

type string

description

type string

icon

type string

favicon

type string

author

type { name: string; url?: string | undefined; email?: string | undefined; }

BlogPostMetadata
#

blog.ts view source

value + type

{ title: string; date_published: string; date_modified: string; summary: string; tags?: string[] | undefined; } & Record<string, unknown>

type { title: string; date_published: string; date_modified: string; summary: string; tags?: string[] | undefined; } & Record<string, unknown>

import {BlogPostMetadata} from '@fuzdev/fuz_blog/blog.js';

The author-defined metadata for each post. Loose so a consumer can add its own fields (e.g. an autoblog's model); the extras stay on the page's post and do not reach the generated BlogFeed (see resolve_blog_feed_item). The slug is not metadata - it comes from the post's <id>-<slug> directory name (see parse_blog_post_dirname).

title

type string

date_published

type string

date_modified

type string

summary

type string

tags?

type string[]

[key: string]

type unknown

resolve_blog_feed_item
#

blog.ts view source

(post_dir: BlogPostDir, dirname: string, home_page_url: string, post: { title: string; date_published: string; date_modified: string; summary: string; tags?: string[] | undefined; } & Record<...>): { ...; } import {resolve_blog_feed_item} from '@fuzdev/fuz_blog/blog.js';

Derives a BlogFeedItem (the feed entry) from a post, its directory's id and slug, and its blog's dirname and home_page_url. Emits only BlogFeedItem fields - a consumer's extra post metadata stays on the page's post for its component to render, and does not leak into the typed generated feed.

post_dir

the post's id and slug, from its directory name

dirname

the blog's route directory under src/routes, from its BlogConfig

type string

home_page_url

the blog's index url, from its feed.home_page_url

type string

post

the author-defined post metadata

returns

BlogFeedItem

to_blog_feed_url
#

blog.ts view source

(home_page_url: string): string import {to_blog_feed_url} from '@fuzdev/fuz_blog/blog.js';

Derives a blog's Atom feed URL from its home_page_url. gro gen writes the feed to static/<dirname>/feed.xml, served beside the blog's index, so the URL is <home_page_url>/feed.xml (a trailing slash on home_page_url is ignored).

home_page_url

type string

returns

string

Depends on
#

Imported by
#