al-quran.reflectslight.io/Rules
0x1eef 431bde851c Add Select component
The Select component renders a list, and provides more flexibility
in how the element is styled (compared to a regular "<select>").
2022-12-28 04:01:23 -03:00

111 lines
2.4 KiB
Ruby

#!/usr/bin/env ruby
# frozen_string_literal: true
require "ryo"
require "nanoc-gunzip"
require "nanoc-webpack"
LOCALES = %w[ar en]
SURAH_ID_TO_SLUG = Ryo.from(
JSON.parse(
File.read(File.join(Dir.getwd, "src", "slugs.json"))
)
)
##
# Root path (/)
# Redirects to a random surah no
compile "/html/redirect-to-random-surah.html.erb" do
filter(:erb)
write("/index.html")
end
##
# /<locale>/<surahno>/surah.json
# Provides the JSON for a given surah no
compile "/*/*/surah.json" do
write(item.identifier.to_s)
if File.size(item.raw_filename) > (1024 * 10)
filter :gzip_text
write("#{item.identifier}.gz")
end
end
##
# /<locale>/<surahno>/index.html
# Redirects to a slug URL (eg /en/al-fatihah/)
compile "/html/redirect-to-surah-slug.html.erb" do
filter(:erb)
1.upto(114) do |surahno|
LOCALES.each { write(File.join("/", _1, surahno.to_s, "index.html")) }
end
end
##
# /<locale>/surah_slug>/index.html
# For reading a given surah
Ryo.each(SURAH_ID_TO_SLUG) do |surah_id, slug|
LOCALES.each do |locale|
compile "/html/TheSurahPage.html.erb", rep: "/#{locale}/#{slug}/index.html" do
filter :erb, locals: {locale: locale, surah_id: surah_id}
write "/#{locale}/#{slug}/index.html"
end
end
end
##
# /js/pages/surah.js
compile "/js/pages/TheSurahPage.tsx" do
filter :webpack, depend_on: [
"/js/components/*.{ts,tsx}",
"/js/{lib,components,hooks}/[!WebPackage]**/*.{ts,tsx,js}"
]
write "/js/pages/surah.js"
filter :gzip_text
write "/js/pages/surah.js.gz"
end
compile "/js/pages/TheSurahPage/package.ts" do
filter :webpack, depend_on: "/js/lib/WebPackage/*.ts"
write "/js/pages/TheSurahPage/package.js"
end
##
# /js/pages/redirect-to-random-surah.js
compile "/js/pages/redirect-to-random-surah.ts" do
filter :webpack
write "/js/pages/redirect-to-random-surah.js"
end
##
# /js/pages/redirect-to-surah-slug.js
compile "/js/pages/redirect-to-surah-slug.ts" do
filter :webpack
write "/js/pages/redirect-to-surah-slug.js"
end
##
# CSS
compile "/css/surah.scss" do
filter :sass, syntax: :scss, style: :compact
filter :rainpress
write("/css/surah.css")
end
##
# Fonts
compile "/fonts/*" do
write(item.identifier.to_s)
filter :gzip_binary
write("#{item.identifier}.gz")
end
##
# Images
compile "/images/*.svg" do
write(item.identifier.to_s)
filter :gzip_binary
write("#{item.identifier}.gz")
end
compile("/**/*") { write(nil) }
layout("**/*", :erb)