working this time

This commit is contained in:
41666 2025-04-21 18:09:24 -07:00
parent 4d1663e588
commit 9aad36f910
4 changed files with 33 additions and 23 deletions

2
.gitignore vendored
View file

@ -1 +1 @@
result/
result

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# Teapot
because doll. it uses [markdoll](https://codeberg.org/0x57e11a/markdoll).

View file

@ -5,7 +5,7 @@ layout: alt.html
this is markdoll!
&so it is really gay to use other doll's software right?
&so it is really gay to use other doll's software right??
yeah.........
&look at this

View file

@ -19,13 +19,16 @@ in pkgs.stdenvNoCC.mkDerivation {
buildPhase = ''
mkdir dist
layout_inject() {
layoutFile=$1
placeholder=$2
content=$3
echoerr() { cat <<< "$@" 1>&2; }
layout=$(cat $layoutFile)
echo ''${layout/"$placeholder"/"$content"}
layout_inject() {
local layoutFile=$1
local placeholder=$2
local contentFile=$3
local layout=$(cat $layoutFile)
local content=$(cat $contentFile)
echo "''${layout/"$placeholder"/"$content"}"
}
get_frontmatter() {
@ -37,33 +40,35 @@ in pkgs.stdenvNoCC.mkDerivation {
}
render_final() {
file=$1
content=$2
outFile=$3
local file=$1
local outFile=$2
local content=$3
### Frontmatter: Get Layout
layout="${defaultLayout}"
layoutFm=$(get_frontmatter layout $file)
local layout="${defaultLayout}"
local layoutFm=$(get_frontmatter layout $file)
if [ ! -z $layoutFm ]; then
layout="$layoutFm"
fi
layoutPath="${layoutSrc}/$layout"
local layoutPath="$layout"
if [ ! -f $layoutPath ]; then
echo "Layout file $layout not found"
exit 1
layoutPath="${layoutSrc}/$layout"
if [ ! -f $layoutPath ]; then
echo "Layout file $layout not found"
exit 1
fi
fi
### Frontmatter: Title
title=$(get_frontmatter title $file)
local title=$(get_frontmatter title $file)
if [ -z $title ]; then
title=$(basename $file | sed -e 's/.doll$//')
fi
### Layout: Title + Content
mkdir -p $(dirname $outFile)
layout_inject $layoutPath %%TITLE%% "$title" > $outFile.tmp.1
layout_inject $outFile.tmp.1 %%CONTENT%% "$content" > $outFile.tmp.final
layout_inject $layoutPath %%TITLE%% <<<"$title" > $outFile.tmp.1
layout_inject $outFile.tmp.1 %%CONTENT%% $content > $outFile.tmp.final
### Layout: Cleanup Tmpfiles
cp $outFile.tmp.final $outFile
@ -76,12 +81,14 @@ in pkgs.stdenvNoCC.mkDerivation {
for file in $dollFiles; do
outFile=$(realpath -m "dist/$(echo $file | sed -e 's/.doll$/.html/')")
mkdir -p $(dirname $outFile)
echo "reading $file; plopping $outFile"
### Markdoll: Convert
content=$(cat $file | ${markdoll} convert)
local content=$(cat $file | ${markdoll} convert | tee $outFile.tmp.render)
render_final $file $content $outFile
render_final $file $outFile $outFile.tmp.render
done
'';