From 269433c6f84ce631d38fd7ffaed04ed3f7c2bf4f Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 20 Apr 2021 21:45:36 +0200 Subject: Support project previews --- scripts/build_content.sh | 1 + scripts/metadata_filter.lua | 10 +++++++--- scripts/watch_content.sh | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 83b6908..e627edc 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh @@ -82,6 +82,7 @@ get_subpages_metadata() { date: .date, \ last_update: .last_update, \ category: .category, \ + preview: .preview, \ content: \"$content\" \ } | del(.[] | nulls)") local title=$(echo "$metadata" | jq ".title") diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua index 499cf3e..21698bd 100644 --- a/scripts/metadata_filter.lua +++ b/scripts/metadata_filter.lua @@ -260,14 +260,18 @@ function Meta(meta) meta.file_out = get_file_out(meta.rewrites, meta.content_dir, meta.output_dir, meta.file_in) - if meta.relative_to == nil then - meta.relative_to = meta.file_in - end + if meta.relative_to == nil then meta.relative_to = meta.file_in end meta.relative_to_out = get_file_out(meta.rewrites, meta.content_dir, meta.output_dir, meta.relative_to) meta.url = resolve_url(meta.site.url, meta.output_dir, meta.relative_to_out, meta.file_out) + if meta.preview ~= nil then + meta.preview = pandoc.utils.stringify(meta.preview) + meta.preview = meta.file_out:gsub("/index%.html$", "/" .. meta.preview) + meta.preview = resolve_url(meta.site.url, meta.output_dir, + meta.relative_to_out, meta.preview) + end meta.date = format_date(meta.date) if meta.last_update ~= nil then diff --git a/scripts/watch_content.sh b/scripts/watch_content.sh index dfaa638..30f8a6c 100755 --- a/scripts/watch_content.sh +++ b/scripts/watch_content.sh @@ -7,7 +7,7 @@ inotifywait -qrme close_write,delete,move --format "%w%f" "${CONTENT_DIR%/}" \ do if [ -f "$file" ]; then # scripts/build_content.sh "single" "$file" - scripts/build_content.sh "all_md" + scripts/build_content.sh elif [ ! -d "$file" ]; then scripts/build_content.sh "delete" "$file" fi -- cgit v1.2.3-70-g09d2