Make use of proper relURL everywhere so site works in sub directory. Fix for setting custom height in figure shortcode.

This commit is contained in:
Fredrik Jonsson 2017-11-24 11:39:58 +01:00
commit 73cc0bfc89
8 changed files with 21 additions and 12 deletions

View file

@ -66,6 +66,7 @@ params:
feedlinks: true # Show feed links in the footer.
footer: "A [example.org](https://example.org/) production."
icon: "" # Relative path to icon in json feed, no leading slash.
imageMaxWidth: "" # Max width for images added via figure shortcode.
jquery: true # Add jQuery
languageDir: "" # Set ltr or rtl, defaults to ltr.
logo: false # Turn off the logo.

View file

@ -14,9 +14,9 @@
<body>
<div class="page layout__page{{ if $.Param "sidebar" | default true }} layout__sidebar-second{{ end }}">
<header class="header layout__header" role="banner">
{{ if $.Param "logo" | default true }}<a href="{{ .Site.BaseURL }}" title="Home" rel="home" class="header__logo"><img src="/images/logo.png" alt="Home" class="header__logo-image"></a>{{ end }}
{{ if $.Param "logo" | default true }}<a href="{{ "/" | relURL }}" title="Home" rel="home" class="header__logo"><img src="{{ "/images/logo.png" | relURL }}" alt="Home" class="header__logo-image"></a>{{ end }}
<h1 class="header__site-name">
<a href="{{ .Site.BaseURL }}" title="Home" class="header__site-link" rel="home"><span>{{ .Site.Title }}</span></a>
<a href="{{ "/" | relURL }}" title="Home" class="header__site-link" rel="home"><span>{{ .Site.Title }}</span></a>
</h1>
<div class="region header__region">{{ if $.Param "search" }}{{ partialCached "search.html" . }}{{ end }}</div>
</header>

View file

@ -1,11 +1,12 @@
{{ $home := relURL "/" }}
{{ $currentSection := .Section }}
{{ $currentID := .UniqueID }}
<nav class="main-menu layout__navigation" role="navigation">
<h2 class="visually-hidden">{{ i18n "menu_title" }}</h2>
<ul class="navbar">
<li><a class="{{ if .IsHome }}active{{ end }}" href="/">{{ i18n "menu_home" }}</a></li>
<li><a class="{{ if .IsHome }}active{{ end }}" href="{{ $home }}">{{ i18n "menu_home" }}</a></li>
{{ range where .Site.Pages "Section" "" -}}
{{ if ne .RelPermalink "/" -}}
{{ if ne .RelPermalink (string $home) -}}
<li><a class="{{ if eq $currentID .UniqueID }}active{{ end }}" href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end -}}
{{ end -}}

View file

@ -1,4 +1,4 @@
{{ .Hugo.Generator }}
{{ with $.Param "contact" }}<meta name="contact" content="{{ . }}">{{ end }}
<link rel="canonical" href="{{ .Permalink }}">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="apple-touch-icon" href="{{ "/apple-touch-icon.png" | relURL }}">

View file

@ -1,3 +1,3 @@
<link rel="preload" as="style" href="/css/styles.css{{ if $.Param "cacheBustCSS" }}?{{ readFile "/public/css/styles.css" | sha1 }}{{ end }}">
<link rel="stylesheet" href="/css/styles.css{{ if $.Param "cacheBustCSS" }}?{{ readFile "/public/css/styles.css" | sha1 }}{{ end }}">
<link rel="stylesheet" href="/css/print.css" media="print">
<link rel="preload" as="style" href="{{ "/css/styles.css" | relURL }}{{ if $.Param "cacheBustCSS" }}?{{ readFile "/public/css/styles.css" | sha1 }}{{ end }}">
<link rel="stylesheet" href="{{ "/css/styles.css" | relURL }}{{ if $.Param "cacheBustCSS" }}?{{ readFile "/public/css/styles.css" | sha1 }}{{ end }}">
<link rel="stylesheet" href="{{ "/css/print.css" | relURL }}" media="print">

View file

@ -1 +1 @@
{{ if $.Param "jquery" }}<script src="/js/jquery.slim.min.js"></script>{{ end }}
{{ if $.Param "jquery" }}<script src="{{ "/js/jquery.slim.min.js" | relURL }}"></script>{{ end }}

View file

@ -1 +1 @@
{{ if $.Param "jquery" }}<script src="/js/script.js{{ if $.Param "cacheBustJS" }}?{{ readFile "/public/js/script.js" | sha1 }}{{ end }}"></script>{{ end }}
{{ if $.Param "jquery" }}<script src="{{ "/js/script.js" | relURL }}{{ if $.Param "cacheBustJS" }}?{{ readFile "/public/js/script.js" | sha1 }}{{ end }}"></script>{{ end }}

View file

@ -7,16 +7,23 @@
{{ end -}}
{{ if (.Get "width") -}}
{{ $.Scratch.Set "width" (int (.Get "width")) -}}
{{ else if lt $maxwidth ($.Scratch.Get "width") -}}
{{ else if and $maxwidth (lt $maxwidth ($.Scratch.Get "width")) -}}
{{ $.Scratch.Set "width" $maxwidth -}}
{{ end -}}
{{ if lt ($.Scratch.Get "width") ($.Scratch.Get "realwidth") -}}
{{ $height := (mul ($.Scratch.Get "realheight") (div (add ($.Scratch.Get "width") 0.0) ($.Scratch.Get "realwidth"))) -}}
{{ $.Scratch.Set "height" (int $height) -}}
{{ end -}}
{{ if (.Get "height") -}}
{{ $.Scratch.Set "height" (int (.Get "height")) -}}
{{ end -}}
{{ if lt ($.Scratch.Get "height") ($.Scratch.Get "realheight") -}}
{{ $width := (mul ($.Scratch.Get "realwidth") (div (add ($.Scratch.Get "height") 0.0) ($.Scratch.Get "realheight"))) -}}
{{ $.Scratch.Set "width" (int $width) -}}
{{ end -}}
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link" }}<a href="{{.}}">{{ end -}}
<img src="{{ $.Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" }}{{ end }}"{{ end }}{{ with $.Scratch.Get "width" }} width="{{.}}"{{ end }}{{ with $.Scratch.Get "height" }} height="{{.}}"{{ end }}>
<img src="{{ $.Get "src" | relURL }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" }}{{ end }}"{{ end }}{{ with $.Scratch.Get "width" }} width="{{.}}"{{ end }}{{ with $.Scratch.Get "height" }} height="{{.}}"{{ end }}>
{{- if .Get "link" }}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
<figcaption>{{ if isset .Params "title" }}