-
Notifications
You must be signed in to change notification settings - Fork 9
DraftDir + manage accent for slug() #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,9 @@ readonly POST_DIR=post | |
| # OUTPUT_DIR stores all compiled html | ||
| readonly OUTPUT_DIR=out | ||
|
|
||
| # DRAFT_DIR stores all compiled html | ||
| readonly DRAFT_DIR=draft | ||
|
|
||
| # LAYOUT_DIR stores all layout markdown files | ||
| readonly LAYOUT_DIR=layout | ||
|
|
||
|
|
@@ -56,7 +59,7 @@ body() { | |
|
|
||
| # slug creates a friendly URL like 'hello-world' | ||
| slug() { | ||
| tr -cs '[:alnum:]\n' - | tr '[:upper:]' '[:lower:]' | sed 's|^-*||;s|-*$||' | ||
| iconv -f utf8 -t ascii//TRANSLIT | tr -cs '[:alnum:]\n' - | tr '[:upper:]' '[:lower:]' | sed 's|^-*||;s|-*$||' | ||
| } | ||
|
|
||
| # | ||
|
|
@@ -279,19 +282,25 @@ usage() { | |
|
|
||
| case "$1" in | ||
| bake) | ||
| rm -rf "$DRAFT_DIR" | ||
| mkdir -p "$DRAFT_DIR" | ||
| rm -rf "$OUTPUT_DIR" | ||
| mkdir -p "$OUTPUT_DIR" | ||
|
|
||
| [[ -d "$POST_DIR" ]] || usage | ||
| [[ -d "$PUBLIC_DIR" ]] && cp -r "$PUBLIC_DIR"/. "$OUTPUT_DIR" | ||
| [[ -d "$PUBLIC_DIR" ]] && cp -r "$PUBLIC_DIR"/. "$DRAFT_DIR" | ||
| touch "$DRAFT_DIR/index.html" | ||
|
|
||
| readarray -t posts < <(find "$POST_DIR" -name '*.md' | sort -r) | ||
|
|
||
| idx=0 | ||
| time for post in "${posts[@]}"; do | ||
| id="$(basename "$post" .md)" | ||
| # skip drafts | ||
| [[ "$(header draft < "$post")" == false ]] || continue | ||
| if [ "$(header draft < "$post")" != false ]; then | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't it be slower ? |
||
| render_file "$post" > "$DRAFT_DIR/$id.html"; continue; | ||
| fi | ||
|
|
||
| echo "$id" | ||
| render_file "$post" > "$OUTPUT_DIR/$id.html" & | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simply merge all rm and mkdir together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in commit 563a6ab