Re:Show HN: Static blog generator in about 1 KLOC
by 1wheel on Saturday October 17, 2020 @03:15PM
(#24812392)
Mine is 60 lines of js; the markdown library does most of the work.
Re:Show HN: Static blog generator in about 1 KLOC
by lynndotpy on Saturday October 17, 2020 @03:22PM
(#24812432)
The most minimal I can muster is 3 lines of Bash:
for filename in ./posts/*.md; do
pandoc -s -c style.css $filename -o outputs/$(basename $filename md)html
done
Re:Show HN: Static blog generator in about 1 KLOC
by samtheprogram on Saturday October 17, 2020 @03:33PM
(#24812514)
This can get pretty pedantic. Where do you draw the line between what is the blog generator and the tools required to do it when counting the number of lines of code? One could easily argue in this case you might want to be counting the lines of code in pandoc, not this bash script.
That said, I do think this is the way to go, using a popular and generic tool (notably that you do not have to maintain) to accomplish a specific task. And more importantly, composing utilities together in a succinct and efficient way.
Also, if you used semicolons, or xargs with a pipe, you could make this one line :) newlines can be pretty arbitrary, I wonder if there's a better measurement for simplicity, like branches or statements/expressions.
Re:Show HN: Static blog generator in about 1 KLOC
by pwdisswordfish4 on Saturday October 17, 2020 @06:06PM
(#24813781)
In that case, here it is in one line, producing byte-for-byte identical output to the snippet above:
pangeadoc -c style.css ./ -O ./_site
(pangeadoc, of course, is a fork of pandoc that when invoked as above behaves exactly the same as those "3 lines of Bash".)
Re:Show HN: Static blog generator in about 1 KLOC
by antisol on Saturday October 17, 2020 @03:54PM
(#24812696)
damn, that's not a bad effort, I like it. But it does sort of feel like cheating ;)
Mine is about 140 lines of bash, and I don't /think/ i'm using anything that isn't part of coreutils.
Re:Show HN: Static blog generator in about 1 KLOC
by pwdisswordfish4 on Saturday October 17, 2020 @06:44PM
(#24814039)
The real story here is not the 60 lines, but the literate programming style used for it.
Aside from that, this approach is very similar to Marijn Haverbeke's (the CodeMirror author) generator, although your 60 lines does lean more heavily on third-party packages.
It does however depend on a few libs and comes with separate html template files for a theme so I am not exactly sure where I stand on the golf course.