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

LlmsTxtService Pennington.LlmsTxt

Generates llms.txt index and stripped markdown files. When managed by FileWatchDependencyFactory, the instance is recreated on file changes — no manual watcher subscription needed.

Folds over ISiteProjection: every renderable page's post-pipeline HTML is already captured by the shared projection, so this service is a pure adapter from RenderedPage + HtmlToMarkdownConverter to the front-door index, per-subtree index files, and per-page sidecar markdown.

Constructors

LlmsTxtService

#
public LlmsTxtService(ISiteProjection projection, IEnumerable<IContentService> contentServices, IEnumerable<LlmsSubtree> subtrees, IFileSystem fileSystem, IWebHostEnvironment hostingEnvironment, PenningtonOptions pennOptions, LlmsTxtOptions llmsTxtOptions, CanonicalBaseUrl canonicalBase, NavigationBuilder navigationBuilder, ILogger<LlmsTxtService> logger)

Creates the service; data is computed lazily on first request.

Parameters

projection ISiteProjection
contentServices IEnumerable<IContentService>
subtrees IEnumerable<LlmsSubtree>
fileSystem IFileSystem
hostingEnvironment IWebHostEnvironment
pennOptions PenningtonOptions
llmsTxtOptions LlmsTxtOptions
canonicalBase CanonicalBaseUrl
navigationBuilder NavigationBuilder
logger ILogger<LlmsTxtService>

Methods

GetLlmsFullTxtAsync

#
public Task<string> GetLlmsFullTxtAsync()

Returns the optional concatenated llms-full.txt content, or null when disabled.

Returns

Task<string>

GetLlmsTxtAsync

#
public Task<string> GetLlmsTxtAsync()

Returns the generated llms.txt index content.

Returns

Task<string>

GetMarkdownFilesAsync

#
public Task<ImmutableList<MarkdownFile>> GetMarkdownFilesAsync()

Returns the per-page stripped markdown files emitted alongside llms.txt.

Returns

Task<ImmutableList<MarkdownFile>>

GetSubtreeFilesAsync

#
public Task<ImmutableList<MarkdownFile>> GetSubtreeFilesAsync()

Returns per-subtree {prefix}llms.txt index files split out of the front door.

Returns

Task<ImmutableList<MarkdownFile>>

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.LlmsTxt.LlmsTxtService

namespace Pennington.LlmsTxt;

/// Generates llms.txt index and stripped markdown files. When managed by FileWatchDependencyFactory, the instance is recreated on file changes — no manual watcher subscription needed. Folds over ISiteProjection: every renderable page's post-pipeline HTML is already captured by the shared projection, so this service is a pure adapter from RenderedPage + HtmlToMarkdownConverter to the front-door index, per-subtree index files, and per-page sidecar markdown.
public class LlmsTxtService
{
    /// Returns the optional concatenated llms-full.txt content, or null when disabled.
    
public Task<string> GetLlmsFullTxtAsync()
; /// Returns the generated llms.txt index content.
public Task<string> GetLlmsTxtAsync()
; /// Returns the per-page stripped markdown files emitted alongside llms.txt.
public Task<ImmutableList<MarkdownFile>> GetMarkdownFilesAsync()
; /// Returns per-subtree {prefix}llms.txt index files split out of the front door.
public Task<ImmutableList<MarkdownFile>> GetSubtreeFilesAsync()
; /// Creates the service; data is computed lazily on first request.
public LlmsTxtService(ISiteProjection projection, IEnumerable<IContentService> contentServices, IEnumerable<LlmsSubtree> subtrees, IFileSystem fileSystem, IWebHostEnvironment hostingEnvironment, PenningtonOptions pennOptions, LlmsTxtOptions llmsTxtOptions, CanonicalBaseUrl canonicalBase, NavigationBuilder navigationBuilder, ILogger<LlmsTxtService> logger)
; /// Called on the file-watcher thread for every watched change. Must be quick and thread-safe.
public FileWatchResponse OnFileChanged(FileChangeNotification change)
; }