generate articles with makefile

This commit is contained in:
Malin Freeborn 2025-02-11 13:06:37 +01:00
parent bbd34e24ec
commit b7729e5712
Signed by: andonome
GPG Key ID: 52295D2377F4D70F
2 changed files with 10 additions and 27 deletions

View File

@ -22,6 +22,16 @@ default += .git/info/exclude
.PHONY: database .PHONY: database
database: $(default) ## Make a database for recfiles database: $(default) ## Make a database for recfiles
.PHONY: article
article: ## Write an article
@path=$$(find . -type d -printf '%P\n' | fzy); \
read -p "Title: " title; \
printf '%s\n' '---' >> $$path/$$title.md ; \
printf 'title: "%s"\n' "$$title" >> $$path/$$title.md ; \
printf 'tags: [ "%s" ]\n' "$$path" | sed 's#\/#", "#g' >> $$path/$$title.md ; \
printf '%s\n\n' '---' >> $$path/$$title.md ;\
$(EDITOR) +5 $$path/$$title.md
.PHONY: clean .PHONY: clean
clean: clean:
$(RM) $(default) $(RM) $(default)

27
new.sh
View File

@ -1,27 +0,0 @@
#!/bin/sh
echo Select a category
category="$(find . -type d -printf '%P\n' | fzy)"
[ ! -d "$category" ] && mkdir "$category"
echo Select a name
read name
filePath="$category/$(echo $name | sed 's/ /_/g').md"
tagsList="$(echo \"$category | sed 's#\/#", "#g')\""
[ -e "$filePath" ] && $EDITOR "$filePath" && exit 0
echo "---
title: \"$name\"
tags: [ $tagsList ]
---
" > "$filePath"
$EDITOR "$filePath"