0x1eef
6e1a7aec51
Add a nanoc filter that runs HTML content through [tidy-html](https://github.com/htacg/tidy-html5). The content that is first run through ERB is often indented incorrectly and inconsistently, and 'tidy' can fix that for us.
57 lines
1.6 KiB
Ruby
57 lines
1.6 KiB
Ruby
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
##
|
|
# 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)
|
|
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/pages/surah/stream.html.erb", rep: "/#{locale}/#{slug}/index.html" do
|
|
instance_exec(locale, identifier: slug, &writer)
|
|
end
|
|
compile "/html/pages/surah/stream.html.erb", rep: "/#{locale}/#{id}/index.html" do
|
|
instance_exec(locale, identifier: id, &writer)
|
|
end
|
|
end
|
|
end
|
|
|
|
compile "/js/pages/surah/stream.tsx" do
|
|
filter :webpack,
|
|
depend_on: ["/js/components", "/js/lib/", "/js/hooks"],
|
|
reject: proc { _1.include?("WebPackage") }
|
|
write "/js/pages/surah/stream.js"
|
|
filter :gzip
|
|
write "/js/pages/surah/stream.js.gz"
|
|
end
|
|
|
|
compile "/js/pages/surah/stream/loader.ts" do
|
|
filter :webpack, depend_on: "/js/lib/WebPackage"
|
|
write "/js/pages/surah/stream/loader.js"
|
|
end
|
|
|
|
compile "/css/pages/surah/stream.scss" do
|
|
filter :sass, syntax: :scss, style: :compact
|
|
filter :rainpress
|
|
write("/css/pages/surah/stream.css")
|
|
end
|