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
recordsContentRecordRegistryresolverIPageResolverclockTimeProvider
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
basePrefixstring- URL prefix the posts live under.
pageint- 1-based page index.
pageSizeint- 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
basePrefixstring- 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
urlUrlPath- 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
siteTitlestring- Feed/site title.
siteDescriptionstring- Feed/site description.
canonicalBaseUrlstring- Absolute base URL used to compose item links; may be null.
basePrefixstring- URL prefix the posts live under.
authorFunc<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)
;
}