new commit

This commit is contained in:
2023-09-02 20:22:34 -05:00
parent a69b5d3904
commit d15176f5e6
7 changed files with 360 additions and 7 deletions

View File

@@ -1,15 +1,14 @@
#!/usr/bin/bash
function get_blog_pages () {
## The blog/project dir
local BLOG_DIR=~/Blog
## Getting the variable to set the list to externally
local VAR_NAME="${1:?"get_blog_pages : No variable was provided to lod the pages into"}"
local -n VAR="$VAR_NAME"
## Setting the list to the available blog files.
VAR=( $(ls $BLOG_DIR/blog/????-??-??.wiki) )
if ls -1 $BLOG_DIR/*.wiki >/dev/null 2>&1; then
VAR=( $(ls -1 $BLOG_DIR/*.wiki | grep -v 'index.wiki' ) )
fi
}

View File

@@ -1,9 +1,9 @@
#!/usr/bin/bash
function generate_blog_post () {
include blog-page
## Loading in required functions
local BLOG_PAGE=~/Blog/utils/libs/blog-page.sh
local BLOG_DIR=~/Blog/blog
[[ -f $BLOG_PAGE ]] && . $BLOG_PAGE
local PAGE_TITLE="${1:?"generate_blog_post : Page Title was not provided"}"
@@ -25,7 +25,7 @@ function generate_blog_post () {
---------------------------
`
TITLES=""
TITLES="[[index.wiki|Index]]"
for page in ${last_few_posts[@]}; do
read JUNK TITLE <<< "$( grep '%title' $page )"
TITLES="${TITLES} [[$page|$TITLE]]"
@@ -40,3 +40,28 @@ EOF
return 0
}
function generate_index () {
local -a blog_files
local OUTPUT=$BLOG_DIR/index.wiki
local TITLE DATE JUNK FILENAME
include blog-page
get_blog_pages blog_files
cat >$OUTPUT <<EOF
%title Blog Index
`
for file in ${blog_files[@]}; do
read JUNK TITLE <<< "$( grep '%title' $file )"
FILENAME="$(basename $file)"
DATE="$(grep -i 'date:' $file | grep -Eo '[0-9]{4}/[0-9]{2}/[0-9]{2}')"
echo "[[$FILENAME|$TITLE ($DATE)]]"
done
`
EOF
}