Allow txt content and deny robots
This commit is contained in:
parent
7755f2be31
commit
c652657ea7
44
build.py
44
build.py
|
@ -40,7 +40,7 @@ def main():
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
# Future-proofing
|
# Future-proofing
|
||||||
if not filename.endswith(".html") and not filename.endswith(".md"):
|
if filename.rsplit(".")[-1] not in ("html", "md", "txt"):
|
||||||
raise Exception("Support for this filetype is not yet supported:", filename)
|
raise Exception("Support for this filetype is not yet supported:", filename)
|
||||||
|
|
||||||
path = src / dirpath / filename
|
path = src / dirpath / filename
|
||||||
|
@ -58,30 +58,34 @@ def main():
|
||||||
content = md.convert(content)
|
content = md.convert(content)
|
||||||
meta = md.Meta
|
meta = md.Meta
|
||||||
|
|
||||||
# Inject content into the template
|
if dest.name.endswith("html"):
|
||||||
page_content = bs4.BeautifulSoup(content, features="html.parser")
|
# Inject content into the template
|
||||||
page = copy.copy(template)
|
page_content = bs4.BeautifulSoup(content, features="html.parser")
|
||||||
article = page.new_tag("article")
|
page = copy.copy(template)
|
||||||
article.append(page_content)
|
article = page.new_tag("article")
|
||||||
page.article.replace_with(article)
|
article.append(page_content)
|
||||||
|
page.article.replace_with(article)
|
||||||
|
|
||||||
# Inject path into the nav
|
# Inject path into the nav
|
||||||
for i in range(len(dirpath.parts)):
|
for i in range(len(dirpath.parts)):
|
||||||
a = page.new_tag("a")
|
a = page.new_tag("a")
|
||||||
a["href"] = "/" + "/".join(dirpath.parts[:i+1]) + "/"
|
a["href"] = "/" + "/".join(dirpath.parts[:i+1]) + "/"
|
||||||
a.string = dirpath.parts[i]
|
a.string = dirpath.parts[i]
|
||||||
page.nav.append(a)
|
page.nav.append(a)
|
||||||
page.nav.append(page.new_string("/"))
|
page.nav.append(page.new_string("/"))
|
||||||
|
|
||||||
# Apply metadata to the template
|
# Apply metadata to the template
|
||||||
if meta_title := meta.get("title"):
|
if meta_title := meta.get("title"):
|
||||||
title = "".join(meta_title)
|
title = "".join(meta_title)
|
||||||
page.title.string = title
|
page.title.string = title
|
||||||
page.header.h1.string = title
|
page.header.h1.string = title
|
||||||
|
|
||||||
|
# The fully templated page is the new content
|
||||||
|
content = str(page)
|
||||||
|
|
||||||
# Write the destination file
|
# Write the destination file
|
||||||
print("Writing ", dest)
|
print("Writing ", dest)
|
||||||
dest.write_text(str(page))
|
dest.write_text(content)
|
||||||
|
|
||||||
print("Processed", count, "files")
|
print("Processed", count, "files")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /
|
Loading…
Reference in New Issue