FileContentService Pennington.Content
Generic file-format content source: globs FilePattern under the content directory, parses each file's front matter into TFrontMatter, and emits FileSource discovered items tagged with the format key. Registered by AddContentFormat; the format's registered parser/renderer turn the bodies into HTML. Deliberately leaner than MarkdownContentService — no locale fan-out, no .llms.md handling, no _meta.yml folder metadata.
Properties
DefaultSectionLabelstring- Default section label applied to discovered items that do not supply one via front matter.
SearchPriorityint- Relative priority for ordering results in the search index (higher values rank first).
WatchScopesIReadOnlyList<FileWatchScope>- Directories needing an OS-level watcher. Empty (the default) for aggregators that ride notifications other watchers already produce.
Constructors
FileContentService
#public FileContentService`1(FileContentServiceOptions options, FrontMatterParser parser, IFileSystem fileSystem, TimeProvider clock = null, ILogger<FileContentService<TFrontMatter>> logger = null)
Creates the service and prepares lazy discovery of the content directory.
Parameters
optionsFileContentServiceOptionsparserFrontMatterParserfileSystemIFileSystemclockTimeProviderloggerILogger<FileContentService<TFrontMatter>>
Methods
DiscoverAsync
#public IAsyncEnumerable<DiscoveredItem> DiscoverAsync()
Discover all content items this service is responsible for.
Returns
IAsyncEnumerable<DiscoveredItem>GetAffectedRoutes
#public ContentChangeImpact GetAffectedRoutes(FileChangeNotification change)
Maps a file-change notification to the set of routes this service projects from that file, without mutating any cached state. Consulted by file-watched caches (SiteProjection, BuildHtmlCache) to invalidate only the affected entries instead of clearing wholesale. Default: None.
Parameters
changeFileChangeNotification
Returns
ContentChangeImpactGetContentTocEntriesAsync
#public Task<ImmutableList<ContentTocItem>> GetContentTocEntriesAsync()
Navigation entries for table of contents.
Returns
Task<ImmutableList<ContentTocItem>>GetContentToCopyAsync
#public Task<ImmutableList<ContentToCopy>> GetContentToCopyAsync()
Static files to copy to output (images, downloads, etc.)
Returns
Task<ImmutableList<ContentToCopy>>GetCrossReferencesAsync
#public Task<ImmutableList<CrossReference>> GetCrossReferencesAsync()
Cross-references for xref resolution.
Returns
Task<ImmutableList<CrossReference>>GetRedirectSourcesAsync
#public Task<ImmutableList<DiscoveredItem>> GetRedirectSourcesAsync()
Redirect sources this service emits (each item's Source is a RedirectSource). Consumed by RedirectContentService to build the unified redirect map without iterating every service's DiscoverAsync — which would force services that have no redirects to pay the full cost of discovery just to return nothing. Default: empty. Services backed by front-matter records that implement IRedirectable override this.
Returns
Task<ImmutableList<DiscoveredItem>>OnFileChanged
#public FileWatchResponse OnFileChanged(FileChangeNotification change)
Called on the file-watcher thread for every watched change. Must be quick and thread-safe.
Parameters
changeFileChangeNotification
Returns
FileWatchResponseParseContentAsync
#public IAsyncEnumerable<ParsedItem> ParseContentAsync()
Discovers and parses this service's content with the service's own front-matter type, yielding ParsedItems (typed metadata + body). Consumers like LlmsTxtService use this instead of re-parsing with a foreign parser, which would mis-flag valid keys from other content types. Default: empty — services whose content is sourced elsewhere (Razor/API pages fetched as rendered HTML) opt out.
Returns
IAsyncEnumerable<ParsedItem>Pennington.Content.FileContentService
namespace Pennington.Content;
/// Generic file-format content source: globs FilePattern under the content directory, parses each file's front matter into TFrontMatter, and emits FileSource discovered items tagged with the format key. Registered by AddContentFormat; the format's registered parser/renderer turn the bodies into HTML. Deliberately leaner than MarkdownContentService — no locale fan-out, no .llms.md handling, no _meta.yml folder metadata.
public class FileContentService
{
/// Default section label applied to discovered items that do not supply one via front matter.
public string DefaultSectionLabel { get; }
/// Discover all content items this service is responsible for.
public IAsyncEnumerable<DiscoveredItem> DiscoverAsync()
;
/// Creates the service and prepares lazy discovery of the content directory.
public FileContentService`1(FileContentServiceOptions options, FrontMatterParser parser, IFileSystem fileSystem, TimeProvider clock = null, ILogger<FileContentService<TFrontMatter>> logger = null)
;
/// Maps a file-change notification to the set of routes this service projects from that file, without mutating any cached state. Consulted by file-watched caches (SiteProjection, BuildHtmlCache) to invalidate only the affected entries instead of clearing wholesale. Default: None.
public ContentChangeImpact GetAffectedRoutes(FileChangeNotification change)
;
/// Navigation entries for table of contents.
public Task<ImmutableList<ContentTocItem>> GetContentTocEntriesAsync()
;
/// Static files to copy to output (images, downloads, etc.)
public Task<ImmutableList<ContentToCopy>> GetContentToCopyAsync()
;
/// Cross-references for xref resolution.
public Task<ImmutableList<CrossReference>> GetCrossReferencesAsync()
;
/// Redirect sources this service emits (each item's Source is a RedirectSource). Consumed by RedirectContentService to build the unified redirect map without iterating every service's DiscoverAsync — which would force services that have no redirects to pay the full cost of discovery just to return nothing. Default: empty. Services backed by front-matter records that implement IRedirectable override this.
public Task<ImmutableList<DiscoveredItem>> GetRedirectSourcesAsync()
;
/// Called on the file-watcher thread for every watched change. Must be quick and thread-safe.
public FileWatchResponse OnFileChanged(FileChangeNotification change)
;
/// Discovers and parses this service's content with the service's own front-matter type, yielding ParsedItems (typed metadata + body). Consumers like LlmsTxtService use this instead of re-parsing with a foreign parser, which would mis-flag valid keys from other content types. Default: empty — services whose content is sourced elsewhere (Razor/API pages fetched as rendered HTML) opt out.
public IAsyncEnumerable<ParsedItem> ParseContentAsync()
;
/// Relative priority for ordering results in the search index (higher values rank first).
public int SearchPriority { get; }
/// Directories needing an OS-level watcher. Empty (the default) for aggregators that ride notifications other watchers already produce.
public IReadOnlyList<FileWatchScope> WatchScopes { get; }
}