diff options
| author | Volpeon <git@volpeon.ink> | 2021-12-17 15:23:34 +0100 |
|---|---|---|
| committer | Volpeon <git@volpeon.ink> | 2021-12-17 15:23:34 +0100 |
| commit | 5320823ae5775b1857ba232262cdeb06c4ffbb6b (patch) | |
| tree | 42d889c57c19603f1912eaa8cb2e4814af2106ae /scripts/subpages.lua | |
| parent | Added category for doodles (diff) | |
| download | volpeon.ink-5320823ae5775b1857ba232262cdeb06c4ffbb6b.tar.gz volpeon.ink-5320823ae5775b1857ba232262cdeb06c4ffbb6b.tar.bz2 volpeon.ink-5320823ae5775b1857ba232262cdeb06c4ffbb6b.zip | |
Use full image URLs in feeds
Diffstat (limited to 'scripts/subpages.lua')
| -rw-r--r-- | scripts/subpages.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/subpages.lua b/scripts/subpages.lua new file mode 100644 index 0000000..95f68f5 --- /dev/null +++ b/scripts/subpages.lua | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | local path = require 'pandoc.path' | ||
| 2 | |||
| 3 | local namespace = '' | ||
| 4 | local siteUrl = '' | ||
| 5 | |||
| 6 | function meta(meta) | ||
| 7 | namespace = pandoc.utils.stringify(meta.namespace) | ||
| 8 | siteUrl = pandoc.utils.stringify(meta.site.url):gsub("/$", "") | ||
| 9 | end | ||
| 10 | |||
| 11 | function image(el) | ||
| 12 | if path.is_relative(el.src) then el.src = siteUrl .. path.join({ namespace, el.src }) end | ||
| 13 | |||
| 14 | return el | ||
| 15 | end | ||
| 16 | |||
| 17 | function link(el) | ||
| 18 | if path.is_relative(el.target) then | ||
| 19 | el.target = siteUrl .. path.join({ namespace, el.target }) | ||
| 20 | end | ||
| 21 | |||
| 22 | return el | ||
| 23 | end | ||
| 24 | |||
| 25 | return { { Meta = meta }, { Image = image, Link = link } } | ||
