diff options
Merge branch 'dunbar-rewrite' into 'master'
feat!: Convert from Markdown to dunbar
See merge request Syndamia/syndamiadotcom!16
1 files changed, 45 insertions, 0 deletions
| -rw-r--r-- | meta/meta.awk | 45 |
diff --git a/meta/meta.awk b/meta/meta.awk new file mode 100644 index 0000000..f586fef --- /dev/null +++ b/meta/meta.awk @@ -0,0 +1,45 @@ +BEGIN { + FS="\t" + while ((getline < ENVIRON["META"]) > 0) { + if ($1 == "") continue + meta_title[$1] = $2 " \\— Syndamia" + meta_description[$1] = $3 + } + FS=" " + + HEADER = getfile(ENVIRON["HEADER"]) + FOOTER = getfile(ENVIRON["FOOTER"]) + + sitemap = ENVIRON["DST"] "/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["DST"]) + 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["DST"]) + 1) "</loc><lastmod>" date "</lastmod><priority>1.0</priority></url>" > sitemap + } + + print "</urlset>" > sitemap +} + +function getfile(filename, status, linebuf, filebuf) { + while ((status = getline linebuf < filename) > 0) + filebuf = filebuf linebuf ORS + close(filename) + sub(ORS "$", "", filebuf) + return filebuf +} |