This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

BlogPostQuery Pennington.Content

Shared read model for blog-style content: lists posts, paginates them, renders a single post, and builds the RSS feed. Everything reads the cached ContentRecordRegistry snapshot and IPageResolver, so nothing re-reads or re-parses markdown per request. Generic over the host's front-matter type; both the DocSite and BlogSite templates consume this one service.

Constructors

BlogPostQuery

#
public BlogPostQuery(ContentRecordRegistry records, IPageResolver resolver, TimeProvider clock = null)

Creates the query over the content-record registry, page resolver, and wall clock.

Parameters

records ContentRecordRegistry
resolver IPageResolver
clock TimeProvider

Methods

GetPageAsync<TFrontMatter>

#
public Task<PagedList<BlogPostRef<TFrontMatter>>> GetPageAsync<TFrontMatter>(string basePrefix, int page, int pageSize)

Returns one page of posts under basePrefix, newest first. Returns null when page/pageSize are non-positive or the page is past the end; page 1 of an empty set yields an empty page rather than null.

Parameters

basePrefix string
URL prefix the posts live under.
page int
1-based page index.
pageSize int
Items per page.

Returns

Task<PagedList<BlogPostRef<TFrontMatter>>>

GetPostsAsync<TFrontMatter>

#
public Task<ImmutableList<BlogPostRef<TFrontMatter>>> GetPostsAsync<TFrontMatter>(string basePrefix)

Returns every published TFrontMatter post whose route sits under basePrefix (e.g. /blog), newest first. Drafts and future-dated posts are excluded. Reads the cached record snapshot — no file I/O.

Parameters

basePrefix string
URL prefix the posts live under.

Returns

Task<ImmutableList<BlogPostRef<TFrontMatter>>>

GetRenderedPostAsync<TFrontMatter>

#
public Task<RenderedBlogPost<TFrontMatter>> GetRenderedPostAsync<TFrontMatter>(UrlPath url)

Renders the single post at url through the cached page resolver. Returns null when nothing matches or the matched page is not a TFrontMatter.

Parameters

url UrlPath
Canonical URL of the post to render.

Returns

Task<RenderedBlogPost<TFrontMatter>>

GetRssXmlAsync<TFrontMatter>

#
public Task<string> GetRssXmlAsync<TFrontMatter>(string siteTitle, string siteDescription, string canonicalBaseUrl, string basePrefix, Func<TFrontMatter, string> author = null)

Builds RSS 2.0 XML for the posts under basePrefix, newest first. author projects each post's author name (the field is template-specific, not part of IFrontMatter); pass null to omit authors.

Parameters

siteTitle string
Feed/site title.
siteDescription string
Feed/site description.
canonicalBaseUrl string
Absolute base URL used to compose item links; may be null.
basePrefix string
URL prefix the posts live under.
author Func<TFrontMatter, string>
Projects a post's author name, or null to omit.

Returns

Task<string>

Pennington.Content.BlogPostQuery

namespace Pennington.Content;

/// Shared read model for blog-style content: lists posts, paginates them, renders a single post, and builds the RSS feed. Everything reads the cached ContentRecordRegistry snapshot and IPageResolver, so nothing re-reads or re-parses markdown per request. Generic over the host's front-matter type; both the DocSite and BlogSite templates consume this one service.
public class BlogPostQuery
{
    /// Creates the query over the content-record registry, page resolver, and wall clock.
    
public BlogPostQuery(ContentRecordRegistry records, IPageResolver resolver, TimeProvider clock = null)
; /// Returns one page of posts under basePrefix, newest first. Returns null when page/pageSize are non-positive or the page is past the end; page 1 of an empty set yields an empty page rather than null.
public Task<PagedList<BlogPostRef<TFrontMatter>>> GetPageAsync<TFrontMatter>(string basePrefix, int page, int pageSize)
; /// Returns every published TFrontMatter post whose route sits under basePrefix (e.g. /blog), newest first. Drafts and future-dated posts are excluded. Reads the cached record snapshot — no file I/O.
public Task<ImmutableList<BlogPostRef<TFrontMatter>>> GetPostsAsync<TFrontMatter>(string basePrefix)
; /// Renders the single post at url through the cached page resolver. Returns null when nothing matches or the matched page is not a TFrontMatter.
public Task<RenderedBlogPost<TFrontMatter>> GetRenderedPostAsync<TFrontMatter>(UrlPath url)
; /// Builds RSS 2.0 XML for the posts under basePrefix, newest first. author projects each post's author name (the field is template-specific, not part of IFrontMatter); pass null to omit authors.
public Task<string> GetRssXmlAsync<TFrontMatter>(string siteTitle, string siteDescription, string canonicalBaseUrl, string basePrefix, Func<TFrontMatter, string> author = null)
; }