77 lines
1.6 KiB
Ruby
77 lines
1.6 KiB
Ruby
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
require "ryo"
|
|
|
|
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/random_redirect.html" do
|
|
write("/index.html")
|
|
end
|
|
|
|
##
|
|
# /<locale>/<surahno>/surah.json
|
|
# Provides the JSON for a given surah no
|
|
1.upto(114) do |surahno|
|
|
LOCALES.each { passthrough "/#{_1}/#{surahno}/surah.json" }
|
|
end
|
|
|
|
##
|
|
# /<locale>/<surahno>/index.html
|
|
# Redirects to a slug URL (eg /en/al-fatihah/)
|
|
compile "/html/slug_redirect.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/surah.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, exe: "./node_modules/webpack/bin/webpack.js"
|
|
write "/js/pages/surah.js"
|
|
end
|
|
|
|
##
|
|
# CSS
|
|
compile("/css/_*.scss") { write(nil) }
|
|
compile "/css/*.scss" do
|
|
filter :sass, syntax: :scss, style: :compact
|
|
filter :rainpress
|
|
write item.identifier.without_ext + ".css"
|
|
end
|
|
|
|
##
|
|
# Fonts
|
|
compile "/fonts/*" do
|
|
write(item.identifier.to_s)
|
|
end
|
|
|
|
##
|
|
# Images
|
|
compile "/images/*" do
|
|
write(item.identifier.to_s)
|
|
end
|
|
|
|
compile("/**/*") { write(nil) }
|
|
layout("**/*", :erb)
|