mirror of
https://git.adityakumar.xyz/hugo-theme-introduction.git
synced 2024-11-12 16:29:44 +00:00
Order sections on homepage by weigth (#143)
This commit is contained in:
parent
f223f10314
commit
5712e49125
14 changed files with 33 additions and 15 deletions
|
@ -95,6 +95,7 @@ hugo new projects/_index.md
|
||||||
```
|
```
|
||||||
|
|
||||||
Add a `title` and some optional content to the file.
|
Add a `title` and some optional content to the file.
|
||||||
|
Add an optional `weight` for ordering projects section.
|
||||||
|
|
||||||
To create a project, run:
|
To create a project, run:
|
||||||
|
|
||||||
|
@ -122,6 +123,7 @@ Create an index file for the blog:
|
||||||
```
|
```
|
||||||
hugo new blog/_index.md
|
hugo new blog/_index.md
|
||||||
```
|
```
|
||||||
|
Add an optional `weight` for ordering blog section on your homepage
|
||||||
|
|
||||||
Create a new blog post with:
|
Create a new blog post with:
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Blog"
|
title: "Blog"
|
||||||
|
weight: 20
|
||||||
---
|
---
|
||||||
|
|
||||||
Ein Einleitungstext für meinen Blog
|
Ein Einleitungstext für meinen Blog
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: "Über mich"
|
title: "Über mich"
|
||||||
image: "profile.jpg"
|
image: "profile.jpg"
|
||||||
weight: 0
|
weight: 8
|
||||||
---
|
---
|
||||||
|
|
||||||
Dies ist **Vorstellung**, ein minimales Webseiten Theme für [Hugo](https://gohugo.io)
|
Dies ist **Vorstellung**, ein minimales Webseiten Theme für [Hugo](https://gohugo.io)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Lorem Ipsum"
|
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.
|
Weitere Abschnitte für die Hauptseiten können hinzugefügt werden, indem Datein unter `content/home/` erstellt werden.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Projekte"
|
title: "Projekte"
|
||||||
|
weight: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
Ein Einleitungstext für meinen Projekte
|
Ein Einleitungstext für meinen Projekte
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Blog"
|
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.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: "About"
|
title: "About"
|
||||||
image: "profile.jpg"
|
image: "profile.jpg"
|
||||||
weight: 0
|
weight: 8
|
||||||
---
|
---
|
||||||
|
|
||||||
This is **Introduction**, a minimalist website theme made for [Hugo](https://gohugo.io).
|
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
|
* 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
|
* _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
|
* _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
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Lorem Ipsum"
|
title: "Lorem Ipsum"
|
||||||
weight: 1
|
weight: 30
|
||||||
---
|
---
|
||||||
|
|
||||||
You can add more sections to the home page by adding files to the `/content/home/` folder.
|
You can add more sections to the home page by adding files to the `/content/home/` folder.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Projects"
|
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.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Blog"
|
title: "Blog"
|
||||||
|
weight: 20
|
||||||
---
|
---
|
||||||
|
|
||||||
Este es un texto introductorio para mi blog.
|
Este es un texto introductorio para mi blog.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: "Sobre"
|
title: "Sobre"
|
||||||
image: "profile.jpg"
|
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).
|
Esto es **Introducción**, un tema mínimo con desplazamiento para sitios web hechos con [Hugo](https://gohugo.io).
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Lorem Ipsum"
|
title: "Lorem Ipsum"
|
||||||
weight: 1
|
weight: 30
|
||||||
---
|
---
|
||||||
|
|
||||||
You can add more sections to the home page by adding file to `content/home/`
|
You can add more sections to the home page by adding file to `content/home/`
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Proyectos"
|
title: "Proyectos"
|
||||||
|
weight: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
Este es un texto introductorio para mis proyectos.
|
Este es un texto introductorio para mis proyectos.
|
||||||
|
|
|
@ -42,9 +42,22 @@
|
||||||
</section> <!-- Done with Hero -->
|
</section> <!-- Done with Hero -->
|
||||||
|
|
||||||
{{ with .Site.GetPage "/home" }}
|
{{ with .Site.GetPage "/home" }}
|
||||||
|
|
||||||
|
{{ $blog := .Site.GetPage "/blog" }}
|
||||||
|
{{ $projects := .Site.GetPage "/projects" }}
|
||||||
{{ $home := . }}
|
{{ $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 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 -->
|
<!-- Range through all sections in /home execept contact.md -->
|
||||||
<div class="section" id="{{ .File.TranslationBaseName }}">
|
<div class="section" id="{{ .File.TranslationBaseName }}">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -76,10 +89,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<!-- Now for some cool projects -->
|
{{ end }}
|
||||||
{{ partial "home/projects.html" . }}
|
|
||||||
<!-- Let`s show some blog posts -->
|
|
||||||
{{ partial "home/blog.html" . }}
|
|
||||||
<!-- Let`s chat, shall we? -->
|
<!-- Let`s chat, shall we? -->
|
||||||
{{ with .Resources.GetMatch "contact.md" }}
|
{{ with .Resources.GetMatch "contact.md" }}
|
||||||
<div class="section" id="{{ .File.TranslationBaseName }}">
|
<div class="section" id="{{ .File.TranslationBaseName }}">
|
||||||
|
@ -124,4 +134,4 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue