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

MarkdownLinkResolver Pennington.Markdown

Resolves author-written relative links inside markdown bodies to absolute canonical URLs. Handles three cases:

  • ../how-to/foo.md — rewrites to the canonical URL of the target markdown file and strips the .md suffix.
  • sample-post (no extension) — treated as a sibling markdown reference, resolved against the source file's directory and looked up by trying common extensions.
  • ./image.png or other non-markdown relative assets — resolved against the source file's directory and emitted as an absolute URL relative to the owning content source's base URL.

The index is built lazily from all registered IContentService instances. When managed by FileWatchDependencyFactory, the instance is recreated on file changes so the index stays fresh.

Constructors

MarkdownLinkResolver

#
public MarkdownLinkResolver(IEnumerable<IContentService> contentServices)

Creates the resolver; the link index is built lazily on first resolution.

Parameters

contentServices IEnumerable<IContentService>

Methods

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

ResolveAsync

#
public ValueTask<string> ResolveAsync(FilePath sourceFile, string href)

Resolve a markdown-author-written href against the source file that contains it. Returns the rewritten href, or null if the href is external / absolute / unresolvable and should be left untouched.

Parameters

sourceFile FilePath
href string

Returns

ValueTask<string>

Pennington.Markdown.MarkdownLinkResolver

namespace Pennington.Markdown;

/// Resolves author-written relative links inside markdown bodies to absolute canonical URLs. Handles three cases: 
  • ../how-to/foo.md — rewrites to the canonical URL of the target markdown file and strips the .md suffix.
  • sample-post (no extension) — treated as a sibling markdown reference, resolved against the source file's directory and looked up by trying common extensions.
  • ./image.png or other non-markdown relative assets — resolved against the source file's directory and emitted as an absolute URL relative to the owning content source's base URL.
The index is built lazily from all registered IContentService instances. When managed by FileWatchDependencyFactory, the instance is recreated on file changes so the index stays fresh. public class MarkdownLinkResolver { /// Creates the resolver; the link index is built lazily on first resolution.
public MarkdownLinkResolver(IEnumerable<IContentService> contentServices)
; /// Called on the file-watcher thread for every watched change. Must be quick and thread-safe.
public FileWatchResponse OnFileChanged(FileChangeNotification change)
; /// Resolve a markdown-author-written href against the source file that contains it. Returns the rewritten href, or null if the href is external / absolute / unresolvable and should be left untouched.
public ValueTask<string> ResolveAsync(FilePath sourceFile, string href)
; }