From d9b5ce6a7d103e3cb27c7ec1bef06e804cdf165c Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Wed, 8 Mar 2023 12:49:27 -0300 Subject: [PATCH] Add Nanoc::Filters::MinifyJSON --- lib/nanoc/filters/minify_json.rb | 11 +++++++++++ rules/pages/TheSurahIndex.rules | 1 + 2 files changed, 12 insertions(+) create mode 100644 lib/nanoc/filters/minify_json.rb diff --git a/lib/nanoc/filters/minify_json.rb b/lib/nanoc/filters/minify_json.rb new file mode 100644 index 0000000..3718fdf --- /dev/null +++ b/lib/nanoc/filters/minify_json.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class Nanoc::Filters::MinifyJSON < Nanoc::Filter + require "json" + identifier :minify_json + type text: :text + + def run(content, options = {}) + JSON.dump(JSON.parse(content)) + end +end diff --git a/rules/pages/TheSurahIndex.rules b/rules/pages/TheSurahIndex.rules index 688d728..efa2b17 100644 --- a/rules/pages/TheSurahIndex.rules +++ b/rules/pages/TheSurahIndex.rules @@ -15,6 +15,7 @@ compile "/js/surah/index/redirect.ts" do end compile "/surahs.json" do + filter(:minify_json) write "/surahs.json" end