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

58 lines
1.5 KiB
Text
Raw Normal View History

#!/usr/bin/env ruby
2023-03-11 18:31:44 +01:00
# frozen_string_literal: true
2023-03-10 14:51:34 +01:00
##
2023-03-10 14:41:19 +01:00
# Rules for the surah stream available at /<locale>/<name>/ (eg /ar/al-fatihah/)
# and its dependencies.
compile "/*/*/surah.json" do
write(item.identifier.to_s)
if File.size(item.raw_filename) > (1024 * 10)
2023-06-30 00:49:42 +02:00
filter :gzip
write("#{item.identifier}.gz")
end
end
Ryo.each(slugs) do |id, slug|
writer = ->(locale, identifier:) do
name = i18n[locale].surahs.names[id.to_i - 1]
context = Ryo.from(
filename: "stream.html.erb",
locale:,
locales:,
surah: {id:, name:, slug:}
)
filter(:erb, locals: {context:})
filter(:tidy)
write "/#{locale}/#{identifier}/index.html"
end
locales.each do |locale|
compile "/html/stream.html.erb", rep: "/#{locale}/#{slug}/index.html" do
instance_exec(locale, identifier: slug, &writer)
end
compile "/html/stream.html.erb", rep: "/#{locale}/#{id}/index.html" do
instance_exec(locale, identifier: id, &writer)
end
end
end
compile "/js/pages/SurahStream.tsx" do
2023-03-27 17:23:20 +02:00
filter :webpack,
depend_on: ["/js/components", "/js/lib/", "/js/hooks"],
2023-05-29 03:28:15 +02:00
reject: proc { _1.include?("WebPackage") }
write "/js/surah-stream.js"
2023-06-30 00:49:42 +02:00
filter :gzip
write "/js/surah-stream.js.gz"
end
compile "/js/loaders/SurahStreamLoader.ts" do
filter :webpack, depend_on: "/js/lib/WebPackage"
write "/js/loaders/surah-stream-loader.js"
end
compile "/css/pages/SurahStream.scss" do
filter :sass, syntax: :scss, style: :compact
filter :rainpress
write("/css/surah-stream.css")
end