Skip to content

Instantly share code, notes, and snippets.

View jgreely's full-sized avatar
💭
I may be slow to respond.

J Greely jgreely

💭
I may be slow to respond.
View GitHub Profile
@jgreely
jgreely / wikiblog.sh
Last active April 7, 2017 23:32
create random Hugo content files for theme testing
#!/usr/bin/env bash
# create Hugo content files from random Wikipedia articles;
# requires Pandoc to convert HTML to Markdown
#
read -r -d '' USAGE <<'EOF'
Usage: wikiblog.sh [options]
-a list of possible authors for an article (selects 1)
-c list of possible categories (select up to N-1)
@jgreely
jgreely / pagination.html
Last active January 11, 2018 01:39
layouts/partials/pagination.html: scalable replacement for Hugo _internal/pagination.html
{{ $pag := $.Paginator }}
{{ if gt $pag.TotalPages 1 }}
<ul class="pagination">
{{ with $pag.First }}
<li class="first {{ if not $pag.HasPrev }}disabled{{ end }}"><a href="{{ .URL }}" aria-label="First"><span aria-hidden="true">&laquo;&laquo;</span></a></li>
{{ end }}
<li class="previous {{ if not $pag.HasPrev }}disabled{{ end }}"><a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
<li class="active"><a href="{{ $pag.URL }}">{{ $pag.PageNumber }}</a></li>
<li class="next {{ if not $pag.HasNext }}disabled{{ end }}" aria-label="Next"><a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}"><span aria-hidden="true">&raquo;</span></a></li>
{{ with $pag.Last }}<li class="last {{ if not $pag.HasNext }}disabled{{ end }}"><a href="{{ .URL }}" aria-label="Last" title="{{$pag.TotalPages}}"><span aria-hidden="true">&raquo;&raquo;</span></a></li>
@jgreely
jgreely / createmonthly.pl
Created April 9, 2017 07:44
Create monthly archives for a Hugo site
#!/usr/bin/env perl
# work around Hugo's lack of monthly archives by filling the archive
# section with stub articles, one for each month referenced in the
# front matter of articles in the "post" category:
# +++
# date = "2017-04-01T00:00:00"
# title = "April 2017"
# month = "2017-04"
# +++
#!/usr/bin/env perl
#
# take a list of Hugo content files and add random taxonomies
# to their TOML front matter:
# find content -name '*.md' | taxonomies.pl -T 5 -t 1000
use strict;
use List::Util qw(shuffle);
use Getopt::Long qw(:config no_ignore_case bundling);
@jgreely
jgreely / smartdown.sh
Created September 5, 2021 06:28
Bash script to convert Hugo markdown files to smartquotes, since Goldmark sucks at it
#!/usr/bin/env bash
#
# add smart quotes to Hugo Markdown source files, using the
# reference implementation of CommonMark's CLI tool:
# https://github.com/commonmark/commonmark-spec
# Notes:
# - assumes TOML front matter
# - converts footnote-style links to inline
# - normalizes ordered/unordered list formatting
#