Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: ✨ add typora-root-url and improve task file to generate code fi…
…le directly
  • Loading branch information
sheldonhull committed May 27, 2021
1 parent a680c4a commit 54aa71d
Show file tree
Hide file tree
Showing 301 changed files with 1,740 additions and 236 deletions.
17 changes: 17 additions & 0 deletions .bhugo
@@ -0,0 +1,17 @@
# Required - substitute your username and Hugo site directory.
# https://github.com/Zach-Johnson/bhugo
DATABASE="/Users/sheldonhull/Library/Group Containers/9K33E3U3T4.net.shinyfrog.bear/Application Data/database.sqlite"
HUGO_DIR=/Users/sheldonhull/git/sheldonhull/sheldonhull.hugo

# Optional - defaults listed below

IMAGE_DIR=/images/
INTERVAL=1s
CATEGORIES=false
TAGS=true

# Use for docs or blog posts
CONTENT_DIR=content/docs
NOTE_TAG=docs
# CONTENT_DIR=content/blog
# NOTE_TAG=blog
3 changes: 3 additions & 0 deletions .code-config
@@ -0,0 +1,3 @@
COUNTER=38
ROUND=1
LANGUAGE=go
84 changes: 57 additions & 27 deletions Taskfile.yml
Expand Up @@ -39,6 +39,8 @@ vars:
white: \033[:1;37m
nocolor: \u001b[0m
reversed: \u001b[7m
CODE_CONFIG: .code-config

tasks:
default:
cmds:
Expand Down Expand Up @@ -166,12 +168,22 @@ tasks:
echo -e "{{ .dark_gray }} creating new file: $filename {{ .nocolor }}"
hugo new $filename --kind blog
echo -e "{{ .green }} ✅ created: $filename {{ .nocolor }}"
microblog:
desc: Create a new microblog post
cmds:
100daysofcode_readconfig:
desc: read the counter values for 100 days of code to simplify creation from archetype
cmds:
- |
source {{ .CODE_CONFIG }}
echo -e "{{.light_gray}}=== ℹ {{ .reversed }} 100 Days Of Code Config from: [{{ .CODE_CONFIG}}] {{ .nocolor }} === "
echo -e "{{.light_gray}}LANGUAGE {{.nocolor}}: {{ .orange}} $LANGUAGE {{ .nocolor }}"
echo -e "{{.light_gray}}ROUND {{.nocolor}}: {{ .orange}} $ROUND {{ .nocolor }}"
echo -e "{{.light_gray}}COUNTER {{.nocolor}}: {{ .orange}} $COUNTER {{ .nocolor }}"
post:
desc: Create a new post
cmds:
- task: 100daysofcode_readconfig
- |
echo -e "{{.light_gray}}=== ℹ {{ .reversed }} Variable Info from Task {{ .nocolor }} === "
echo -e "{{.light_gray}}TODAY_UTC {{.nocolor}}: {{ .orange}}{{ .TODAY_UTC }} {{ .nocolor }}"
echo -e "{{.light_gray}}TODAY_UTC {{.nocolor}}: {{ .orange}}{{ .TODAY_UTC }} {{ .nocolor }}"
echo -e "{{.green}}Please enter title{{ .nocolor }}"
read;
echo -e "{{.green}}Title: ${REPLY}{{ .nocolor }}"
Expand All @@ -180,29 +192,47 @@ tasks:
| sed 's/[[:space:]]*//g' \
| tr '[:upper:]' '[:lower:]'
)
directory=./content/microblog/
mkdir -p $directory/{{ .YEAR }} || echo -e "{{.dark_gray}}🔄 skipped creation of directory [$directory] per already exists {{.nocolor}}"
filename=$directory/{{ .YEAR }}/{{ .YEAR }}-{{ .MONTH }}-{{ .DAY }}-$title.md
echo -e "{{ .dark_gray }} creating new file: $filename {{ .nocolor }}"
hugo new $filename --kind microblog
echo -e "{{ .green }} ✅ created: $filename {{ .nocolor }}"
code:
desc: Create a new 100DaysOfCode post
cmds:
- |
echo -e "{{.light_gray}}=== ℹ {{ .reversed }} Variable Info from Task {{ .nocolor }} === "
echo -e "{{.light_gray}}TODAY_UTC {{.nocolor}}: {{ .orange}}{{ .TODAY_UTC }} {{ .nocolor }}"
echo -e "{{.green}}Please enter title{{ .nocolor }}"
echo -e "{{.green}}Please enter [blog, microblog, code] for archetype{{ .nocolor }}"
read;
echo -e "{{.green}}Title: ${REPLY}{{ .nocolor }}"
title=$(echo ${REPLY} \
| sed 's/\(.\)\([A-Z]\)/\1-\2/g' \
| sed 's/[[:space:]]*//g' \
| tr '[:upper:]' '[:lower:]'
)
directory=./content/microblog/
archetype=$(echo ${REPLY})
directory=./content/posts/
mkdir -p $directory/{{ .YEAR }} || echo -e "{{.dark_gray}}🔄 skipped creation of directory [$directory] per already exists {{.nocolor}}"
filename=$directory/{{ .YEAR }}/{{ .YEAR }}-{{ .MONTH }}-{{ .DAY }}-$title.md
filename=$directory{{ .YEAR }}/{{ .YEAR }}-{{ .MONTH }}-{{ .DAY }}-$title.md
if [[ $archetype == "code" ]];
then
source {{ .CODE_CONFIG }}
echo -e "{{.light_gray}}=== ℹ {{ .reversed }} 100 Days Of Code Config from: [{{ .CODE_CONFIG}}] {{ .nocolor }} === "
echo -e "{{.light_gray}}LANGUAGE {{.nocolor}}: {{ .orange}} $LANGUAGE {{ .nocolor }}"
echo -e "{{.light_gray}}ROUND {{.nocolor}}: {{ .orange}} $ROUND {{ .nocolor }}"
echo -e "{{.light_gray}}COUNTER {{.nocolor}}: {{ .orange}} $COUNTER {{ .nocolor }}"
UPDATED_COUNTER=$(($COUNTER+1))
TARGET_KEY=COUNTER
REPLACEMENT_VALUE=$UPDATED_COUNTER
sed -i '' "s/\($TARGET_KEY *= *\).*/\1$REPLACEMENT_VALUE/" "{{ .CODE_CONFIG }}"
echo -e "{{.green}} 💾 updated code config with new counter: from [$COUNTER] to [$UPDATED_COUNTER] (saved in {{ .CODE_CONFIG }}){{ .nocolor }}"
echo -e "{{.dark_gray}} ℹ override filename with 100days of code naming convention{{ .nocolor }}"
filename=$directory/{{ .YEAR }}/{{ .YEAR }}-{{ .MONTH }}-{{ .DAY }}-$LANGUAGE-R$ROUND-day-$UPDATED_COUNTER.md
hugo new $filename --kind $archetype
# Replace the counter in the text file
sed -i '' "s/VAR_LANGUAGE/$LANGUAGE/g" "$filename"
sed -i '' "s/VAR_ROUND/$ROUND/g" "$filename"
sed -i '' "s/VAR_DAYCOUNTER/$UPDATED_COUNTER/g" "$filename"
echo -e "{{.dark_gray}} 💾 update VAR_DAYCOUNTER,VAR_LANGUAGE,VAR_DAY_COUNTER in output file{{ .nocolor }}"
else
hugo new $filename --kind $archetype
fi
echo -e "{{ .dark_gray }} creating new file: $filename {{ .nocolor }}"
hugo new $filename --kind 100DaysOfCode
echo -e "{{ .green }} ✅ created: $filename {{ .nocolor }}"
echo -e "{{ .green }} ✅ created [ $archetype ] at: [ $filename ] {{ .nocolor }}"
bear:
desc: Run bhugo to sync posts
cmds:
- |
echo -e "{{.light_gray}}=== ℹ {{ .reversed }} Running Bear Hugo {{ .nocolor }} === "
go get -u github.com/Zach-Johnson/bhugo
bhugo
preconditions:
- test -f .bhugo
# TODO: Add task for imageoptim preprocessing on staged files only
2 changes: 2 additions & 0 deletions archetypes/blog.md
Expand Up @@ -15,6 +15,8 @@ tags:
draft: true
toc: true
# images: [/images/]
typora-root-url: ../../../static
typora-copy-images-to: ../../../static/images
---

## Header
8 changes: 5 additions & 3 deletions archetypes/100DaysOfCode.md → archetypes/code.md
Expand Up @@ -4,16 +4,18 @@
date: {{ .Date }}
title: {{ replace $TitleWithoutDate "-" " " | title }}
slug: {{ replace $TitleWithoutDate " " "-" | lower }}
area: go
round: 1
area: VAR_LANGUAGE
round: VAR_ROUND
day_counter: VAR_DAYCOUNTER
tags:
- tech
- development
- 100DaysOfCode
- golang
- microblog
# images: [/images/r1-dVAR_DAYCOUNTERIMAGE.png]
# images: [/images/r1-dVAR_DAYCOUNTER-IMAGE.png]
typora-root-url: ../../../static
typora-copy-images-to: ../../../static/images
---

## progress
Expand Down
2 changes: 2 additions & 0 deletions archetypes/microblog.md
Expand Up @@ -9,4 +9,6 @@ tags:
- development
- microblog
# images: [/images/]
typora-root-url: ../../../static
typora-copy-images-to: ../../../static/images
---
110 changes: 0 additions & 110 deletions content/docs/git.md

This file was deleted.

0 comments on commit 54aa71d

Please sign in to comment.