diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-07-13 01:08:16 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-07-13 01:08:16 -0400 |
commit | 380f45eef274eb1f4966487635e8afa84654c5d7 (patch) | |
tree | 40032b2b9d14fae7d01ed755d7a34e6f252639d7 /bin | |
parent | 3c9bae7652eb92ea7c7a0da27afebc085f1844fe (diff) | |
download | pablotron.org-380f45eef274eb1f4966487635e8afa84654c5d7.tar.bz2 pablotron.org-380f45eef274eb1f4966487635e8afa84654c5d7.zip |
bin/gen-projects.rb: add support for go-import
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/gen-projects.rb | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/bin/gen-projects.rb b/bin/gen-projects.rb index ef4c547..c8983bc 100755 --- a/bin/gen-projects.rb +++ b/bin/gen-projects.rb @@ -17,7 +17,10 @@ require 'yaml' YAML_PATH = File.join(__dir__, '..', 'data', 'projects.yaml') PROJECTS_DIR = File.join(__dir__, '..', 'content', 'projects') -PROJECT_TMPL = ' +# project template +TMPLS = { + # default template + default: ' --- title: "%<name>s" slug: "%<slug>s" @@ -26,7 +29,21 @@ repo: "%<repo>s" text: "%<text>s" --- %<text>s -'.strip +'.strip, + + # go modules + go: ' +--- +title: "%<name>s" +slug: "%<slug>s" +active: %<active>s +repo: "%<repo>s" +text: "%<text>s" +go_import: "pablotron.org/%<slug>s git %<repo>s" +--- +%<text>s +'.strip, +} # # write front matter for project to projects directory @@ -35,8 +52,11 @@ def write_project(row) # build absolute path to destination file path = File.expand_path(File.join(PROJECTS_DIR, row['slug'])) + '.md' + # get template + tmpl = row['type'] ? TMPLS[row['type'].intern] : TMPLS[:default] + # generate and write body - File.write(path, PROJECT_TMPL % { + File.write(path, tmpl % { name: row['name'], slug: row['slug'], active: !row['old'], |