From 823973dbd881cfeef48f3b241bc7bee799a87320 Mon Sep 17 00:00:00 2001 From: Paul Esch-Laurent Date: Sat, 13 Jul 2024 20:52:57 -0500 Subject: [PATCH] fix: do tags for drafts, just don't ALL_TAGS 'em --- bic | 10 ++++++++-- tests/tags/drafts/3-my-draft.md | 4 ++++ tests/test.bats | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 tests/tags/drafts/3-my-draft.md diff --git a/bic b/bic index cb60769..284db6b 100755 --- a/bic +++ b/bic @@ -189,9 +189,14 @@ build_drafts() { for _draft in "${SRC_DIR}"/drafts/*.md; do log "Building draft: ${_draft}" ALL_DRAFTS+=("${_draft}") - local filename filename_sans_id + local filename filename_sans_id tags=() filename="$(basename "${_draft}")" filename_sans_id="$(echo "${filename}" | sed -E 's/^[0-9]+-//')" + for _tag in $(mk_tags "${_post}"); do + local slug + slug="$(mk_slug "${_tag}")" + tags+=("${slug}") + done mkdir -p "${DEST_DIR}"/drafts ( @@ -201,7 +206,8 @@ build_drafts() { date="$(mk_date "${_draft}")" slug="$(mk_slug "${filename_sans_id%.md}")" id="$(mk_id "${filename}" "${filename_sans_id}")" - export title body date slug id draft + [[ -n "${tags[*]}" ]] && has_tags=true + export title body date slug id draft has_tags mo \ "${SRC_DIR}"/entry.html \ > "${DEST_DIR}/drafts/${slug}.html" diff --git a/tests/tags/drafts/3-my-draft.md b/tests/tags/drafts/3-my-draft.md new file mode 100644 index 0000000..ed26c3b --- /dev/null +++ b/tests/tags/drafts/3-my-draft.md @@ -0,0 +1,4 @@ +# Draft +tags: draft + +Words go here. diff --git a/tests/test.bats b/tests/test.bats index 537ca5b..8f4d347 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -155,9 +155,11 @@ [[ "${status}" == 0 ]] [[ -f tests/tags/build/tags.html ]] [[ -f tests/tags/build/tags/one.html ]] + [[ ! -f tests/tags/build/tags/draft.html ]] run cat tests/tags/build/sitemap.xml [[ "${output}" == *"tags"* ]] [[ "${output}" == *"tags/one"* ]] + [[ "${output}" != *"tags/draft"* ]] run cat tests/tags/build/test.html [[ "${output}" == *"has_tags defined"* ]] rm -rf tests/tags/build