Skip to content

feat: Allow serving blog posts as markdown - #553

Merged
linkdotnet merged 2 commits into
masterfrom
feat/serve-as-markdown
Oct 20, 2026
Merged

linkdotnet merged 2 commits into
masterfrom
feat/serve-as-markdown

Conversation

@linkdotnet

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI balanced review requested due to automatic review settings October 20, 2026 06:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Content negotiation can return HTML despite an explicit rejection because wildcard quality overrides a more specific media range.

1 open issue
What changed in this PR

Adds optional Markdown responses for published blog posts alongside the existing HTML pages.

Changes:

  • Introduces content negotiation and Markdown rendering with metadata and expanded short codes.
  • Adds a disabled-by-default setting and configuration migration to version 17.0.
  • Adds tests and setup documentation.
File Description
tools/​LinkDotNet.Blog.UpgradeAssistant/​Migrations/​Migration_16_To_17.cs Adds the disabled setting.
tools/​LinkDotNet.Blog.UpgradeAssistant/​MigrationDiscovery.cs Registers the migration.
tests/​LinkDotNet.Blog.UpgradeAssistant.Tests/​MigrationManagerTests.cs Tests upgrades to version 17.0.
tests/​LinkDotNet.Blog.UpgradeAssistant.Tests/​Migration16To17Tests.cs Tests setting migration behavior.
tests/​LinkDotNet.Blog.UnitTests/​Web/​Features/​ShowBlogPost/​BlogPostMarkdownRendererTests.cs Tests Markdown formatting and metadata.
tests/​LinkDotNet.Blog.UnitTests/​Web/​Features/​ShowBlogPost/​BlogPostMarkdownMiddlewareTests.cs Tests content negotiation.
tests/​LinkDotNet.Blog.UnitTests/​Web/​Features/​MarkdownConverterTests.cs Tests short-code expansion.
tests/​LinkDotNet.Blog.UnitTests/​Web/​ApplicationConfigurationTests.cs Tests setting binding and default.
tests/​LinkDotNet.Blog.TestUtilities/​ApplicationConfigurationBuilder.cs Supports the setting in test fixtures.
tests/​LinkDotNet.Blog.IntegrationTests/​BlogPostMarkdownTests.cs Tests Markdown responses and HTML fallback.
src/​LinkDotNet.Blog.Web/​WebApplicationExtensions.cs Conditionally enables middleware.
src/​LinkDotNet.Blog.Web/​Program.cs Integrates middleware into the pipeline.
src/​LinkDotNet.Blog.Web/​Features/​ShowBlogPost/​ShowBlogPostPage.razor Reuses shared short-code expansion.
src/​LinkDotNet.Blog.Web/​Features/​ShowBlogPost/​BlogPostMarkdownRenderer.cs Renders Markdown with front matter.
src/​LinkDotNet.Blog.Web/​Features/​ShowBlogPost/​BlogPostMarkdownMiddleware.cs Negotiates and serves published posts.
src/​LinkDotNet.Blog.Web/​Features/​MarkdownConverter.cs Extracts shared short-code expansion.
src/​LinkDotNet.Blog.Web/​appsettings.json Updates configuration version and default.
src/​LinkDotNet.Blog.Web/​ApplicationConfiguration.cs Defines the feature setting.
MIGRATION.md Documents the configuration upgrade.
docs/​Setup/​Configuration.md Explains Markdown requests and responses.
docs/​Migrations/​UpgradeAssistant.md Documents the new migration.

Review effort: Balanced

Comment thread src/LinkDotNet.Blog.Web/Features/ShowBlogPost/BlogPostMarkdownMiddleware.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Plain-text titles need escaping to preserve their displayed content in Markdown headings.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Escape Markdown and HTML metacharacters in heading titles

src/​LinkDotNet.Blog.Web/​Features/​ShowBlogPost/​BlogPostMarkdownRenderer.cs:33

The title is plain text, but this line inserts it as Markdown syntax. For example, Understanding List<T> produces a heading whose <T> is treated as an HTML tag by Markdown renderers, so the displayed title loses the type argument. Escape Markdown/HTML metacharacters in the heading title while leaving the post body unchanged. Add a generic-type title regression test and update the existing assertion that expects an unescaped title backslash.

1 resolved since last review

Review effort: Balanced

@linkdotnet
linkdotnet merged commit 4f288a2 into master Oct 20, 2026
4 checks passed
@linkdotnet
linkdotnet deleted the feat/serve-as-markdown branch October 20, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants