opengraph article integration

This commit is contained in:
veclav talica 2023-05-25 21:58:10 +05:00
parent 37f7bf2c11
commit ba8327c161
2 changed files with 15 additions and 3 deletions

View File

@ -15,7 +15,7 @@ for d in ./articles/*/; do
mkdir -p "./html/articles/$(basename -- $d)" mkdir -p "./html/articles/$(basename -- $d)"
cp -r "$d/.dynamic/." "./html/articles/$(basename -- $d)/" cp -r "$d/.dynamic/." "./html/articles/$(basename -- $d)/"
fi fi
./tools/article_wrapper.py "$d/page.mmd" | ./tools/mmd/build/multimarkdown > "./html/articles/$(basename -- $d).html" ./tools/article_wrapper.py "$d/page.mmd" https://mjestecko.neocities.org/ | ./tools/mmd/build/multimarkdown > "./html/articles/$(basename -- $d).html"
fi fi
done done

View File

@ -3,7 +3,7 @@
# todo: Show related git history of a file? # todo: Show related git history of a file?
from sys import argv, exit from sys import argv, exit
import time import time, urllib.parse
from article_utils import the_line_after_metadata, parse_metadata from article_utils import the_line_after_metadata, parse_metadata
from page_shares import wrap_page, MONTHS from page_shares import wrap_page, MONTHS
@ -12,6 +12,10 @@ if len(argv) <= 1:
print("No file was supplied") print("No file was supplied")
exit(-1) exit(-1)
if len(argv) <= 2:
print("No address was supplied")
exit(-1)
with open(argv[1], "r") as f: with open(argv[1], "r") as f:
content = f.readlines() content = f.readlines()
i = the_line_after_metadata(content) i = the_line_after_metadata(content)
@ -42,4 +46,12 @@ if tags:
article_head += "---\n\n" article_head += "---\n\n"
print(''.join(content[:i]) + wrap_page(article_head + ''.join(content[i:]))) # todo: Article namespace with related metadata.
header = f"""HTML header: <meta property="og:title" content="{title} on mjestečko"></meta>
<meta property="og:type" content="article"></meta>
<meta property="og:url" content="{argv[2]}/articles/{urllib.parse.quote(title)}.html"></meta>
"""
if not brief is None:
header += f"""<meta property="og:description" content="{brief}"></meta>\n"""
print(header + ''.join(content[:i]) + wrap_page(article_head + ''.join(content[i:])))