diff options
| Commit | e97af60a826212f4fa5cc50e950401162b1e34d5 (patch) | |
|---|---|---|
| Author | 2025-08-18 19:45:37 +0300 | |
| Committer | 2025-08-18 19:45:37 +0300 | |
| Files | 369e7ecf99178ab71b4994175d08b974df79bb68 | |
| syndamia.com-e97af60a826212f4fa5cc50e950401162b1e34d5.tar syndamia.com-e97af60a826212f4fa5cc50e950401162b1e34d5.tar.gz syndamia.com-e97af60a826212f4fa5cc50e950401162b1e34d5.zip | ||
| Parent | 594b2cb3aa351a04064ea1f2ca62ad99318fd423 (diff) | |
feat(meta): Generate sitemap
2 files changed, 17 insertions, 2 deletions
| -rwxr-xr-x | generate.sh | 5 | ||||
| -rw-r--r-- | meta/meta.awk | 14 |
diff --git a/generate.sh b/generate.sh index 10ead82..6d92ce0 100755 --- a/generate.sh +++ b/generate.sh @@ -2,6 +2,7 @@ : ${SRC:=$PWD/src} : ${GEN_DIR:=./website} +: ${URL:=https://syndamia.com} : ${HEADER:=$PWD/meta/header.html} : ${FOOTER:=$PWD/meta/footer.html} : ${META:=$PWD/meta/meta.tsv} @@ -29,7 +30,7 @@ EOF cp -a "$SRC/." "$GEN_DIR" AWK="mawk" - export HEADER FOOTER META GEN_DIR AWK + export HEADER FOOTER META GEN_DIR AWK URL /usr/bin/env dash ./dunbar/dunbar_awk/dunbar.sh html \ -i \ @@ -38,7 +39,7 @@ EOF $(find "$GEN_DIR" -type f -name "*.du") # }}} # 2. Meta handling {{{ - mawk -f ./meta/meta.awk $(find "$GEN_DIR" -type f -name "*.html") + mawk -f ./meta/meta.awk -v date="$(date +%Y-%m-%d)" $(find "$GEN_DIR" -type f -name "*.html") # }}} # 2. Tiny version, strip away styles and other stuff {{{ # TODO diff --git a/meta/meta.awk b/meta/meta.awk index b1023c2..3f416f1 100644 --- a/meta/meta.awk +++ b/meta/meta.awk @@ -12,16 +12,30 @@ BEGIN { HEADER = getfile(ENVIRON["HEADER"]) FOOTER = getfile(ENVIRON["FOOTER"]) + sitemap = ENVIRON["GEN_DIR"] "/sitemap.xml" + print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ORS \ + "<urlset" ORS \ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" ORS \ + "xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9" ORS \ + "http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\"" ORS \ + "xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">" > sitemap + for (i = ARGC; i > 0; --i) { if (!ARGV[i]) continue + #-- Add header and footer --# start = HEADER FILENAME = substr(ARGV[i], length(ENVIRON["GEN_DIR"]) + 2) gsub(/\$TITLE/, meta_title[FILENAME], start) gsub(/\$DESCRIPTION/, meta_description[FILENAME], start) print start getfile(ARGV[i]) FOOTER > ARGV[i] + + #-- Add to sitemap --# + print "<url><loc>" ENVIRON["URL"] substr(ARGV[i], length(ENVIRON["GEN_DIR"]) + 1) "</loc><lastmod>" date "</lastmod><priority>1.0</priority></url>" > sitemap } + + print "</urlset>" > sitemap } function getfile(filename, status, linebuf, filebuf) { |