al-quran.reflectslight.io/nanoc/rules/stream.rules

55 lines
1.5 KiB
Ruby

#!/usr/bin/env ruby
# frozen_string_literal: true
##
# Rules for the surah stream available at /<locale>/<name>/.
compile "/json/*/*/surah.json" do
write(item.identifier.to_s)
if File.size(item.raw_filename) > (1024 * 10)
filter :gzip
write("#{item.identifier}.gz")
end
end
Ryo.each(name_by_id) do |id, transliterated_name|
writer = ->(locale, identifier:) do
name = tdata[locale].surahs.names[id.to_i - 1]
context = Ryo.from(
filename: "stream.html.erb",
locale:,
locales:,
surah: {id:, name:, transliterated_name:}
)
filter(:erb, locals: {context:})
filter(:tidy)
write "/#{locale}/#{identifier}/index.html"
end
locales.each do |locale|
compile "/html/stream.html.erb", rep: "/#{locale}/#{transliterated_name}/index.html" do
instance_exec(locale, identifier: transliterated_name, &writer)
end
compile "/html/stream.html.erb", rep: "/#{locale}/#{id}/index.html" do
instance_exec(locale, identifier: id, &writer)
end
end
end
compile "/js/main/surah-stream.tsx" do
filter :webpack,
depend_on: ["/js/components", "/js/lib/", "/js/hooks"]
write "/js/main/surah-stream.js"
filter :gzip
write "/js/main/surah-stream.js.gz"
end
compile "/js/loaders/SurahStreamLoader.ts" do
filter :webpack
write "/js/loaders/surah-stream-loader.js"
end
compile "/css/main/SurahStream.scss" do
filter :sass, syntax: :scss, style: :compact
filter :rainpress
write("/css/main/surah-stream.css")
end