From 9fef5122ebc6b4ced072c704e944409c67407ae7 Mon Sep 17 00:00:00 2001
From: 0x1eef <0x1eef@protonmail.com>
Date: Fri, 10 Mar 2023 07:48:47 -0300
Subject: [PATCH] Add surah/id_redirect
---
Rules | 1 +
rules/pages/surah/id_redirect.rules | 15 +++++++++++++++
.../surah/id_redirect.html.erb} | 2 +-
.../id_redirect.ts} | 0
4 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 rules/pages/surah/id_redirect.rules
rename src/html/{redirect-to-surah-slug.html.erb => pages/surah/id_redirect.html.erb} (78%)
rename src/js/pages/{redirect-to-surah-slug.ts => surah/id_redirect.ts} (100%)
diff --git a/Rules b/Rules
index 6f037b1..598e9fc 100644
--- a/Rules
+++ b/Rules
@@ -34,6 +34,7 @@ require_rules "rules/pages/surah/random", {locales:, surah_id_to_name:}
require_rules "rules/pages/surah/stream", {locales:, surah_id_to_name:}
require_rules "rules/pages/surah/index", {locales:}
require_rules "rules/pages/surah/redirect"
+require_rules "rules/pages/surah/id_redirect", {locales:}
##
# Defaults
diff --git a/rules/pages/surah/id_redirect.rules b/rules/pages/surah/id_redirect.rules
new file mode 100644
index 0000000..6d768f2
--- /dev/null
+++ b/rules/pages/surah/id_redirect.rules
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+
+1.upto(114) do |id|
+ locales.each do |locale|
+ compile "/html/pages/surah/id_redirect.html.erb", rep: "redirect_id/#{id}" do
+ filter(:erb)
+ write("/#{locale}/#{id}/index.html")
+ end
+ end
+end
+
+compile "/js/pages/surah/id_redirect.ts" do
+ filter(:webpack)
+ write("/js/pages/surah/id_redirect.js")
+end
diff --git a/src/html/redirect-to-surah-slug.html.erb b/src/html/pages/surah/id_redirect.html.erb
similarity index 78%
rename from src/html/redirect-to-surah-slug.html.erb
rename to src/html/pages/surah/id_redirect.html.erb
index 91bd6d6..7c17725 100644
--- a/src/html/redirect-to-surah-slug.html.erb
+++ b/src/html/pages/surah/id_redirect.html.erb
@@ -7,6 +7,6 @@
-
+