Nested folders

Read Markdown from every folder below a root with the ** wildcard, and learn how index.md files get their slug.

On this page
csharp
[DataSource("Guides", "./**/*.md")]
public sealed record Guide(string Slug, string Title, string SourcePath, string RawMarkdown);

Use ** to read Markdown (or any list file type) from the folders below the one you name.

  • Guides/
  • Guide.cs
  • overview.md
  • intro/
  • index.md
  • advanced/
  • tuning.md
  • ./*.md reads one folder only.
  • The part before the first wildcard is the root. Other wildcards are only allowed in the last segment.
  • Files are sorted by their path (ordinal, / separators), so the order is stable.
  • SourcePath is the path relative to the root, for example intro/index.md. For ./*.md it is the file name.
  • A file named index.md (or index.markdown) below the root gets the name of its folder as its slug. intro/index.md has the slug intro. A slug: in the front matter still wins. An index.md at the root keeps the slug index.

Recursive reads skip hidden and system entries silently. Bevel never follows symbolic links or other reparse points. It skips each one and prints a build message:

text
Dataset 'Posts': skipped symbolic link 'content/shared' (symlinks are not followed).

Catch slug clashes

intro.md next to intro/index.md gives two items with the slug intro. Bevel does not check this for you. Add [Unique] to catch it:

csharp
public sealed record Guide([Unique(IgnoreCase = true)] string Slug, string Title, string SourcePath, string RawMarkdown);