Skip to content

Commit

Permalink
feat: draft and post keys for respective files
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinjasaur committed Feb 22, 2022
1 parent de1a928 commit ccf8bbf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
38 changes: 20 additions & 18 deletions bic
Original file line number Diff line number Diff line change
Expand Up @@ -125,52 +125,54 @@ build_pages() {
build_posts() {
[[ ! -d "${SRC_DIR}"/posts || ! -f "${SRC_DIR}"/entry.html ]] && return
ALL_POSTS=()
for post in "${SRC_DIR}"/posts/*.md; do
log "Building post: ${post}"
ALL_POSTS+=("${post}")
for _post in "${SRC_DIR}"/posts/*.md; do
log "Building post: ${_post}"
ALL_POSTS+=("${_post}")
local filename filename_sans_id
filename="$(basename "${post}")"
filename="$(basename "${_post}")"
filename_sans_id="$(echo "${filename}" | sed -E 's/^[0-9]+-//')"

(
title="$(mk_title "${post}")"
body="$(mk_body "${post}")"
date="$(mk_date "${post}")"
post=true
title="$(mk_title "${_post}")"
body="$(mk_body "${_post}")"
date="$(mk_date "${_post}")"
slug="$(mk_slug "${filename_sans_id%.md}")"
id="$(mk_id "${filename}" "${filename_sans_id}")"
export title body date slug id
export title body date slug id post
mo \
"${SRC_DIR}"/entry.html \
> "${DEST_DIR}/${slug}.html"
)
done
unset post
unset _post
}

build_drafts() {
[[ ! -d "${SRC_DIR}"/drafts || ! -f "${SRC_DIR}"/entry.html ]] && return
ALL_DRAFTS=()
for draft in "${SRC_DIR}"/drafts/*.md; do
log "Building draft: ${draft}"
ALL_DRAFTS+=("${draft}")
for _draft in "${SRC_DIR}"/drafts/*.md; do
log "Building draft: ${_draft}"
ALL_DRAFTS+=("${_draft}")
local filename filename_sans_id
filename="$(basename "${draft}")"
filename="$(basename "${_draft}")"
filename_sans_id="$(echo "${filename}" | sed -E 's/^[0-9]+-//')"
mkdir -p "${DEST_DIR}"/drafts

(
title="$(mk_title "${draft}")"
body="$(mk_body "${draft}")"
date="$(mk_date "${draft}")"
draft=true
title="$(mk_title "${_draft}")"
body="$(mk_body "${_draft}")"
date="$(mk_date "${_draft}")"
slug="$(mk_slug "${filename_sans_id%.md}")"
id="$(mk_id "${filename}" "${filename_sans_id}")"
export title body date slug id
export title body date slug id draft
mo \
"${SRC_DIR}"/entry.html \
> "${DEST_DIR}/drafts/${slug}.html"
)
done
unset draft
unset _draft
}

build_index() {
Expand Down
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ Some specific keys used within entries (posts or drafts) and pages:
- `id`, the number prefix for an entry encoded with [Hashids]
- `body`, converted Markdown to HTML contents (sans title)

Drafts will have a `draft` key set. Likewise, posts will have a `post` key set.

Each entry in `posts/*.md` or `drafts/*.md` is rendered against an `entry.html`.

Each page in `pages/*.md` is rendered against a `page.html`.
Expand Down

0 comments on commit ccf8bbf

Please sign in to comment.