Skip to content

Commit

Permalink
fix: do tags for drafts, just don't ALL_TAGS 'em
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinjasaur committed Jul 14, 2024
1 parent fa60875 commit 823973d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bic
Original file line number Diff line number Diff line change
Expand Up @@ -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

(
Expand All @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions tests/tags/drafts/3-my-draft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Draft
tags: draft

Words go here.
2 changes: 2 additions & 0 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 823973d

Please sign in to comment.