Add context to surah index (index.html.erb)

This commit is contained in:
0x1eef 2023-10-05 12:23:37 -03:00
parent 251dde6080
commit a6b55b64b7
3 changed files with 12 additions and 9 deletions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
use_helper Module.new {
require_relative "helper"
include Helper
@ -9,10 +11,10 @@ use_helper Module.new {
def local_assigns(context)
case context.filename
when "stream.html.erb"
{ title: t(context.locale, "TheNobleQuran"),
description: t(context.locale, "meta.stream.description"),
url: "https://al-quran.reflectslight.io/#{context.locale}/#{context.surah.slug}/",
image: "https://al-quran.reflectslight.io/images/opengraph/#{context.surah.id}.png" }
{title: t(context.locale, "TheNobleQuran"),
description: t(context.locale, "meta.stream.description"),
url: "https://al-quran.reflectslight.io/#{context.locale}/#{context.surah.slug}/",
image: "https://al-quran.reflectslight.io/images/opengraph/#{context.surah.id}.png"}
end
end
}

View file

@ -7,7 +7,8 @@
locales.each do |locale|
compile "/html/pages/surah/index.html.erb", rep: "/#{locale}/surah/index" do
filter(:erb, locals: {locale:})
context = Ryo.from(locale:)
filter(:erb, locals: {context:})
write "/#{locale}/index.html"
end
end

View file

@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="<%= locale %>">
<html lang="<%= context.locale %>">
<head>
<title><%= t(locale, "TheNobleQuran") %></title>
<title><%= t(context.locale, "TheNobleQuran") %></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<meta name="description" content="<%= t(locale, 'meta.index.description') %>">
<meta name="description" content="<%= t(context.locale, 'meta.index.description') %>">
<link rel="icon" href="/favicon.png">
<%= inline_css('/css/postman.scss') %>
</head>
@ -15,7 +15,7 @@
<span class="percentage">Loading...</span>
</div>
</div>
<div class="root" data-locale="<%= locale %>"></div>
<div class="root" data-locale="<%= context.locale %>"></div>
<%= inline_json("/i18n.json") %>
<%= inline_json("/surahs.json") %>
<script src="/js/pages/surah/index/loader.js"></script>