Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,25 @@ if [ ! -f "$FILE" ]; then
exit 1
fi

# Extract frontmatter
FRONTMATTER=$(sed -n '/^---$/,/^---$/{ /^---$/d; p; }' "$FILE")
# Extract only the opening frontmatter block. A range-based sed expression
# restarts at later Markdown horizontal rules and can mix body text into it.
FRONTMATTER=$(awk '
NR == 1 {
if ($0 != "---") exit 1
next
}
/^---$/ {
found_end = 1
exit
}
{ print }
END {
if (!found_end) exit 1
}
' "$FILE") || {
echo "Error: No frontmatter found in $FILE" >&2
exit 1
}

if [ -z "$FRONTMATTER" ]; then
echo "Error: No frontmatter found in $FILE" >&2
Expand Down