71 lines
1.8 KiB
Ruby
71 lines
1.8 KiB
Ruby
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
##
|
|
# Requires
|
|
require "ryo"
|
|
require "ryo/json"
|
|
require "ryo/yaml"
|
|
require "nanoc-gzip"
|
|
require "nanoc-webpack"
|
|
require "nanoc-tidy"
|
|
|
|
##
|
|
# Extensions
|
|
[Nanoc::RuleDSL::CompilationRuleContext, Nanoc::RuleDSL::CompilerDSL].each { _1.prepend(Utils) }
|
|
Nanoc::RuleDSL::CompilationRuleContext.prepend(Nanoc::Extension::AnonymousFilter)
|
|
Nanoc::RuleDSL::CompilerDSL.prepend(Nanoc::Extension::RequireRules)
|
|
|
|
##
|
|
# Locals
|
|
locales = %w[ar fa en]
|
|
name_by_id = Ryo.from_json(path: File.join(dirs.content, "json", "nameById.json"))
|
|
tdata = Ryo.from_json(path: File.join(dirs.content, "json", "t.json"))
|
|
surahs = Ryo.from_json(path: File.join(dirs.content, "json", "surahs.json"))
|
|
tidy = `which tidy || which tidy5`.chomp
|
|
buildenv = ENV["buildenv"] || "development"
|
|
etcdir = File.join(__dir__, "etc")
|
|
globals = {buildenv:, locales:, tidy:, tdata:, surahs:, name_by_id:}
|
|
|
|
##
|
|
# Filters
|
|
Nanoc::Tidy
|
|
.default_argv
|
|
.replace([*Nanoc::Tidy.default_argv, "-upper"].uniq)
|
|
|
|
##
|
|
# See packages/typescript/postman
|
|
compile "/css/vendor/postman.css" do
|
|
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
|
|
|
|
##
|
|
# Rules
|
|
passthrough "/json/durations/*.json"
|
|
require_rules "nanoc/rules/assets", globals
|
|
require_rules "nanoc/rules/redirect", globals
|
|
require_rules "nanoc/rules/random", globals
|
|
require_rules "nanoc/rules/surah-stream", globals
|
|
require_rules "nanoc/rules/surah-index", globals
|
|
|
|
compile "/js/main/vendor.ts" do
|
|
filter :webpack,
|
|
argv: %w[--config etc/webpack.vendor.js]
|
|
write("/js/main/vendor.js")
|
|
end
|
|
compile("/**/*") { write(nil) }
|
|
layout("**/*", :erb)
|