pagebuilder
pagebuilder copied to clipboard
whitelist/blacklist branches for generated versions.json
I really like the dynamically generated versions.json
over the manual maintenance of the extra section of mkdocs.yml.
But the issues are:
- whenever someone sends a pull-request, it will be included in the versions dropdown.
- if a branch name includes any of the words: "latest", "site", "build", it will be excluded from the versions list.
I would like to have more control over the directory inclusion/exclusion.
Although i could do the filtering in the client side with javascript, i would prefer to have a correctly generated versions.json
.
The sigil cal uses the dirs "*"
function call. But currently dirs
doesn't supports patterns. I see 3 solutions:
- Use
dirs "*"
in a range, and use a wrapped match:{{ range dirs "." | drop "latest" | drop ".git" | drop "site" | drop "build" }} {{if match "$WHITELIST" . }} {{.}} {{end}} {{end}}
- Add a sigil function which supports pattern matching like
dirspatt "v[0-9]* latest"
. but this seems like breaking the "do one thing" rule. - Just use plain shell functionality to get the directory list and feed it into sigil via env variable:
: ${WHITELIST:="v[0-9]*"}
dirsToInclude=$(ls -d "$WHITELIST")
sigil -i '...template...' dirsToInclude=$dirsToInclude
Or maybe I'm just lost in the details, and there is much simpler obvious solution. Im happy to do a PR if you tell which direction makes sense.