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

BookArtifactService Pennington.Book

Single source of truth for every book artifact, behind the artifact-tier façade BookArtifactContentService (which serves dev requests and enumerates the PDFs for the static build) — the same shape as SearchArtifactService.

The projection fold (post-pipeline HTML per page) and the static-asset map are computed once, lazily; each book's composed HTML is cached per (book, locale); PDF bytes are rendered on demand through the singleton ChromiumBrowserProvider and cached until a file change drops the whole service. EnumerateArtifacts is deliberately cheap — pure options × locales, no projection, no Chromium — so build enumeration and link verification never trigger a render.

Constructors

BookArtifactService

#
public BookArtifactService(BookOptions options, PenningtonOptions penn, LocalizationOptions localization, ISiteProjection projection, IEnumerable<IContentService> contentServices, NavigationBuilder navigationBuilder, BookComposer composer, AssetInliner assetInliner, ChromiumBrowserProvider chromium, TimeProvider clock, ILogger<BookArtifactService> logger)

Creates the service; all artifacts are computed lazily on first request.

Parameters

options BookOptions
penn PenningtonOptions
localization LocalizationOptions
projection ISiteProjection
contentServices IEnumerable<IContentService>
navigationBuilder NavigationBuilder
composer BookComposer
assetInliner AssetInliner
chromium ChromiumBrowserProvider
clock TimeProvider
logger ILogger<BookArtifactService>

Methods

GetPdfAsync

#
public Task<byte[]> GetPdfAsync(string pdfPath)

Renders the PDF for the artifact at pdfPath (e.g. pdf/tutorials.pdf), or null when no book matches.

Parameters

pdfPath string

Returns

Task<byte[]>

GetPreviewHtmlAsync

#
public Task<string> GetPreviewHtmlAsync(string previewPath)

Returns the composed HTML for the preview route at previewPath, or null when no book matches.

Parameters

previewPath string

Returns

Task<string>

OnFileChanged

#
public FileWatchResponse OnFileChanged(FileChangeNotification change)

Called on the file-watcher thread for every watched change. Must be quick and thread-safe.

Parameters

change FileChangeNotification

Returns

FileWatchResponse

Pennington.Book.BookArtifactService

namespace Pennington.Book;

/// Single source of truth for every book artifact, behind the artifact-tier façade BookArtifactContentService (which serves dev requests and enumerates the PDFs for the static build) — the same shape as SearchArtifactService. The projection fold (post-pipeline HTML per page) and the static-asset map are computed once, lazily; each book's composed HTML is cached per (book, locale); PDF bytes are rendered on demand through the singleton ChromiumBrowserProvider and cached until a file change drops the whole service. EnumerateArtifacts is deliberately cheap — pure options × locales, no projection, no Chromium — so build enumeration and link verification never trigger a render.
public class BookArtifactService
{
    /// Creates the service; all artifacts are computed lazily on first request.
    
public BookArtifactService(BookOptions options, PenningtonOptions penn, LocalizationOptions localization, ISiteProjection projection, IEnumerable<IContentService> contentServices, NavigationBuilder navigationBuilder, BookComposer composer, AssetInliner assetInliner, ChromiumBrowserProvider chromium, TimeProvider clock, ILogger<BookArtifactService> logger)
; /// Renders the PDF for the artifact at pdfPath (e.g. pdf/tutorials.pdf), or null when no book matches.
public Task<byte[]> GetPdfAsync(string pdfPath)
; /// Returns the composed HTML for the preview route at previewPath, or null when no book matches.
public Task<string> GetPreviewHtmlAsync(string previewPath)
; /// Called on the file-watcher thread for every watched change. Must be quick and thread-safe.
public FileWatchResponse OnFileChanged(FileChangeNotification change)
; }