aboutsummaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorJefferson Julio <[email protected]>2021-05-30 22:53:32 -0300
committerJefferson Julio <[email protected]>2021-05-30 22:53:32 -0300
commit381bff129b70471e86e99a2d6b6a7e090f13287e (patch)
tree35d383b4ec622efd8fbbd49a72c44a5561a04f92 /pages
parente9c35a9eff9e0881df7d6a6e8d17b70ac37ad0fe (diff)
downloadblog.sh-381bff129b70471e86e99a2d6b6a7e090f13287e.tar.bz2
blog.sh-381bff129b70471e86e99a2d6b6a7e090f13287e.zip
Better article parsing, support for article code parsing (add line numbers to code blocks)
Diffstat (limited to 'pages')
-rwxr-xr-xpages/article.sh2
-rwxr-xr-xpages/home.sh15
2 files changed, 14 insertions, 3 deletions
diff --git a/pages/article.sh b/pages/article.sh
index b50d922..59a33b6 100755
--- a/pages/article.sh
+++ b/pages/article.sh
@@ -14,7 +14,7 @@ cat <<ARTICLE
<article class="container">
<section>
<div class="post-header">
- <h4 class="post-title">$ stat -c "%s %w %z" \\ <br/> &gt;&ensp;$ARTICLE_FILE</h4>
+ <h4 class="post-title">$ stat -c "%s %w %z" \\ <br/> &gt;&ensp;$ARTICLE_FILE_SANITIZED</h4>
<small>$ARTICLE_BYTES</small> <br/>
<time>$ARTICLE_TIME</time> <br/>
diff --git a/pages/home.sh b/pages/home.sh
index c9a9966..02adf53 100755
--- a/pages/home.sh
+++ b/pages/home.sh
@@ -13,8 +13,19 @@ WELCOME
print-all-articles () {
# Find all articles and sort by date of creation
- for i in $(find $ARTICLES_PATH -type f -name '*.txt' -printf "%T@ %p\n" | sort -rn | cut -b 23-); do
- ARTICLE_FILE="${i/* /}" source $SCRIPT_DIR/components/post-preview.sh
+ IFS=';' read -ra ARTICLE_LIST <<< "$(
+ find $ARTICLES_PATH \
+ -type f \
+ -name '*.txt' \
+ -printf "%T@ %p\n" |
+ sort -rn |
+ cut -b 23- |
+ sed 's/^ //g' |
+ tr '\n' ';'
+ )"
+
+ for i in "${ARTICLE_LIST[@]}"; do
+ ARTICLE_FILE="$i" source $SCRIPT_DIR/components/post-preview.sh
done
}