mirror of
https://github.com/alvierahman90/gronk.git
synced 2024-11-22 15:29:52 +00:00
remember which directories were previously included and include them,
even if not passed as argument
This commit is contained in:
parent
efa6fd4b24
commit
3243b1cf64
25
notes2web
25
notes2web
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
[[ -z "$1" ]] && echo "USAGE: $0 NOTES_DIRECTORY_1 [NOTES_DIRECTORY_2 [...]]" && exit 0
|
[[ "$1" == "--help" ]] && echo "USAGE: $0 [NOTES_DIRECTORY_1 [NOTES_DIRECTORY_2 [...]]]" && exit 0
|
||||||
|
|
||||||
function _render {
|
function _render {
|
||||||
echo "rendering $1"
|
echo "rendering $1"
|
||||||
@ -23,7 +23,13 @@ function _renderindex {
|
|||||||
"$1"
|
"$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _addtolist {
|
function _adddirtoindex {
|
||||||
|
dir="$(dirname "$1")"
|
||||||
|
echo "<h1>$(basename "$dir") notes</h1>" >> index.md
|
||||||
|
find "$dir" -name '*.md' -exec bash -c "_addarticletoindex '{}'" \;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _addarticletoindex {
|
||||||
echo "adding $1 to list of notes"
|
echo "adding $1 to list of notes"
|
||||||
pandoc\
|
pandoc\
|
||||||
-t html\
|
-t html\
|
||||||
@ -34,13 +40,13 @@ function _addtolist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export -f _render
|
export -f _render
|
||||||
export -f _addtolist
|
export -f _adddirtoindex
|
||||||
|
export -f _addarticletoindex
|
||||||
|
|
||||||
#render each markdown file
|
#render each markdown file
|
||||||
|
for file in "$@"
|
||||||
for var in "$@"
|
|
||||||
do
|
do
|
||||||
find "$var" -name '*.md' -exec bash -c "_render '{}'" \;
|
find "$file" -name '*.md' -exec bash -c "_render '{}'" \;
|
||||||
done
|
done
|
||||||
|
|
||||||
# create an intermediate markdown file of links to each article
|
# create an intermediate markdown file of links to each article
|
||||||
@ -48,12 +54,13 @@ echo "---
|
|||||||
title: alv's notes
|
title: alv's notes
|
||||||
---" > index.md
|
---" > index.md
|
||||||
|
|
||||||
for var in "$@"
|
for file in "$@"
|
||||||
do
|
do
|
||||||
echo "<h1>$var notes</h1>" >> index.md
|
[[ ! -f "$file" ]] && echo "the presence of this files tells notes2web that it should be added to the notes2web index" > "$file/.2web"
|
||||||
find "$var" -name '*.md' -exec bash -c "_addtolist '{}'" \;
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
find -name '.2web' -exec bash -c "_adddirtoindex '{}'" \;
|
||||||
|
|
||||||
_renderindex index.md
|
_renderindex index.md
|
||||||
|
|
||||||
echo "copying styles.css to current directory"
|
echo "copying styles.css to current directory"
|
||||||
|
Loading…
Reference in New Issue
Block a user