Pi66

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

← back to log

fix: resolve symlinked markdown files using readlink before compiling

author: pi66
date: 2026-07-05 01:19
hash: b900af2e7290dcb0e043a7b31b0139c66378e6ac

Diffstat:

M

src/build.py
5 ++++++++++++++++++------------
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
diff --git a/src/build.py b/src/build.py
index fb72e7e..349bf4e 100644
--- a/src/build.py
+++ b/src/build.py
@@ -6,7 +6,7 @@ from . import settings
 from jinja2 import Environment, FileSystemLoader
 from markdown import markdown
 from markdown.extensions.attr_list import AttrListTreeprocessor
-from os import chdir, getcwd, makedirs, path, walk
+from os import chdir, getcwd, makedirs, path, walk, readlink
 from os.path import abspath, dirname

 from .config import find_project_from_path, load_config
@@ -173,7 +173,8 @@ def build(building_type:str,project_path:str, file:list[str]):
                     md_file = path.join(parent, filename)
                     md_relpath = path.relpath(md_file,md_path)
                     html_dest  = path.join(config.tree.dest, md_relpath).removesuffix(".md") + ".html"
-                    compile_md_to_html(md_file, html_dest)
+                    source_file = readlink(md_file) if path.islink(md_file) else md_file
+                    compile_md_to_html(source_file, html_dest)

     except Exception as e:
         fatal(e, f"Build failed: {e}")