From 03d6a5058048351b9326bc03f2a6279b9d1031ce Mon Sep 17 00:00:00 2001 From: Adam Schmalhofer Date: Wed, 5 Jan 2022 14:13:02 +0100 Subject: [PATCH] Let apps.json be generated by Liquid template Instead of plugin as tried first. Turns out github doesn't allow own plugins (unlike gitlab). It is the simpler and more elegant solution any how. --- .gitignore | 1 - _plugins/AppsJsonGenerator.rb | 26 -------------------------- apps.json | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 27 deletions(-) delete mode 100644 _plugins/AppsJsonGenerator.rb create mode 100644 apps.json diff --git a/.gitignore b/.gitignore index 6542325c5..47233d1f5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,3 @@ appdates.csv _config.yml tests/Layout/bin/tmp.* tests/Layout/testresult.bmp -/apps.json diff --git a/_plugins/AppsJsonGenerator.rb b/_plugins/AppsJsonGenerator.rb deleted file mode 100644 index 1a6525cca..000000000 --- a/_plugins/AppsJsonGenerator.rb +++ /dev/null @@ -1,26 +0,0 @@ -class AppsJsonPage < Jekyll::Page - def initialize(site) - @site = site - @base = site.source - @basename = 'apps' - @ext = '.json' - @name = 'apps.json' - @data = {} - end -end - -# Generates the apps.json -# out of all the /apps/*/metadata.json files -class Generator < Jekyll::Generator - safe true - - def generate(site) - metadatas = site.static_files.select { |file| file.name == 'metadata.json' } - json = metadatas.map { |file| JSON.load(open(file.path)) } - appsjson = AppsJsonPage.new(site) - open(appsjson.path, 'wb') do |file| - file << JSON.generate(json) - end - site.pages << appsjson - end -end diff --git a/apps.json b/apps.json new file mode 100644 index 000000000..c62663ee0 --- /dev/null +++ b/apps.json @@ -0,0 +1,14 @@ +--- +layout: none +--- +{%- assign apps = site.static_files | where: "name", "metadata.json" -%} + +[ + +{%- include_relative {{ apps.first.path }} -%} + +{%- for app in apps offset:1 -%} +,{%- include_relative {{ app.path }} -%} +{%- endfor -%} + +]