diff --git a/build.sh b/build.sh
index e84aea6..7240b38 100755
--- a/build.sh
+++ b/build.sh
@@ -26,7 +26,15 @@ pagedump()
# always check for markdown first
if [ -f "$1.md" ]
then
- pandoc -t html -f markdown "$1.md"
+
+ # always check for markdown first
+ if [ -f "$1.yaml" ]
+ then
+ pandoc -t markdown --metadata-file "$1.yaml" --template "$1.md" | pandoc -t html
+ else
+ pandoc -t html -f markdown "$1.md"
+ fi
+
return
fi
fi
@@ -166,7 +174,7 @@ make_news_header()
echo "" >> "$2"
}
-# arguments: site, page side, page, title
+# arguments: site, page side, page, title, sub-page
site_button()
{
if [ "$2" = "news" ]
@@ -179,7 +187,13 @@ site_button()
BTN_NAME="$3"
BTN_PAGE="$3"
fi
- BTN_OUT="_pb_$BTN_NAME"
+
+ if [ "$5" = "" ]
+ then
+ BTN_OUT="_pb_$BTN_NAME"
+ else
+ BTN_OUT="_pb_$5_$BTN_NAME"
+ fi
if [ -f "$BTN_SEARCHPATH/$BTN_NAME.gif" ]
then
@@ -202,7 +216,12 @@ site_button()
return
fi
- echo "• $4
"
+ if [ "$5" = "" ]
+ then
+ echo " $4
"
+ else
+ echo "• $4
"
+ fi
}
# arguments: site-name (folder inside ./sites)
@@ -235,7 +254,7 @@ site_process()
# enumerate and list the right-aligned pages
if [ -d "./sites/$1/pages_right" ]
then
- find ./sites/$1/pages_right -name title | sort | while read LINE
+ find ./sites/$1/pages_right -maxdepth 2 -name title | sort | while read LINE
do
DIR=$(dirname "$LINE")
ID_NAME=$(basename "$DIR")
@@ -247,14 +266,22 @@ site_process()
fi
site_button "$1" "pages_right" "$ID_NAME" "$TITLE" >> "$TMP_PAGES_R"
- #echo "• $TITLE
" >> "$TMP_PAGES_R"
+
+ # a page may have sub-pages
+ find "./sites/$1/pages_right/$ID_NAME/" -mindepth 2 -maxdepth 2 -name title | sort | while read SUBLINE
+ do
+ SUBDIR=$(dirname "$SUBLINE")
+ SUBID_NAME=$(basename "$SUBDIR")
+ SUBTITLE=$(cat "$SUBDIR/title")
+ site_button "$1" "pages_right/$ID_NAME" "$SUBID_NAME" "$SUBTITLE" "$ID_NAME" >> "$TMP_PAGES_L"
+ done
done
fi
# enumerate and list the left-aligned pages
if [ -d "./sites/$1/pages_left" ]
then
- find ./sites/$1/pages_left -name title | sort | while read LINE
+ find ./sites/$1/pages_left -maxdepth 2 -name title | sort | while read LINE
do
DIR=$(dirname "$LINE")
ID_NAME=$(basename "$DIR")
@@ -266,7 +293,15 @@ site_process()
fi
site_button "$1" "pages_left" "$ID_NAME" "$TITLE" >> "$TMP_PAGES_L"
- #echo "• $TITLE
" >> "$TMP_PAGES_L"
+
+ # a page may have sub-pages
+ find "./sites/$1/pages_left/$ID_NAME/" -mindepth 2 -maxdepth 2 -name title | sort | while read SUBLINE
+ do
+ SUBDIR=$(dirname "$SUBLINE")
+ SUBID_NAME=$(basename "$SUBDIR")
+ SUBTITLE=$(cat "$SUBDIR/title")
+ site_button "$1" "pages_left/$ID_NAME" "$SUBID_NAME" "$SUBTITLE" "$ID_NAME" >> "$TMP_PAGES_L"
+ done
done
fi
@@ -292,7 +327,7 @@ site_process()
# build right-aligned pages
if [ -d "./sites/$1/pages_right" ]
then
- find ./sites/$1/pages_right -name title | sort | while read LINE
+ find ./sites/$1/pages_right -maxdepth 2 -name title | sort | while read LINE
do
DIR=$(dirname "$LINE")
ID_NAME=$(basename "$DIR")
@@ -303,13 +338,27 @@ site_process()
html_start "$OUTFILE" "$TITLE" "$1"
pagedump "$DIR/content" >> "$OUTFILE"
html_end "$OUTFILE" "$1"
+
+ # handle sub-pages
+ find "./sites/$1/pages_right/$ID_NAME/" -mindepth 2 -maxdepth 2 -name title | sort | while read SUBLINE
+ do
+ SUBDIR=$(dirname "$SUBLINE")
+ SUBID_NAME=$(basename "$SUBDIR")
+ SUBTITLE=$(cat "$SUBDIR/title")
+ SUBOUTFILE="./out/$1/${ID_NAME}_${SUBID_NAME}.html"
+
+ # generate the individual news page
+ html_start "$SUBOUTFILE" "$TITLE - $SUBTITLE" "$1"
+ pagedump "$SUBDIR/content" >> "$SUBOUTFILE"
+ html_end "$SUBOUTFILE" "$1"
+ done
done
fi
# Build left-aligned pages
if [ -d "./sites/$1/pages_left" ]
then
- find ./sites/$1/pages_left -name title | sort | while read LINE
+ find ./sites/$1/pages_left -maxdepth 2 -name title | sort | while read LINE
do
DIR=$(dirname "$LINE")
ID_NAME=$(basename "$DIR")
@@ -320,6 +369,20 @@ site_process()
html_start "$OUTFILE" "$TITLE" "$1"
pagedump "$DIR/content" >> "$OUTFILE"
html_end "$OUTFILE" "$1"
+
+ # handle sub-pages
+ find "./sites/$1/pages_left/$ID_NAME/" -mindepth 2 -maxdepth 2 -name title | sort | while read SUBLINE
+ do
+ SUBDIR=$(dirname "$SUBLINE")
+ SUBID_NAME=$(basename "$SUBDIR")
+ SUBTITLE=$(cat "$SUBDIR/title")
+ SUBOUTFILE="./out/$1/${ID_NAME}_${SUBID_NAME}.html"
+
+ # generate the individual news page
+ html_start "$SUBOUTFILE" "$TITLE - $SUBTITLE" "$1"
+ pagedump "$SUBDIR/content" >> "$SUBOUTFILE"
+ html_end "$SUBOUTFILE" "$1"
+ done
done
fi
diff --git a/readme.txt b/readme.txt
index bb888b4..bf9d2f4 100644
--- a/readme.txt
+++ b/readme.txt
@@ -51,6 +51,20 @@ file inside your page directory. Name it the same thing as your page.
Same can be done for the 'News' button, just name it 'news' and place it
inside the `./sites/???/news/` directory with the file format of your choosing.
+# Sub-pages
+
+Pages can have sub-pages. Simply have another page-styled directory within
+a page directory. For example, `./sites/???/pages_left/games/files/` containing both
+a `title` and a `content.md` file.
+
+# Metadata within pages
+
+You can use metadata within Markdown pages. If your `content.md` has a `content.yaml` file
+alongside it, it will be used within the page accordingly. Please see this page for detailed
+information:
+
+https://pandoc.org/MANUAL.html#extension-yaml_metadata_block
+
# LICENSE
Licensed under the ISC license. Everything in here was written by