Restructure into feature folders with code-behind and scoped CSS
This commit is contained in:
1 parent
5ba523d34d
commit
9d1f8fe0d4
25 files changed
+250
-203
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using Markdig;
|
||||
using Markdig.Extensions.Yaml;
|
||||
using Markdig.Syntax;
|
||||
|
||||
namespace Elternbeirat.Web.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Reads simple <c>key: value</c> pairs from a Markdown file's YAML front
|
||||
/// matter. Kept deliberately minimal (one value per line, no nesting) — this is
|
||||
/// enough for titles and dates. YamlDotNet will take over once we need
|
||||
/// structured metadata. Front-matter keys stay German because the Markdown
|
||||
/// files are edited by German-speaking editors.
|
||||
/// </summary>
|
||||
public static class FrontMatter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the value of the given front-matter key, or <c>null</c> if the
|
||||
/// file has no front matter or the key is missing. The key match is
|
||||
/// case-insensitive; surrounding quotes on the value are removed.
|
||||
/// </summary>
|
||||
public static string? Read(string key, MarkdownDocument document, string source)
|
||||
{
|
||||
var block = document.Descendants<YamlFrontMatterBlock>().FirstOrDefault();
|
||||
if (block is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var prefix = key + ":";
|
||||
var frontMatter = source.Substring(block.Span.Start, block.Span.Length);
|
||||
foreach (var line in frontMatter.Split('\n'))
|
||||
{
|
||||
var trimmed = line.Trim();
|
||||
if (trimmed.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return trimmed[prefix.Length..].Trim().Trim('"');
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user