Order sections on homepage by weigth (#143)

This commit is contained in:
Maximilian Bosche 2019-04-10 14:41:06 +02:00 committed by Hanzei
parent f223f10314
commit 5712e49125
14 changed files with 33 additions and 15 deletions

View file

@ -95,6 +95,7 @@ hugo new projects/_index.md
```
Add a `title` and some optional content to the file.
Add an optional `weight` for ordering projects section.
To create a project, run:
@ -122,6 +123,7 @@ Create an index file for the blog:
```
hugo new blog/_index.md
```
Add an optional `weight` for ordering blog section on your homepage
Create a new blog post with:

View file

@ -1,5 +1,6 @@
---
title: "Blog"
weight: 20
---
Ein Einleitungstext für meinen Blog

View file

@ -1,7 +1,7 @@
---
title: "Über mich"
image: "profile.jpg"
weight: 0
weight: 8
---
Dies ist **Vorstellung**, ein minimales Webseiten Theme für [Hugo](https://gohugo.io)

View file

@ -1,6 +1,6 @@
---
title: "Lorem Ipsum"
weight: 1
weight: 30
---
Weitere Abschnitte für die Hauptseiten können hinzugefügt werden, indem Datein unter `content/home/` erstellt werden.

View file

@ -1,5 +1,6 @@
---
title: "Projekte"
weight: 10
---
Ein Einleitungstext für meinen Projekte

View file

@ -1,5 +1,6 @@
---
title: "Blog"
weight: 20
---
Here is some introduction text for my blog. You can set this text in the `/blog/_index.md` file. This page uses the `/layouts/blog/list.html` template.
Here is some introduction text for my blog. You can set this text in the `/blog/_index.md` file. This page uses the `/layouts/blog/list.html` template.

View file

@ -1,7 +1,7 @@
---
title: "About"
image: "profile.jpg"
weight: 0
weight: 8
---
This is **Introduction**, a minimalist website theme made for [Hugo](https://gohugo.io).
@ -14,4 +14,4 @@ This is **Introduction**, a minimalist website theme made for [Hugo](https://goh
* Any number of custom index page sections from Markdown files
* _Projects_ section with any number of projects: highly configurable as a photo gallery, modals, or external links
* _Blog_ section with optional _Latest Post_, on the main page or as a separate section
* Styled Markdown throughout with support for Hugo's syntax highlighting
* Styled Markdown throughout with support for Hugo's syntax highlighting

View file

@ -1,6 +1,6 @@
---
title: "Lorem Ipsum"
weight: 1
weight: 30
---
You can add more sections to the home page by adding files to the `/content/home/` folder.

View file

@ -1,5 +1,6 @@
---
title: "Projects"
weight: 10
---
Here is some introduction text for my projects. You can set this text in the `/projects/_index.md` file. This page uses the `/layouts/projects/list.html` template.
Here is some introduction text for my projects. You can set this text in the `/projects/_index.md` file. This page uses the `/layouts/projects/list.html` template.

View file

@ -1,5 +1,6 @@
---
title: "Blog"
weight: 20
---
Este es un texto introductorio para mi blog.

View file

@ -1,7 +1,7 @@
---
title: "Sobre"
image: "profile.jpg"
weight: 0
weight: 8
---
Esto es **Introducción**, un tema mínimo con desplazamiento para sitios web hechos con [Hugo](https://gohugo.io).

View file

@ -1,6 +1,6 @@
---
title: "Lorem Ipsum"
weight: 1
weight: 30
---
You can add more sections to the home page by adding file to `content/home/`

View file

@ -1,5 +1,6 @@
---
title: "Proyectos"
weight: 10
---
Este es un texto introductorio para mis proyectos.

View file

@ -42,9 +42,22 @@
</section> <!-- Done with Hero -->
{{ with .Site.GetPage "/home" }}
{{ $blog := .Site.GetPage "/blog" }}
{{ $projects := .Site.GetPage "/projects" }}
{{ $home := . }}
{{ range sort (.Resources.ByType "page") "Params.weight" }}
{{ $pages := sort (.Resources.ByType "page" | append $blog | append $projects) "Params.weight" }}
{{ range $pages }}
{{ if ne .Name "contact.md" }}
{{ if eq .File.Dir "projects/" }}
<!-- Now for some cool projects -->
{{ partial "home/projects.html" . }}
{{ else if eq .File.Dir "blog/" }}
<!-- Let`s show some blog posts -->
{{ partial "home/blog.html" . }}
{{ else }}
<!-- Range through all sections in /home execept contact.md -->
<div class="section" id="{{ .File.TranslationBaseName }}">
<div class="container">
@ -76,10 +89,7 @@
</div>
{{ end }}
{{ end }}
<!-- Now for some cool projects -->
{{ partial "home/projects.html" . }}
<!-- Let`s show some blog posts -->
{{ partial "home/blog.html" . }}
{{ end }}
<!-- Let`s chat, shall we? -->
{{ with .Resources.GetMatch "contact.md" }}
<div class="section" id="{{ .File.TranslationBaseName }}">
@ -124,4 +134,4 @@
{{ end }}
</body>
</html>
</html>