add directory normalization
This commit is contained in:
parent
b045739b45
commit
0b4de161b5
2 changed files with 11 additions and 3 deletions
|
@ -44,7 +44,15 @@ def discover(root: Path, out_dir: Path) -> list[Item]:
|
||||||
item.metadata, item.content = split_metadata(path)
|
item.metadata, item.content = split_metadata(path)
|
||||||
item.type = ItemType.MARKDOWN
|
item.type = ItemType.MARKDOWN
|
||||||
item.copy = False
|
item.copy = False
|
||||||
item.destination = destination.with_suffix(".html")
|
name = destination.stem
|
||||||
|
if name == "index":
|
||||||
|
item.destination = item.destination.with_suffix(".html")
|
||||||
|
else:
|
||||||
|
relative = path.relative_to(base).with_suffix("")
|
||||||
|
name = relative.stem
|
||||||
|
item.destination = (
|
||||||
|
out_dir / relative.parent / name / "index.html"
|
||||||
|
)
|
||||||
items.append(item)
|
items.append(item)
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ p {
|
||||||
|
|
||||||
md_item = items[0]
|
md_item = items[0]
|
||||||
assert md_item.source == md_file
|
assert md_item.source == md_file
|
||||||
assert md_item.destination.name == "post.md"
|
assert md_item.destination.name == "index.html"
|
||||||
assert md_item.destination.is_relative_to(outd)
|
assert md_item.destination.is_relative_to(outd)
|
||||||
assert md_item.url == "post.md"
|
assert md_item.url == "post.md"
|
||||||
assert isinstance(md_item.metadata, Metadata)
|
assert isinstance(md_item.metadata, Metadata)
|
||||||
|
@ -103,7 +103,7 @@ p {
|
||||||
|
|
||||||
items = discover(tmp_path, outd)
|
items = discover(tmp_path, outd)
|
||||||
build(items)
|
build(items)
|
||||||
html = (outd / "post.html").read_text()
|
html = (outd / "post" / "index.html").read_text()
|
||||||
assert html.strip() == "<h1>Hello World</h1>"
|
assert html.strip() == "<h1>Hello World</h1>"
|
||||||
s = (outd / "static" / "style.css").read_text()
|
s = (outd / "static" / "style.css").read_text()
|
||||||
assert s.strip() == style_content.strip()
|
assert s.strip() == style_content.strip()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue