Replace hard-coded references with 'server.hostname'

This commit is contained in:
0x1eef 2024-05-25 22:27:28 -03:00
parent 8c2f4df663
commit f9282c1345
8 changed files with 36 additions and 19 deletions

View file

@ -5,10 +5,10 @@ This repository contains the source code of
a static website for reading (and listening to)
The Noble Quran. After the website is built,
the build directory consists of HTML, CSS, JavaScript
and other static assets that can be hosted by nginx,
apache, etc.
and other static assets that can be hosted by
a web server such as nginx, apache, etc.
## Environment
## Requirements
The following languages and tools have to be
installed to build the website from source:
@ -40,6 +40,17 @@ kept in this repository.
# Start web server
rake server
## Configuration
If you plan to host the website on your own domain
you will probably want to update
[nanoc.yaml](nanoc.yaml)
first. Largely for SEO reasons certain links will
reference the hostname al-quran.reflectslight.io.
Those links can be updated to your own domain by
changing the `server.hostname` field in
[nanoc.yaml](nanoc.yaml).
## Thanks
Alhamdulillah
@ -56,4 +67,4 @@ Alhamdulillah
## License
The "source code" is released under the terms of the GPL <br>
See [./LICENSE](./LICENSE) for details
See [LICENSE](./LICENSE) for details

View file

@ -21,6 +21,7 @@ data_sources:
layouts_dir: src/layouts
server:
hostname: al-quran.reflectslight.io
unix:
path: /tmp/al-quran.reflectslight.io
tcp:

View file

@ -19,10 +19,15 @@ module Mixin
end
def build_dir
@build_dir ||= begin
nanoc = Ryo.from YAML.load_file(File.join(Dir.getwd, "nanoc.yaml"))
nanoc.output_dir
end
def hostname
nanoc.server.hostname
end
def nanoc
@nanoc ||= Ryo.from YAML.load_file(File.join(Dir.getwd, "nanoc.yaml"))
end
include T

View file

@ -6,12 +6,12 @@
<%= erb("_revision.html.erb") %>
<link
rel="canonical"
href="https://al-quran.reflectslight.io/<%= locale %>/random/"
href="https://<%= hostname %>/<%= locale %>/random/"
/>
<% locales.each do |locale| %>
<link
rel="alternate"
href="https://al-quran.reflectslight.io/<%= locale %>/random/"
href="https://<%= hostname %>/<%= locale %>/random/"
hreflang="<%= locale %>" />
<% end %>
<%= erb("_favicon.html.erb") %>

View file

@ -6,12 +6,12 @@
<%= opengraph(Ryo(filename: "redirect.html.erb", locale: "en")) %>
<link
rel="canonical"
href="https://al-quran.reflectslight.io/en/"
href="https://<%= hostname %>/en/"
/>
<% locales.each do |locale| %>
<link
rel="alternate"
href="https://al-quran.reflectslight.io/<%= locale %>/"
href="https://<%= hostname %>/<%= locale %>/"
hreflang="<%= locale %>" />
<% end %>
<%= erb("_favicon.html.erb") %>

View file

@ -10,11 +10,11 @@
<%= opengraph(context) %>
<link
rel="canonical"
href="https://al-quran.reflectslight.io/<%= locale %>/"
href="https://<%= hostname %>/<%= locale %>/"
/>
<% locales.each do |locale| %>
<link rel="alternate"
href="https://al-quran.reflectslight.io/<%= locale %>/"
href="https://<%= hostname %>/<%= locale %>/"
hreflang="<%= locale %>" />
<% end %>
<%= erb("_favicon.html.erb") %>

View file

@ -10,11 +10,11 @@
<%= opengraph(context) %>
<link
rel="canonical"
href="https://al-quran.reflectslight.io/<%= locale %>/<%= surah.slug %>/"
href="https://<%= hostname %>/<%= locale %>/<%= surah.slug %>/"
/>
<% locales.each do |locale| %>
<link rel="alternate"
href="https://al-quran.reflectslight.io/<%= locale %>/<%= surah.slug %>/"
href="https://<%= hostname %>/<%= locale %>/<%= surah.slug %>/"
hreflang="<%= locale %>" />
<% end %>
<%= erb("_favicon.html.erb") %>

View file

@ -3,19 +3,19 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<% locales.each do |locale| %>
<url>
<loc>https://al-quran.reflectslight.io/<%= locale %>/</loc>
<loc>https://<%= hostname %>/<%= locale %>/</loc>
<priority>1.0</priority>
<changefreq>weekly</changefreq>
</url>
<% Ryo.each(name_by_id) do |_, transliterated_name| %>
<url>
<loc>https://al-quran.reflectslight.io/<%= locale %>/<%= transliterated_name %>/</loc>
<loc>https://<%= hostname %>/<%= locale %>/<%= transliterated_name %>/</loc>
<priority>0.8</priority>
<changefreq>weekly</changefreq>
</url>
<% end %>
<url>
<loc>https://al-quran.reflectslight.io/<%= locale %>/random/</loc>
<loc>https://<%= hostname %>/<%= locale %>/random/</loc>
<priority>0.7</priority>
<changefreq>weekly</changefreq>
</url>