From 676ba8a7bbaf087aa18168792451f0e5e54a7fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 6 Feb 2022 01:58:32 +0100 Subject: [PATCH] exampleSite: arrr, let pirrrates rrread sites from subfolder with canonifyURLs=false #163 --- exampleSite/content/basics/configuration/_index.en.md | 2 +- exampleSite/content/basics/customization/_index.en.md | 8 ++++---- exampleSite/content/basics/installation/_index.en.md | 2 +- exampleSite/content/basics/requirements/_index.en.md | 2 +- exampleSite/content/cont/i18n/_index.en.md | 2 +- exampleSite/content/cont/pages/_index.en.md | 6 +++--- exampleSite/layouts/shortcodes/piratify.html | 7 ++++++- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/exampleSite/content/basics/configuration/_index.en.md b/exampleSite/content/basics/configuration/_index.en.md index 17ad8c80f5..a76c619af3 100644 --- a/exampleSite/content/basics/configuration/_index.en.md +++ b/exampleSite/content/basics/configuration/_index.en.md @@ -134,4 +134,4 @@ landingPageName = " Home" The home button is going to look like this: -![Default Home Button](/basics/configuration/images/home_button_defaults.png?width=100%) +![Default Home Button](images/home_button_defaults.png?width=100%) diff --git a/exampleSite/content/basics/customization/_index.en.md b/exampleSite/content/basics/customization/_index.en.md index a31df5031e..122339264c 100644 --- a/exampleSite/content/basics/customization/_index.en.md +++ b/exampleSite/content/basics/customization/_index.en.md @@ -57,7 +57,7 @@ The Relearn theme let you choose between some predefined color scheme variants, themeVariant = "" ``` -![Red variant](/basics/customization/images/standard-variant.png?width=60pc) +![Red variant](images/standard-variant.png?width=60pc) ### Red variant @@ -67,7 +67,7 @@ The Relearn theme let you choose between some predefined color scheme variants, themeVariant = "red" ``` -![Red variant](/basics/customization/images/red-variant.png?width=60pc) +![Red variant](images/red-variant.png?width=60pc) ### Blue variant @@ -77,7 +77,7 @@ The Relearn theme let you choose between some predefined color scheme variants, themeVariant = "blue" ``` -![Blue variant](/basics/customization/images/blue-variant.png?width=60pc) +![Blue variant](images/blue-variant.png?width=60pc) ### Green variant @@ -87,7 +87,7 @@ The Relearn theme let you choose between some predefined color scheme variants, themeVariant = "green" ``` -![Green variant](/basics/customization/images/green-variant.png?width=60pc) +![Green variant](images/green-variant.png?width=60pc) ### 'Mine‘ variant diff --git a/exampleSite/content/basics/installation/_index.en.md b/exampleSite/content/basics/installation/_index.en.md index 292f26d081..e540e30f21 100644 --- a/exampleSite/content/basics/installation/_index.en.md +++ b/exampleSite/content/basics/installation/_index.en.md @@ -48,7 +48,7 @@ Discover what this Hugo theme is all about and the core concepts behind it. renders as -![A Chapter](/basics/installation/images/chapter.png?classes=shadow&width=60pc) +![A Chapter](images/chapter.png?classes=shadow&width=60pc) The Relearn theme provides archetypes to create skeletons for your website. Begin by creating your first chapter page with the following command diff --git a/exampleSite/content/basics/requirements/_index.en.md b/exampleSite/content/basics/requirements/_index.en.md index 3d15b9a914..65500c41ed 100755 --- a/exampleSite/content/basics/requirements/_index.en.md +++ b/exampleSite/content/basics/requirements/_index.en.md @@ -8,4 +8,4 @@ Thanks to the simplicity of Hugo, this page is as empty as this theme needs requ Just download latest version of [Hugo binary](https://gohugo.io/getting-started/installing/) for your OS (Windows, Linux, Mac) : it's that simple. -![Magic](/basics/requirements/images/magic.gif?classes=shadow) +![Magic](images/magic.gif?classes=shadow) diff --git a/exampleSite/content/cont/i18n/_index.en.md b/exampleSite/content/cont/i18n/_index.en.md index 727ea1c3fb..42ebda8125 100644 --- a/exampleSite/content/cont/i18n/_index.en.md +++ b/exampleSite/content/cont/i18n/_index.en.md @@ -11,7 +11,7 @@ It provides: - Automatic menu generation from multilingual content - In-browser language switching -![I18n menu](/cont/i18n/images/i18n-menu.gif) +![I18n menu](images/i18n-menu.gif) ## Basic configuration diff --git a/exampleSite/content/cont/pages/_index.en.md b/exampleSite/content/cont/pages/_index.en.md index ef2e917c27..e006634700 100644 --- a/exampleSite/content/cont/pages/_index.en.md +++ b/exampleSite/content/cont/pages/_index.en.md @@ -46,7 +46,7 @@ The Relearn theme defines two types of pages. *Default* and *Chapter*. Both can A **Chapter** displays a page meant to be used as introduction for a set of child pages. Commonly, it contains a simple title and a catch line to define content that can be found under it. You can define any HTML as prefix for the menu. In the example below, it's just a number but that could be an [icon](https://fortawesome.github.io/Font-Awesome/). -![Chapter page](/cont/pages/images/pages-chapter.png?width=50pc) +![Chapter page](images/pages-chapter.png?width=50pc) ```markdown +++ @@ -67,7 +67,7 @@ To tell the Relearn theme to consider a page as a chapter, set `chapter=true` in A **Default** page is any other content page. -![Default page](/cont/pages/images/pages-default.png?width=50pc) +![Default page](images/pages-default.png?width=50pc) ```toml +++ @@ -131,7 +131,7 @@ pre = " " +++ ``` -![Title with icon](/cont/pages/images/frontmatter-icon.png) +![Title with icon](images/frontmatter-icon.png) ### Ordering sibling menu/page entries diff --git a/exampleSite/layouts/shortcodes/piratify.html b/exampleSite/layouts/shortcodes/piratify.html index 2acac7648f..5530e04d0f 100644 --- a/exampleSite/layouts/shortcodes/piratify.html +++ b/exampleSite/layouts/shortcodes/piratify.html @@ -1,5 +1,7 @@ {{- $langsrc := .Get 1 | default "en" }} {{- $langtrg := .Page.Language.Lang }} +{{- $baseURL := urls.Parse .Site.BaseURL }} +{{- $baseURLpath := $baseURL.Path | default "/" }} {{- $words := dict "Hugo" "Cap'n Hugo" "Info" "Ahoi" @@ -70,7 +72,7 @@ "(\\w)(?:[aeiou])mizes([\\s\\n<.,;?!:])" "'mizes" "(\\w)(?:[aeiou])nize([\\s\\n<.,;?!:])" "'nize" "(\\w)(?:[aeiou])nizes([\\s\\n<.,;?!:])" "'nizes" - "(.)=\"/([^\".]*?\")" (printf "=\"/%s/" $langtrg) + (printf "(.)=\"%s([^\"]*?\")" $baseURLpath) (printf "=\"%s%s/" $baseURLpath $langtrg) }} {{- $fix := dict "warn'n" "warning" @@ -82,6 +84,7 @@ {{- $c := "" }} {{- range .Page.Translations }} {{- if eq .Language.Lang $langsrc }} + {{- $l := .RelPermalink }} {{- $c = .Content }} {{- range $from, $to := $words }} {{- $c = replaceRE (printf "([\\s\\n>])%s([\\s\\n<.,;?!:])" $from) (printf "${1}%s${2}" $to) $c }} @@ -92,6 +95,8 @@ {{- range $from, $to := $fix }} {{ $c = replace $c $from $to }} {{- end }} + {{- $c = replaceRE "(src|href)=\"(images/[^\"]*?\")" (printf "${1}=\"%s${2}" $l) $c }} + {{- $c = replaceRE "(src|href)=\"([^\"]*?)/pir/([^\"]*?.files/[^\"]*?\")" "${1}=\"${2}/${3}" $c }} {{- end }} {{- end }} {{- $c | safeHTML }} \ No newline at end of file