Skip to content

Commit

Permalink
Merge pull request #17 from hmngwy/bugfix/tag-slugs
Browse files Browse the repository at this point in the history
Re-use generated slugs for tag posts
  • Loading branch information
hmngwy authored Jul 24, 2018
2 parents e9e06a4 + 896fcaf commit 282634c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions bin/jenny
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if source_blogrc; then
;;
n) # Ignore the .bloglock file when building
echo "$T Ignoring $BLOG_LOCK"
BLOG_LOCK=/dev/null
BLOG_LOCK_IGNORE=1
;;
c) # Empty out the build folder prior to building
echo "$T Cleaning $DIST"
Expand Down Expand Up @@ -161,11 +161,11 @@ begin () {
fi

local content_sum=$(cat "$f" | $SUM | cut -d ' ' -f 1)
local filename_sum=$(echo "$f" | $SUM | cut -d ' ' -f 1)
local filename_sum=$(echo "$full_file_name" | $SUM | cut -d ' ' -f 1)

echo "$T$full_file_name"
forRendering=false
if is_new "$filename_sum"; then
if is_new "$filename_sum" && [ ! -z $BLOG_LOCK_IGNORE ]; then
forRendering=true
echo "$T + /post/$slug.html"
echo "$slug $filename_sum $content_sum" >> $BLOG_LOCK
Expand Down Expand Up @@ -216,6 +216,7 @@ fileList=(*.md)

# Start generation
_DIST=$DIST begin "${fileList[@]}"
BLOG_LOCK=$(pwd)/.bloglock

# Now generate indexes for tags
OIFS="$IFS"
Expand Down
11 changes: 10 additions & 1 deletion share/jenny/lib/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ function get_filename() {

function get_slug() {
local slug=$(echo $(get_filename "$1") | rev | cut -d ' ' -f 1 | rev)
local filename_sum=$(echo "$f" | $SUM | cut -d ' ' -f 1)
local filename_sum=$(get_full_filename "$1" | $SUM | cut -d ' ' -f 1)

if [ ! -z $_TAGNAME ]; then
local match=$($GREP " $filename_sum " $BLOG_LOCK)
if [ $? -eq 0 ]; then
echo $match | cut -d " " -f 1
exit 0
fi
fi

$GREP "^$slug " $BLOG_LOCK > /dev/null
if [ $? -eq 0 ]; then
# slug exists
Expand Down

0 comments on commit 282634c

Please sign in to comment.