Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bjacquemet/personal-web.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste Jacquemet <baptiste.jacquemet@gmail.com>2019-05-16 13:11:50 +0300
committerBaptiste Jacquemet <baptiste.jacquemet@gmail.com>2019-05-16 13:11:50 +0300
commita64b3904cab50ae2fe9d58c29ea47dc21b613d06 (patch)
tree2c244940d8510d82fafde427174543ad05a242ac
parent01d8a6bb10f074e08550a7cde84b37e2aeb83355 (diff)
parent9d9842c2c3809cca04fd6fef14ebb4426e8761a2 (diff)
Merge branch 'master' of https://github.com/bjacquemet/personal-web
-rw-r--r--exampleSite/config.toml2
-rw-r--r--exampleSite/content/post/config-file.md10
-rw-r--r--layouts/404.html14
-rw-r--r--layouts/index.html8
4 files changed, 22 insertions, 12 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 35444a4..952b4fb 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -23,12 +23,12 @@ pygmentsCodeFences=true
[params]
breadcrumb = true
accentColor = "#FD3519"
+ mainSections = ['portfolio'] # values: ['post', 'portfolio'] only accept one section, to be displayed bellow 404
[params.notFound]
gopher = "/images/gopher.png" # checkout https://gopherize.me/
h1 = 'Bummer!'
p = "It seems that this page doesn't exist."
- mainSection = 'portfolio' # values: [post, portfolio] only accept one section, to be displayed bellow 404
[params.sections]
# Define how your sections will be called
diff --git a/exampleSite/content/post/config-file.md b/exampleSite/content/post/config-file.md
index 89a69df..cd237f2 100644
--- a/exampleSite/content/post/config-file.md
+++ b/exampleSite/content/post/config-file.md
@@ -37,12 +37,12 @@ pygmentsCodeFences=true
[params]
breadcrumb = true
accentColor = "#FD3519"
+ mainSections = ['portfolio']
[params.notFound]
gopher = "/images/gopher.png"
h1 = 'Bummer!'
p = "It seems that this page doesn't exist."
- mainSection = 'portfolio'
[params.sections]
post = "article"
@@ -129,7 +129,9 @@ You can also customize the params with the `params.sidebar` parameters. The `co
## 404
The 404 page is defined within the `params.notFound` section.
-The `gopher`, `h1` and `p` params define the image and texts displayed on the page. The `mainSection` params possible values are 'portfolio' or 'post': it defines the section highlighted on the page.
+The `gopher`, `h1` and `p` params define the image and texts displayed on the page.
+
+In the `[params]` section, the `mainSections` params possible values are 'portfolio' or 'post': it defines the section highlighted on the page.
NB: to see the 404 page from your development env, check `/404.html`.
@@ -138,7 +140,9 @@ NB: to see the 404 page from your development env, check `/404.html`.
gopher = "/images/gopher.png"
h1 = 'Bummer!'
p = "It seems that this page doesn't exist."
- mainSection = 'portfolio'
+
+[params]
+ mainSections = ['portfolio']
```
You can also define how the post and portfolio sections will be named on the 404 page, thanks to the `params.sections` params.
diff --git a/layouts/404.html b/layouts/404.html
index ddc4b8e..765e1e2 100644
--- a/layouts/404.html
+++ b/layouts/404.html
@@ -4,19 +4,23 @@
<p>{{ .Site.Params.notFound.p }}</p>
<img src="{{ .Site.Params.notFound.gopher }}" alt="gopher" title="gopher" class="gopher" />
-{{ if .Site.Params.notFound.mainSection }}
+{{ if .Site.Params.mainSections }}
{{ $scratch := newScratch }}
- {{ if eq .Site.Params.notFound.mainSection "portfolio" }}
+ {{ if in .Site.Params.mainSections "portfolio" }}
{{ $scratch.Set "section" .Site.Params.sections.portfolio }}
{{ else }}
{{ $scratch.Set "section" (.Site.Params.sections.post) }}
{{ end }}
<p>While you're here, you can check out my last {{ $scratch.Get "section" }}:</p>
- {{ $pages := where site.RegularPages.ByPublishDate.Reverse "Type" "in" .Site.Params.notFound.mainSection }}
+ {{ $pages := where site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ range first 1 $pages }}
- {{ partial (printf "%s/item.html" .Site.Params.notFound.mainSection) . }}
- {{end}}
+ {{ if in .Site.Params.mainSections "portfolio" }}
+ {{ partial "portfolio/item" .}}
+ {{ else if in .Site.Params.mainSections "post" }}
+ {{ partial "post/item" .}}
+ {{ end }}
+ {{ end }}
{{end}}
{{ partial "footer" .}}
diff --git a/layouts/index.html b/layouts/index.html
index 526453a..bbca958 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -4,11 +4,13 @@
{{ .Content }}
<h2>My Latest Job</h2>
- {{ $pages := where site.RegularPages.ByPublishDate.Reverse "Type" "in" .Site.Params.notFound.mainSection }}
+ {{ $pages := where site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ range first 1 $pages }}
- <div class="portfolio-list">
+ {{ if in .Site.Params.mainSections "portfolio" }}
{{ partial "portfolio/item" .}}
- </div>
+ {{ else if in .Site.Params.mainSections "post" }}
+ {{ partial "post/item" .}}
+ {{ end }}
{{ end }}
{{ partial "footer" .}}