Skip to content

Commit

Permalink
fix: handle relative non-root baseURL (#25)
Browse files Browse the repository at this point in the history
This PR add support for non-root baseURL. By non-root, we mean URLs which are of the type example.com/path.
Prior to this, one could only use either apex domain (also known as a root, bare, or naked domain) like example.com or subdomain like www.example.com for baseURL.

Co-authored-by: Vladyslav Shurbin <2917600-kusyka911@users.noreply.gitlab.com>
  • Loading branch information
kusyka911 and Vladyslav Shurbin authored May 5, 2023
1 parent b1bb3e6 commit 058560e
Show file tree
Hide file tree
Showing 32 changed files with 129 additions and 83 deletions.
Binary file added assets/icons/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/apple-touch-icon-precomposed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions assets/icons/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="{{ (resources.Get "/icons/mstile-70x70.png").RelPermalink }}"/>
<square150x150logo src="{{ (resources.Get "/icons/mstile-150x150.png").RelPermalink }}"/>
<square310x310logo src="{{ (resources.Get "/icons/mstile-310x310.png").RelPermalink }}"/>
<wide310x150logo src="{{ (resources.Get "/icons/mstile-310x150.png").RelPermalink }}"/>
<TileColor>{{ .TileColor | default "#2d89ef" }}</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added assets/icons/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/favicon.ico
Binary file not shown.
File renamed without changes
Binary file added assets/icons/mstile-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/mstile-310x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/mstile-310x310.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/mstile-70x70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions assets/icons/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions assets/icons/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "{{ .name }}",
"short_name": "{{ .short_name }}",
"start_url": "{{ .start_url }}",
"theme_color": "{{ .theme_color }}",
"background_color": "{{ .background_color }}",
"display": "{{ .display }}",
"icons": [
{
"src": "{{ (resources.Get "/icons/android-chrome-192x192.png").RelPermalink }}",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "{{ (resources.Get "/icons/android-chrome-512x512.png").RelPermalink }}",
"sizes": "512x512",
"type": "image/png"
}
]
}
14 changes: 7 additions & 7 deletions assets/sass/_fonts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url('/fonts/Roboto/roboto-v30-latin-regular.eot'); /* IE9 Compat Modes */
src: url('/fonts/Roboto/roboto-v30-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/fonts/Roboto/roboto-v30-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('/fonts/Roboto/roboto-v30-latin-regular.woff') format('woff'), /* Modern Browsers */
url('/fonts/Roboto/roboto-v30-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('/fonts/Roboto/roboto-v30-latin-regular.svg#Roboto') format('svg'); /* Legacy iOS */
}
src: url(fonts/Roboto/roboto-v30-latin-regular.eot); /* IE9 Compat Modes */
src: url(fonts/Roboto/roboto-v30-latin-regular.eot?#iefix) format('embedded-opentype'), /* IE6-IE8 */
url(fonts/Roboto/roboto-v30-latin-regular.woff2) format('woff2'), /* Super Modern Browsers */
url(fonts/Roboto/roboto-v30-latin-regular.woff) format('woff'), /* Modern Browsers */
url(fonts/Roboto/roboto-v30-latin-regular.ttf) format('truetype'), /* Safari, Android, iOS */
url(fonts/Roboto/roboto-v30-latin-regular.svg#Roboto) format('svg'); /* Legacy iOS */
}
13 changes: 13 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ enableEmoji = true
name = "Sidharth R"
description = "A fast, minimalistic Hugo theme with light and dark mode support, for running a personal site or blog"

# Allow to override webmanifest options
[params.webmanifest]
name = "sitename" # will use "params.sitename" or "title" by default
short_name = "sitename" # same as name
start_url = "/" # will use homepage url by default
theme_color = "#434648" # default is "#434648" (base color of text). Also will override html `<meta name="theme-color" />`
background_color = "#fff" # by default depend on "params.defaultColor" for "light" or "auto" will be set to "#fff" for dark will be "#131418" (color of dark mode background)
display = "standalone"

# Allow to override `browserconfig.xml` params (configuration for windows embeded browsers)
[params.browserconfig]
TileColor = "#2d89ef" # default windows 10 blue tile color

[[params.socialIcons]]
name = "github"
url = "https://github.com/hugo-sid"
Expand Down
8 changes: 8 additions & 0 deletions layouts/partials/browserconfig.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{
$ctx := merge (.Site.Params.browserconfig | default dict)
(dict
"TileColor" (.Site.Params.browserconfig.TileColor | default "#2d89ef" )
)
}}
<meta name="msapplication-config" content="{{ (resources.Get "icons/browserconfig.xml" | resources.ExecuteAsTemplate "browserconfig.xml" $ctx).RelPermalink }}">
<meta name="msapplication-TileColor" content="{{ $ctx.TileColor }}">
22 changes: 11 additions & 11 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@

{{- /* Styles */ -}}

{{- $style := resources.Get "sass/main.scss" | resources.ExecuteAsTemplate "style.scss" . | toCSS | minify | fingerprint }}
{{- $style := resources.Get "sass/main.scss" | resources.ExecuteAsTemplate "style.scss" . | toCSS (dict "targetPath" "style.css") | minify | fingerprint }}
<link href="{{ $style.RelPermalink }}" rel="stylesheet">
{{- $code_syntax_highlight_css := resources.Get "code-highlight.css" | minify | fingerprint }}
<link href="{{ $code_syntax_highlight_css.RelPermalink }}" rel="stylesheet">

{{/* Favicons */}}
<link rel="apple-touch-icon" sizes="180x180" href="{{ (resources.Get "icons/apple-touch-icon.png").RelPermalink }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ (resources.Get "icons/favicon-32x32.png").RelPermalink }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ (resources.Get "icons/favicon-16x16.png").RelPermalink }}">
<link rel="mask-icon" href="{{ (resources.Get "icons/safari-pinned-tab.svg").RelPermalink }}">
<link rel="shortcut icon" href="{{ (resources.Get "icons/favicon.ico" | resources.Copy "favicon.ico").RelPermalink }}">

<link rel="apple-touch-icon" sizes="180x180" href="/images/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon/favicon-16x16.png">
<link rel="manifest" href="/images/favicon/site.webmanifest">
<link rel="mask-icon" href="/images/favicon/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/images/favicon/favicon.ico">
<meta name="msapplication-TileColor" content="#2b5797">
<meta name="msapplication-config" content="/images/favicon/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
{{- partial "webmanifest.html" . -}}
{{- partial "browserconfig.html" . -}}

<meta name="theme-color" content="{{ .Site.Params.webmanifest.theme_color | default "#434648" }}">

{{/* SVG favicon for the modern web */}}
<link rel="icon" type="image/svg+xml" href="/images/favicon/favicon.svg">
<link rel="icon" type="image/svg+xml" href="{{ (resources.Get "icons/favicon.svg").RelPermalink }}">

{{/* Katex support (enabled on specific pages). See 'helpers/katex.html' for more info. */}}

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/header.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="navbar" role="navigation">
<nav class="menu" aria-label="Main Navigation">
<a href="/" class="logo">
<a href="{{ .Site.Home.Permalink }}" class="logo">
{{ partial "svgs/home.svg" (dict "height" 25 "width" 25) . }}
</a>
<input type="checkbox" id="menu-trigger" class="menu-trigger" />
Expand Down
26 changes: 26 additions & 0 deletions layouts/partials/webmanifest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{ define "partials/hugo-blog-awesome/manifest-background-color" }}
{{ $bg := ""}}
{{ if isset .Site.Params.webmanifest "background_color" }}
{{ $bg = .Site.Params.webmanifest.background_color }}
{{ else if eq .Site.Params.defaultColor "dark" }}
{{ $bg = "#131418" }}
{{ else }}
{{ $bg = "#ffffff"}}
{{ end}}
{{ return $bg }}
{{ end }}

{{ $background_color := partial "hugo-blog-awesome/manifest-background-color" . }}

{{
$ctx := merge (.Site.Params.webmanifest | default dict)
(dict
"name" (.Site.Params.webmanifest.name | default .Site.Params.sitename | default .Site.Title)
"short_name" (.Site.Params.webmanifest.short_name | default .Site.Params.sitename | default .Site.Title)
"start_url" (.Site.Params.webmanifest.start_url | default .Site.Home.Permalink)
"theme_color" (.Site.Params.webmanifest.theme_color | default "#434648")
"background_color" $background_color
"display" (.Site.Params.webmanifest.display | default "standalone")
)
}}
<link rel="manifest" href="{{ (resources.Get "icons/site.webmanifest" | resources.ExecuteAsTemplate "site.webmanifest" $ctx).Permalink }}">
Binary file removed static/images/favicon/android-chrome-192x192.png
Binary file not shown.
Binary file removed static/images/favicon/android-chrome-512x512.png
Binary file not shown.
Binary file removed static/images/favicon/apple-touch-icon.png
Binary file not shown.
9 changes: 0 additions & 9 deletions static/images/favicon/browserconfig.xml

This file was deleted.

Binary file removed static/images/favicon/favicon-16x16.png
Binary file not shown.
Binary file removed static/images/favicon/favicon-32x32.png
Binary file not shown.
Binary file removed static/images/favicon/favicon.ico
Binary file not shown.
Binary file removed static/images/favicon/mstile-150x150.png
Binary file not shown.
36 changes: 0 additions & 36 deletions static/images/favicon/safari-pinned-tab.svg

This file was deleted.

19 changes: 0 additions & 19 deletions static/images/favicon/site.webmanifest

This file was deleted.

0 comments on commit 058560e

Please sign in to comment.