Merge pull request #143 from ReflectsLight/seo

Add meta description for search engines
This commit is contained in:
Robert 2023-07-21 10:36:17 -03:00 committed by GitHub
commit fff80b8558
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 8 deletions

View file

@ -19,5 +19,18 @@ module Helper
nanoc = Ryo.from YAML.load_file(File.join(Dir.getwd, "nanoc.yaml"))
nanoc.output_dir
end
def t(locale, key, locals = {})
str = [locale, *key.split(".")].inject(i18n) { |h, k| h[k] }
str % locals
end
def i18n
@i18n ||= Ryo.from(
JSON.parse(
File.read(File.join(Dir.getwd, "src", "i18n.json"))
)
)
end
end
use_helper Helper

View file

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

View file

@ -16,9 +16,8 @@ end
Ryo.each(slugs) do |surah_id, slug|
locales.each do |locale|
compile "/html/pages/surah/stream.html.erb", rep: "/#{locale}/#{slug}/index.html" do
name = i18n[locale].surahs.names[surah_id.to_i - 1]
title = "#{i18n[locale].TheNobleQuran}: #{name}"
filter(:erb, locals: {locale:, surah_id:, title:})
surah_name = i18n[locale].surahs.names[surah_id.to_i - 1]
filter(:erb, locals: {locale:, surah_id:, surah_name:})
write "/#{locale}/#{slug}/index.html"
end
end

View file

@ -1,9 +1,10 @@
<!DOCTYPE html>
<html lang="<%= locale %>">
<head>
<title><%= title %></title>
<title><%= t(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') %>">
<link rel="icon" href="/favicon.png">
<%= inline_css('/css/postman.scss') %>
</head>

View file

@ -1,9 +1,10 @@
<!DOCTYPE html>
<html lang="<%= locale %>">
<head>
<title><%= title %></title>
<title> <%= t(locale, "TheNobleQuran") %>: <%= surah_name %> </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<meta name="description" content="<%= t(locale, 'meta.stream.description', {surah_name:}) %>">
<link rel="icon" href="/favicon.png">
<%= inline_css('/css/postman.css') %>
</head>

View file

@ -5,6 +5,10 @@
"surah": "Surah",
"ayah": "Ayah",
"comma": ",",
"meta": {
"index": {"description": "Read and listen to The Noble Quran."},
"stream": {"description": "Read and listen to '%{surah_name}' from The Noble Quran."}
},
"surahs": {
"names": [
"The Opener",
@ -130,6 +134,10 @@
"surah": "سورة",
"ayah": "آية",
"comma": "،",
"meta": {
"index": {"description": "اقرأ واستمع إلى القرآن الكريم."},
"stream": {"description": "اقرأ واستمع إلى '%{surah_name}' من القرآن الكريم."}
},
"surahs": {
"names": [
"الفاتحة",
@ -249,4 +257,4 @@
]
}
}
}
}