al-quran.reflectslight.io/Rules

61 lines
1.3 KiB
Ruby

#!/usr/bin/env ruby
# frozen_string_literal: true
require "ryo"
require "ryo/json"
require "nanoc-gzip"
require "nanoc-webpack"
require "nanoc-tidy"
require_relative "nanoc/lib/require_rules"
##
# Common vars
locales = %w[ar en]
json_dir = File.join(Dir.getwd, "src", "json")
name_by_id = Ryo.from_json_file("#{json_dir}/nameById.json")
tdata = Ryo.from_json_file("#{json_dir}/t.json")
buildenv = ENV["buildenv"] || "development"
##
# Plugins
Nanoc::Webpack
.default_argv
.concat ["--config", "webpack.#{buildenv}.js"]
Nanoc::Tidy
.default_argv
.concat ["-upper"]
##
# See packages/typescript/postman
compile "/css/vendor/postman.scss" do
filter :sass, syntax: :scss, style: :compact
filter :rainpress
write("/css/vendor/postman.css")
end
##
# /sitemap.xml
compile "/sitemap.xml.erb" do
filter(:erb, locals: {locales:, name_by_id:})
filter(:strip)
write("/sitemap.xml")
end
##
# /robots.txt
compile "/robots.txt" do
write("/robots.txt")
end
##
# Require rules
require_rules "nanoc/rules/assets"
require_rules "nanoc/rules/redirect"
require_rules "nanoc/rules/random", {locales:}
require_rules "nanoc/rules/stream", {locales:, tdata:, name_by_id:}
require_rules "nanoc/rules/index", {locales:, tdata:}
##
# Defaults
compile("/**/*") { write(nil) }
layout("**/*", :erb)