Fix / improve render of meta tags (stream.html.erb)
This commit is contained in:
parent
6bec11a547
commit
f544be4144
4 changed files with 30 additions and 25 deletions
|
@ -8,10 +8,11 @@ module Mixin::OpenGraph
|
|||
def local_assigns(context)
|
||||
case context.filename
|
||||
when "stream.html.erb"
|
||||
surah = context.surah
|
||||
{title: t(context.locale, "TheNobleQuran"),
|
||||
description: t(context.locale, "meta.stream.description", surah_name: context.surah.name),
|
||||
url: "https://al-quran.reflectslight.io/#{context.locale}/#{context.surah.slug}/",
|
||||
image: "https://al-quran.reflectslight.io/images/opengraph/#{context.surah.id}.png"}
|
||||
description: t(context.locale, "meta.stream.description", surah_name: surah.name),
|
||||
url: "https://al-quran.reflectslight.io/#{context.locale}/#{surah.slug}/",
|
||||
image: "https://al-quran.reflectslight.io/images/opengraph/#{surah.id}.png"}
|
||||
when "index.html.erb"
|
||||
{title: t(context.locale, "TheNobleQuran"),
|
||||
description: t(context.locale, "meta.index.description"),
|
||||
|
|
|
@ -12,25 +12,29 @@ compile "/json/*/*/surah.json" do
|
|||
end
|
||||
end
|
||||
|
||||
Ryo.each(name_by_id) do |id, transliterated_name|
|
||||
writer = ->(locale, identifier:) do
|
||||
Ryo.each(name_by_id) do |id, slug|
|
||||
write_file = ->(locale, pathname:) do
|
||||
name = tdata[locale].surahs.names[id.to_i - 1]
|
||||
context = Ryo.from(
|
||||
filename: "stream.html.erb",
|
||||
locale:,
|
||||
locales:,
|
||||
surah: {id:, name:, transliterated_name:}
|
||||
surah: {id:, name:, slug:}
|
||||
)
|
||||
filter(:erb, locals: {context:})
|
||||
locals = {
|
||||
locale: context.locale, locales: context.locales,
|
||||
surah: context.surah, context:
|
||||
}
|
||||
filter(:erb, locals:)
|
||||
filter(:tidy)
|
||||
write "/#{locale}/#{identifier}/index.html"
|
||||
write "/#{locale}/#{pathname}/index.html"
|
||||
end
|
||||
locales.each do |locale|
|
||||
compile "/html/stream.html.erb", rep: "/#{locale}/#{transliterated_name}/index.html" do
|
||||
instance_exec(locale, identifier: transliterated_name, &writer)
|
||||
compile "/html/stream.html.erb", rep: "/#{locale}/#{slug}/index.html" do
|
||||
instance_exec(locale, pathname: slug, &write_file)
|
||||
end
|
||||
compile "/html/stream.html.erb", rep: "/#{locale}/#{id}/index.html" do
|
||||
instance_exec(locale, identifier: id, &writer)
|
||||
instance_exec(locale, pathname: id, &write_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="<%= context.locale %>">
|
||||
<html lang="<%= locale %>">
|
||||
<head>
|
||||
<title> <%= context.surah.name %> </title>
|
||||
<title><%= t(locale, "TheNobleQuran") %></title>
|
||||
<%= inline_css('/css/vendor/postman.css') %>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content='<%= t(context.locale, 'meta.stream.description', {surah_name: context.surah.name}) %>'>
|
||||
<meta name="description" content='<%= t(locale, 'meta.stream.description', {surah_name: surah.name}) %>'>
|
||||
<%= erb("partials/favicon.html.erb") %>
|
||||
<link
|
||||
rel="canonical"
|
||||
hreflang="<%= context.locale %>"
|
||||
href="https://al-quran.reflectslight.io/<%= context.locale %>/<%= context.surah.transliterated_name %>/"
|
||||
hreflang="<%= locale %>"
|
||||
href="https://al-quran.reflectslight.io/<%= locale %>/<%= surah.slug %>/"
|
||||
/>
|
||||
<% context.locales.each do |locale| %>
|
||||
<% locales.each do |locale| %>
|
||||
<link
|
||||
rel="alternate"
|
||||
type="text/html"
|
||||
hreflang="<%= locale %>"
|
||||
href="https://al-quran.reflectslight.io/<%= locale %>/<%= context.surah.transliterated_name %>/"
|
||||
href="https://al-quran.reflectslight.io/<%= locale %>/<%= surah.slug %>/"
|
||||
/>
|
||||
<% end %>
|
||||
<%= opengraph(context) %>
|
||||
|
@ -30,10 +30,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="root"
|
||||
data-locale="<%= context.locale %>"
|
||||
data-surah-id="<%= context.surah.id %>">
|
||||
data-locale="<%= locale %>"
|
||||
data-surah-id="<%= surah.id %>">
|
||||
</div>
|
||||
<%= inline_json("/json/durations/alafasy/#{context.surah.id}.json", class_name: 'durations') %>
|
||||
<%= inline_json("/json/durations/alafasy/#{surah.id}.json", class_name: 'durations') %>
|
||||
<script src="/js/loaders/surah-stream-loader.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
"of": "of",
|
||||
"filter": "Filter",
|
||||
"meta": {
|
||||
"index": {"description": "Explore the chapters of The Noble Quran."},
|
||||
"stream": {"description": "Read and listen to %{surah_name}."}
|
||||
"index": {"description": "Explore the chapters of The Noble Quran"},
|
||||
"stream": {"description": "Read and listen to %{surah_name}"}
|
||||
},
|
||||
"surahs": {
|
||||
"names": [
|
||||
|
@ -142,10 +142,10 @@
|
|||
"filter": "تصفية",
|
||||
"meta": {
|
||||
"index": {
|
||||
"description": ".استكشف فصول القرآن الكريم"
|
||||
"description": "استكشف فصول القرآن الكريم"
|
||||
},
|
||||
"stream": {
|
||||
"description": ".%{surah_name} اقرأ واستمع إلى"
|
||||
"description": "%{surah_name} اقرأ واستمع إلى"
|
||||
}
|
||||
},
|
||||
"surahs": {
|
||||
|
|
Loading…
Reference in a new issue