From 380f45eef274eb1f4966487635e8afa84654c5d7 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Wed, 13 Jul 2022 01:08:16 -0400 Subject: bin/gen-projects.rb: add support for go-import --- bin/gen-projects.rb | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'bin/gen-projects.rb') 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: "%s" slug: "%s" @@ -26,7 +29,21 @@ repo: "%s" text: "%s" --- %s -'.strip +'.strip, + + # go modules + go: ' +--- +title: "%s" +slug: "%s" +active: %s +repo: "%s" +text: "%s" +go_import: "pablotron.org/%s git %s" +--- +%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'], -- cgit v1.2.3