Skip to content

Commit 23a8810

Browse files
committed
feat: ✨ add typora-root-url and improve task file to generate code file directly
1 parent 95db6d5 commit 23a8810

File tree

301 files changed

+1740
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

301 files changed

+1740
-236
lines changed

.bhugo

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Required - substitute your username and Hugo site directory.
2+
# https://github.com/Zach-Johnson/bhugo
3+
DATABASE="/Users/sheldonhull/Library/Group Containers/9K33E3U3T4.net.shinyfrog.bear/Application Data/database.sqlite"
4+
HUGO_DIR=/Users/sheldonhull/git/sheldonhull/sheldonhull.hugo
5+
6+
# Optional - defaults listed below
7+
8+
IMAGE_DIR=/images/
9+
INTERVAL=1s
10+
CATEGORIES=false
11+
TAGS=true
12+
13+
# Use for docs or blog posts
14+
CONTENT_DIR=content/docs
15+
NOTE_TAG=docs
16+
# CONTENT_DIR=content/blog
17+
# NOTE_TAG=blog

.code-config

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
COUNTER=38
2+
ROUND=1
3+
LANGUAGE=go

Taskfile.yml

+57-27
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ vars:
3939
white: \033[:1;37m
4040
nocolor: \u001b[0m
4141
reversed: \u001b[7m
42+
CODE_CONFIG: .code-config
43+
4244
tasks:
4345
default:
4446
cmds:
@@ -166,12 +168,22 @@ tasks:
166168
echo -e "{{ .dark_gray }} creating new file: $filename {{ .nocolor }}"
167169
hugo new $filename --kind blog
168170
echo -e "{{ .green }} ✅ created: $filename {{ .nocolor }}"
169-
microblog:
170-
desc: Create a new microblog post
171-
cmds:
171+
100daysofcode_readconfig:
172+
desc: read the counter values for 100 days of code to simplify creation from archetype
173+
cmds:
174+
- |
175+
source {{ .CODE_CONFIG }}
176+
echo -e "{{.light_gray}}=== ℹ {{ .reversed }} 100 Days Of Code Config from: [{{ .CODE_CONFIG}}] {{ .nocolor }} === "
177+
echo -e "{{.light_gray}}LANGUAGE {{.nocolor}}: {{ .orange}} $LANGUAGE {{ .nocolor }}"
178+
echo -e "{{.light_gray}}ROUND {{.nocolor}}: {{ .orange}} $ROUND {{ .nocolor }}"
179+
echo -e "{{.light_gray}}COUNTER {{.nocolor}}: {{ .orange}} $COUNTER {{ .nocolor }}"
180+
post:
181+
desc: Create a new post
182+
cmds:
183+
- task: 100daysofcode_readconfig
172184
- |
173185
echo -e "{{.light_gray}}=== ℹ {{ .reversed }} Variable Info from Task {{ .nocolor }} === "
174-
echo -e "{{.light_gray}}TODAY_UTC {{.nocolor}}: {{ .orange}}{{ .TODAY_UTC }} {{ .nocolor }}"
186+
echo -e "{{.light_gray}}TODAY_UTC {{.nocolor}}: {{ .orange}}{{ .TODAY_UTC }} {{ .nocolor }}"
175187
echo -e "{{.green}}Please enter title{{ .nocolor }}"
176188
read;
177189
echo -e "{{.green}}Title: ${REPLY}{{ .nocolor }}"
@@ -180,29 +192,47 @@ tasks:
180192
| sed 's/[[:space:]]*//g' \
181193
| tr '[:upper:]' '[:lower:]'
182194
)
183-
directory=./content/microblog/
184-
mkdir -p $directory/{{ .YEAR }} || echo -e "{{.dark_gray}}🔄 skipped creation of directory [$directory] per already exists {{.nocolor}}"
185-
filename=$directory/{{ .YEAR }}/{{ .YEAR }}-{{ .MONTH }}-{{ .DAY }}-$title.md
186-
echo -e "{{ .dark_gray }} creating new file: $filename {{ .nocolor }}"
187-
hugo new $filename --kind microblog
188-
echo -e "{{ .green }} ✅ created: $filename {{ .nocolor }}"
189-
code:
190-
desc: Create a new 100DaysOfCode post
191-
cmds:
192-
- |
193-
echo -e "{{.light_gray}}=== ℹ {{ .reversed }} Variable Info from Task {{ .nocolor }} === "
194-
echo -e "{{.light_gray}}TODAY_UTC {{.nocolor}}: {{ .orange}}{{ .TODAY_UTC }} {{ .nocolor }}"
195-
echo -e "{{.green}}Please enter title{{ .nocolor }}"
195+
echo -e "{{.green}}Please enter [blog, microblog, code] for archetype{{ .nocolor }}"
196196
read;
197-
echo -e "{{.green}}Title: ${REPLY}{{ .nocolor }}"
198-
title=$(echo ${REPLY} \
199-
| sed 's/\(.\)\([A-Z]\)/\1-\2/g' \
200-
| sed 's/[[:space:]]*//g' \
201-
| tr '[:upper:]' '[:lower:]'
202-
)
203-
directory=./content/microblog/
197+
archetype=$(echo ${REPLY})
198+
199+
directory=./content/posts/
204200
mkdir -p $directory/{{ .YEAR }} || echo -e "{{.dark_gray}}🔄 skipped creation of directory [$directory] per already exists {{.nocolor}}"
205-
filename=$directory/{{ .YEAR }}/{{ .YEAR }}-{{ .MONTH }}-{{ .DAY }}-$title.md
201+
filename=$directory{{ .YEAR }}/{{ .YEAR }}-{{ .MONTH }}-{{ .DAY }}-$title.md
202+
203+
if [[ $archetype == "code" ]];
204+
then
205+
source {{ .CODE_CONFIG }}
206+
echo -e "{{.light_gray}}=== ℹ {{ .reversed }} 100 Days Of Code Config from: [{{ .CODE_CONFIG}}] {{ .nocolor }} === "
207+
echo -e "{{.light_gray}}LANGUAGE {{.nocolor}}: {{ .orange}} $LANGUAGE {{ .nocolor }}"
208+
echo -e "{{.light_gray}}ROUND {{.nocolor}}: {{ .orange}} $ROUND {{ .nocolor }}"
209+
echo -e "{{.light_gray}}COUNTER {{.nocolor}}: {{ .orange}} $COUNTER {{ .nocolor }}"
210+
UPDATED_COUNTER=$(($COUNTER+1))
211+
TARGET_KEY=COUNTER
212+
REPLACEMENT_VALUE=$UPDATED_COUNTER
213+
sed -i '' "s/\($TARGET_KEY *= *\).*/\1$REPLACEMENT_VALUE/" "{{ .CODE_CONFIG }}"
214+
echo -e "{{.green}} 💾 updated code config with new counter: from [$COUNTER] to [$UPDATED_COUNTER] (saved in {{ .CODE_CONFIG }}){{ .nocolor }}"
215+
echo -e "{{.dark_gray}} ℹ override filename with 100days of code naming convention{{ .nocolor }}"
216+
filename=$directory/{{ .YEAR }}/{{ .YEAR }}-{{ .MONTH }}-{{ .DAY }}-$LANGUAGE-R$ROUND-day-$UPDATED_COUNTER.md
217+
hugo new $filename --kind $archetype
218+
219+
# Replace the counter in the text file
220+
sed -i '' "s/VAR_LANGUAGE/$LANGUAGE/g" "$filename"
221+
sed -i '' "s/VAR_ROUND/$ROUND/g" "$filename"
222+
sed -i '' "s/VAR_DAYCOUNTER/$UPDATED_COUNTER/g" "$filename"
223+
echo -e "{{.dark_gray}} 💾 update VAR_DAYCOUNTER,VAR_LANGUAGE,VAR_DAY_COUNTER in output file{{ .nocolor }}"
224+
else
225+
hugo new $filename --kind $archetype
226+
fi
206227
echo -e "{{ .dark_gray }} creating new file: $filename {{ .nocolor }}"
207-
hugo new $filename --kind 100DaysOfCode
208-
echo -e "{{ .green }} ✅ created: $filename {{ .nocolor }}"
228+
echo -e "{{ .green }} ✅ created [ $archetype ] at: [ $filename ] {{ .nocolor }}"
229+
bear:
230+
desc: Run bhugo to sync posts
231+
cmds:
232+
- |
233+
echo -e "{{.light_gray}}=== ℹ {{ .reversed }} Running Bear Hugo {{ .nocolor }} === "
234+
go get -u github.com/Zach-Johnson/bhugo
235+
bhugo
236+
preconditions:
237+
- test -f .bhugo
238+
# TODO: Add task for imageoptim preprocessing on staged files only

archetypes/blog.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ tags:
1515
draft: true
1616
toc: true
1717
# images: [/images/]
18+
typora-root-url: ../../../static
19+
typora-copy-images-to: ../../../static/images
1820
---
1921

2022
## Header

archetypes/100DaysOfCode.md archetypes/code.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
date: {{ .Date }}
55
title: {{ replace $TitleWithoutDate "-" " " | title }}
66
slug: {{ replace $TitleWithoutDate " " "-" | lower }}
7-
area: go
8-
round: 1
7+
area: VAR_LANGUAGE
8+
round: VAR_ROUND
99
day_counter: VAR_DAYCOUNTER
1010
tags:
1111
- tech
1212
- development
1313
- 100DaysOfCode
1414
- golang
1515
- microblog
16-
# images: [/images/r1-dVAR_DAYCOUNTERIMAGE.png]
16+
# images: [/images/r1-dVAR_DAYCOUNTER-IMAGE.png]
17+
typora-root-url: ../../../static
18+
typora-copy-images-to: ../../../static/images
1719
---
1820

1921
## progress

archetypes/microblog.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ tags:
99
- development
1010
- microblog
1111
# images: [/images/]
12+
typora-root-url: ../../../static
13+
typora-copy-images-to: ../../../static/images
1214
---

content/docs/git.md

-110
This file was deleted.

0 commit comments

Comments
 (0)