diff --git a/photojawn/generate.py b/photojawn/generate.py index 1cd1c9d..b5f3f86 100644 --- a/photojawn/generate.py +++ b/photojawn/generate.py @@ -49,6 +49,7 @@ class ImageDirectory: @dataclass class ImagePath: path: Path + description: str = "" def thumbnail_filename(self) -> str: return self.path.stem + ".thumb" + self.path.suffix @@ -122,6 +123,13 @@ def find_images(root_path: Path) -> ImageDirectory: # that separately continue + # If there's an associated .txt or .md file, read it in as the image's + # description + if file_path.with_suffix(".md").exists(): + ip.description = markdown(file_path.with_suffix(".md").read_text()) + elif file_path.with_suffix(".txt").exists(): + ip.description = file_path.with_suffix(".txt").read_text() + image_dir.images.append(ip) if image_dir.cover_path is None and len(image_dir.images) > 0: diff --git a/photojawn/skel/_templates/photo.html b/photojawn/skel/_templates/photo.html index 403ed1e..86ead53 100644 --- a/photojawn/skel/_templates/photo.html +++ b/photojawn/skel/_templates/photo.html @@ -42,6 +42,12 @@ +
+ {% if image_path.description %} + {{ image_path.description | safe }} + {% endif %} +
+
view full size