al-quran.reflectslight.io/Rules
0x1eef e1249e7b81 Add Farsi support
This change is a big one. It adds Farsi support,
which by itself is significant. In the process of
adding Farsi support other significant improvements
were made:

* Select.tsx component
* TLocale (Quran/index.ts)
* ...
2024-05-19 16:51:37 -03:00

71 lines
1.5 KiB
Ruby

#!/usr/bin/env ruby
# frozen_string_literal: true
##
# requires
require "ryo"
require "ryo/json"
require "nanoc-gzip"
require "nanoc-webpack"
require "nanoc-tidy"
##
# variables
locales = %w[ar fa 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"
##
# DSL extensions
Nanoc::RuleDSL::CompilationRuleContext.prepend(Nanoc::RuleDSL::Filter)
Nanoc::RuleDSL::CompilerDSL.prepend(Nanoc::RuleDSL::RequireRules)
##
# 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 proc { _1.each_line.reject { |s| s.strip.empty? }.join }
write("/sitemap.xml")
end
##
# /robots.txt
compile "/robots.txt" do
write("/robots.txt")
end
##
# /json/durations/*/*.json
passthrough "/json/durations/*/*.json"
##
# require rules
require_rules "nanoc/rules/assets"
require_rules "nanoc/rules/redirect", {locales:}
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)