Templatize lists, tags and single page (#8)

This commit is contained in:
Yash Mehrotra
2021-05-29 19:14:36 +05:30
committed by GitHub
parent e04f39b245
commit 5240bc3e8d
9 changed files with 130 additions and 42 deletions

View File

@@ -2,6 +2,7 @@
title: "First Post"
date: 2021-05-15T23:39:49+05:30
tags: ["abc", "def"]
type: post
---
Yo yo yo

View File

@@ -0,0 +1,24 @@
---
title: "Second Post"
date: 2021-04-15T23:39:49+05:30
tags: ["xyz", "def"]
type: "post"
---
Yo yo yo
# This is a heading
- And
- this
- is
- a
- list
```py
Codeblocks look like this
def print():
print('Hello world!')
```

View File

@@ -0,0 +1,24 @@
---
title: "Third Post"
date: 2020-04-15T23:39:49+05:30
tags: ["xyz"]
type: "post"
---
Yo yo yo
# This is a heading
- And
- this
- is
- a
- list
```py
Codeblocks look like this
def print():
print('Hello world!')
```

View File

@@ -0,0 +1,10 @@
---
title: "Tatooine"
date: 2021-05-12T23:39:49+05:30
tags: ["abc", "def"]
type: singles
---
### A long time ago in a galaxy far, far away....
A project was planned

View File

@@ -0,0 +1,13 @@
---
title: "Projects"
tags: ["abc", "def"]
type: singles
---
# Hello my projects are
1. Tatooine: [Link](/project/tatooine/)
2. is
3. my
4. project

View File

@@ -6,33 +6,28 @@
{{- partial "header.html" . -}}
<main id="content">
<!-- TODO: @yash Paginate this if items more than n -->
<div class="container list-posts">
<h2 class="list-title">All Posts</h2>
<h2 class="list-title">{{ .Name }}</h2>
<h2 class="posts-year">2021</h2>
<h4 class="posts-month">March</h4>
{{ $posts := where .Data.Pages "Params.type" "post" }}
{{ range $posts.GroupByDate "2006" }}
<h2 class="posts-year">{{ .Key }}</h2>
<!-- TODO: @yash The month param should be optional -->
{{ range .Pages.GroupByDate "January" }}
<h4 class="posts-month">{{ .Key }}</h4>
{{- range .Pages -}}
<article class="post-title">
<a href="example.com" class="post-link">Theme Documentation - Basics</a>
<span class="post-date">March 15, 2021</span>
</article>
<article class="post-title">
<a href="example.com" class="post-link">Theme Documentation - Built-in Shortcodes</a>
<span class="post-date">March 15, 2021</span>
</article>
<h2 class="posts-year">2019</h2>
<h4 class="posts-month">May</h4>
<article class="post-title">
<a href="example.com" class="post-link">Basic Markdown Syntax</a>
<span class="post-date">May 15, 2019</span>
</article>
<h4 class="posts-month">January</h4>
<article class="post-title">
<a href="example.com" class="post-link">Emoji Support</a>
<span class="post-date">January 19, 2019</span>
<a href="{{ .RelPermalink }}" class="post-link">{{ .Title }}</a>
<span class="post-date">{{ dateFormat "January 2, 2006" .Date }}</span>
</article>
{{ end }}
{{ end }}
{{ end }}
</div>
@@ -40,4 +35,4 @@
{{- partial "footer.html" . -}}
</body>
</html>
</html>

View File

@@ -6,27 +6,13 @@
{{- partial "header.html" . -}}
<main id="content">
<div class="post container">
{{ if eq .Type "post" }}
{{- partial "post.html" . -}}
{{ end }}
<div class="post-header-section">
<h1>{{ .Title }}</h1>
<p class="post-date">
{{ dateFormat "January 2, 2006" .Date }}
</p>
<ul class="post-tags">
{{ range .Params.tags }}
<li class="post-tag"><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a></li>
{{ end }}
</ul>
</div>
<div class="post-content">
<p>
{{ .Content }}
</p>
</div>
</div>
{{ if eq .Type "singles" }}
{{- partial "single.html" . -}}
{{ end }}
</main>
{{- partial "footer.html" . -}}

View File

@@ -0,0 +1,22 @@
<div class="post container">
<div class="post-header-section">
<h1>{{ .Title }}</h1>
<p class="post-date">
{{ dateFormat "January 2, 2006" .Date }}
</p>
<ul class="post-tags">
{{ range .Params.tags }}
<li class="post-tag"><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a></li>
{{ end }}
</ul>
</div>
<div class="post-content">
<p>
{{ .Content }}
</p>
</div>
</div>

View File

@@ -0,0 +1,13 @@
<div class="post container">
<div class="post-header-section">
<h1>{{ .Title }}</h1>
</div>
<div class="post-content">
<p>
{{ .Content }}
</p>
</div>
</div>