From 051a51280f98adae2b86925e5ac847f343bcb5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20S=C3=A9chet?= Date: Tue, 21 May 2024 00:52:28 +0200 Subject: [PATCH] feat: add glob method on ContentDirectory --- jwebsite/content.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jwebsite/content.py b/jwebsite/content.py index a40e801..ba79f03 100644 --- a/jwebsite/content.py +++ b/jwebsite/content.py @@ -1,6 +1,6 @@ from functools import cache from pathlib import Path -from typing import Any, Iterator +from typing import Any, Iterable, Iterator from markdown import Markdown from yaml import Loader, load @@ -27,6 +27,10 @@ class ContentDirectory(Content): return current + def glob(self, pattern: str) -> Iterable[Content]: + for item in self.path.glob(pattern): + yield self.load(str(item)) + @cache # noqa: B019 def __load_children(self, name: str) -> Content: child_path = self.path / name