Support YAML front matter in Markdown uploads#1
Closed
Said-MZ wants to merge 4 commits into
Closed
Conversation
Tailwind's --watch stops as soon as stdin closes, which Foreman does immediately for spawned processes, so `mise run dev` exited the whole process group right after boot. --watch=always keeps it running regardless of stdin.
Parse a leading --- delimited YAML block off Markdown uploads before rendering. `title` overrides the H1/filename fallback for the page <title>, and `description` renders as a meta description tag. Malformed or non-mapping front matter (or none at all) falls back to treating the whole file as plain Markdown body, so nothing breaks rendering.
There was a problem hiding this comment.
Pull request overview
Adds support for YAML front matter in Markdown uploads so authors can set page metadata (HTML <title> and <meta name="description">) without affecting Markdown rendering, and adjusts the dev CSS watcher to stay alive under Foreman.
Changes:
- Parse and strip a leading
----delimited YAML front matter block inMarkdownDocument, usingtitle/descriptionas metadata. - Add model tests covering front matter parsing, precedence rules, and fallback behavior for malformed/non-mapping YAML.
- Update
Procfile.devCSS watcher invocation to use--watch=alwaysto prevent premature shutdown.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/models/markdown_document.rb | Adds front matter splitting/parsing and emits optional meta description tag during HTML rendering. |
| test/models/markdown_document_test.rb | Introduces test coverage for front matter behavior and edge cases. |
| Procfile.dev | Keeps the CSS watcher process alive under Foreman by switching Tailwind watch mode. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Psych::SyntaxError and Psych::DisallowedClass aren't the only failure modes -- YAML aliases (&anchor/*alias) raise Psych::BadAlias or Psych::AliasesNotEnabled, which weren't rescued and would break rendering instead of falling back to plain Markdown body. Co-authored-by: Copilot code review
Redundant with the broadened Psych::Exception rescue itself; not worth the upkeep.
Owner
Author
|
Superseded by AliOsm#19, opened against the upstream repo instead of my fork. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
----delimited YAML front matter block off Markdown uploads before rendering (MarkdownDocument).titleoverrides the H1/filename fallback for the page<title>;descriptionrenders as a<meta name="description">tag.Procfile.dev'scssprocess used Tailwind's--watch, which stops as soon as stdin closes — which Foreman does immediately for spawned processes — killing the wholemise run devprocess group right after boot. Switched to--watch=always.Test plan
bin/rails test test/models/markdown_document_test.rb(17 assertions covering strip/parse/title/description precedence, malformed and non-mapping front matter, and the "stray---horizontal rule isn't mistaken for front matter" edge case) — all passbin/rails test test/models/paste_test.rb— all pass (no regression in the ingest path)rails runnerand confirmed<title>/<meta description>are set correctly and the YAML block doesn't leak into the bodymise run devkeeps all three Foreman processes (web/js/css) alive after the Procfile fix🤖 Generated with Claude Code