From 789876a144c58cd4876913ac75c2024c643576a6 Mon Sep 17 00:00:00 2001
From: Osterberg <me@gummigroda.se>
Date: Fri, 31 Dec 2021 12:27:06 +0000
Subject: [PATCH] feat: Added page title switcher (#286)

---
 layouts/partials/head.html              |   14 ++++++++++----
 exampleSite/config/_default/params.toml |    1 +
 README.md                               |   10 ++++++++++
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 5885988..5113f19 100644
--- a/README.md
+++ b/README.md
@@ -743,6 +743,16 @@
 
 Please note that fields such as start, end, authors, and tags will only appear if they have been populated. The image path defined under `image` parameter is relative to the static folder, similarly to images included in the post.
 
+### Reverse Page Title
+
+By default, the title of pages is `Author | PageTitle`. You can switch the order to `PageTitle | Author` by setting the parameter `reversepagetitle` to `true` in `config.toml`.
+
+```toml
+[params]
+reversepagetitle = true
+
+```
+
 ## License
 
 Anatole is licensed under the [MIT license](https://github.com/lxndrblz/anatole/blob/master/LICENSE).
diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml
index b45c45f..e131c32 100644
--- a/exampleSite/config/_default/params.toml
+++ b/exampleSite/config/_default/params.toml
@@ -28,6 +28,7 @@
 # readMore = true
 # postSectionName = "blog"
 
+reversepagetitle = true # When set to 'true', the Window Title will be reversed to 'Title | Author' instead of the default 'Author | Title'
 
 [simpleAnalytics]
 # enable = true
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 524051b..5ac438b 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -1,12 +1,18 @@
 <head>
   <title>
-    {{ .Site.Params.author }}{{ with .Title }}
-      |
-      {{ . }}
+    {{ if (eq .Site.Params.reversepagetitle true) }}
+      {{ with .Title }}
+        {{ . }} |
 
+      {{ end }}{{ .Site.Params.author }}
+
+    {{ else }}
+      {{ .Site.Params.author }}{{ with .Title }}
+        | {{ . }}
+
+      {{ end }}
 
     {{ end }}
-
   </title>
 
   <!-- Meta -->

--
Gitblit v1.10.0