From 9c803bfafc69ec77d012c3c3c7b55bbd4272cd20 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Thu, 12 Dec 2024 18:47:37 +0100 Subject: [PATCH] move API generator to post-write hook --- _plugins/api.rb | 5 +++-- _plugins/generator-workflows.rb | 1 - _plugins_dev/api-fake.rb | 10 ---------- 3 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 _plugins_dev/api-fake.rb diff --git a/_plugins/api.rb b/_plugins/api.rb index a86532cb6ac9ed..2fab71e6065e9f 100644 --- a/_plugins/api.rb +++ b/_plugins/api.rb @@ -68,7 +68,7 @@ module Generators ## # This class generates the GTN's "api" by writing out a folder full of JSON files. # TODO: could be a post-write hook. - class APIGenerator < Generator + class APIGenerator ## # Generates /api/configuration.json @@ -342,7 +342,6 @@ def generate(site) end end - Jekyll::Hooks.register :site, :post_read do |site| Gtn::Hooks.by_tool(site) end @@ -351,6 +350,8 @@ def generate(site) Jekyll::Hooks.register :site, :post_write do |site| # No need to run this except in prod. if Jekyll.env == 'production' + # Our API + Jekyll::Generators::APIGenerator.generate(site) # Public tool listing: reorganised if site.data['public-server-tools'] && site.data['public-server-tools']['tools'] diff --git a/_plugins/generator-workflows.rb b/_plugins/generator-workflows.rb index 84c74974165cae..02f12298c57093 100644 --- a/_plugins/generator-workflows.rb +++ b/_plugins/generator-workflows.rb @@ -10,7 +10,6 @@ module Jekyll # # Real Generators, the way Jekyll intended: # - # - Jekyll::Generators::APIGenerator - outputs our API # - Jekyll::Generators::PlaintextSlidesGenerator - turns slides.html into plain text non-JS versions. # - Jekyll::Generators::RecordingPageGenerator - emits a webpage for every tutorial that has recordings, in the GTN # - Jekyll::Generators::WorkflowPageGenerator - emits a webpage for every workflow in the GTN diff --git a/_plugins_dev/api-fake.rb b/_plugins_dev/api-fake.rb deleted file mode 100644 index 2419d9c6e325ac..00000000000000 --- a/_plugins_dev/api-fake.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'json' - -module Jekyll - # API Generation Disabled - class APIGenerator < Generator - def generate(_site) - puts '[GTN/API] Disabled' - end - end -end