fix url in preview embeds

This commit is contained in:
veclav talica 2024-02-10 22:53:26 +05:00
parent 760f947c00
commit a395c3e016
2 changed files with 5 additions and 4 deletions

View File

@ -19,8 +19,8 @@ for d in ./articles/*/; do
mkdir -p "./html/articles/$(basename -- $d)" mkdir -p "./html/articles/$(basename -- $d)"
cp -r "$d/.static/." "./html/articles/$(basename -- $d)/" cp -r "$d/.static/." "./html/articles/$(basename -- $d)/"
fi fi
./tools/article_wrapper.py "$d/page.mmd" https://mjestecko.neocities.org/ | ./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
./tools/feed_generator.py ./articles/ https://mjestecko.neocities.org/ > ./html/feed.xml ./tools/feed_generator.py ./articles/ https://mjestecko.neocities.org > ./html/feed.xml

View File

@ -4,6 +4,7 @@
from sys import argv, exit from sys import argv, exit
import time, urllib.parse, re import time, urllib.parse, re
import os.path as path
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
@ -21,6 +22,7 @@ with open(argv[1], "r") as f:
i = the_line_after_metadata(content) i = the_line_after_metadata(content)
metadata = parse_metadata(argv[1]) metadata = parse_metadata(argv[1])
directory = path.split(path.dirname(path.abspath(argv[1])))[-1]
title = metadata.get("Title", "Oopsie, somebody forgot to name the article!") title = metadata.get("Title", "Oopsie, somebody forgot to name the article!")
article_head = "\n# " + title + "\n" article_head = "\n# " + title + "\n"
@ -46,10 +48,9 @@ if tags:
article_head += "---\n\n" article_head += "---\n\n"
# todo: Article namespace with related metadata.
header = f"""HTML header: <meta property="og:title" content="{title} on mjestečko"></meta> header = f"""HTML header: <meta property="og:title" content="{title} on mjestečko"></meta>
<meta property="og:type" content="article"></meta> <meta property="og:type" content="article"></meta>
<meta property="og:url" content="{argv[2]}/articles/{urllib.parse.quote(title)}.html"></meta> <meta property="og:url" content="{argv[2]}/articles/{urllib.parse.quote(directory)}.html"></meta>
""" """
if not brief is None: if not brief is None:
header += f"""<meta property="og:description" content="{brief}"></meta>\n""" header += f"""<meta property="og:description" content="{brief}"></meta>\n"""