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.
master
Adam Schmalhofer 2022-01-05 14:13:02 +01:00
parent 01d3615663
commit 03d6a50580
3 changed files with 14 additions and 27 deletions

1
.gitignore vendored
View File

@ -9,4 +9,3 @@ appdates.csv
_config.yml _config.yml
tests/Layout/bin/tmp.* tests/Layout/bin/tmp.*
tests/Layout/testresult.bmp tests/Layout/testresult.bmp
/apps.json

View File

@ -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

14
apps.json Normal file
View File

@ -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 -%}
]