aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gen-projects.rb26
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'],