Add option to show posts on Homepage (#31)

* Add recent posts to Homepage

* Add different content posts

* Update html and css

* Add basic doc in README

* Update README

* Use partial

* Update page content
This commit is contained in:
Yash Mehrotra
2021-07-19 20:30:35 +05:30
committed by GitHub
parent 81ee72eb46
commit 5a1959c930
15 changed files with 1454 additions and 100 deletions

View File

Before

Width:  |  Height:  |  Size: 5.9 MiB

After

Width:  |  Height:  |  Size: 5.9 MiB

View File

@@ -2,7 +2,7 @@
A minimal opinionated theme for Hugo
![Gokarna theme](/docs/screenshot.png)
![Gokarna theme](/.project/screenshot.png)
## Features
@@ -21,7 +21,7 @@ A minimal opinionated theme for Hugo
The theme is inspired by and accordingly named after [Gokarna](https://en.wikipedia.org/wiki/Gokarna,_Karnataka), a small and peaceful beach town on the west coast on India.
![Gokarna](/docs/gokarna.jpg)
![Gokarna](/.project/gokarna.jpg)
## Installation
@@ -35,8 +35,9 @@ git submodule add https://github.com/526avijitgupta/gokarna.git themes/gokarna
- Navbar
- Footer
- Inject html (Give example)
- Syntax highlighting (Choose one of emacs, trac, perldoc)
- Syntax highlighting (Choose from https://xyproto.github.io/splash/docs/all.html)
- Avatar sizes
- Option to show posts on homepage (Choose one of [popular|recent])
## LICENSE

View File

@@ -3,6 +3,7 @@ title = "Gokarna"
theme = "gokarna"
languageCode = "en"
defaultContentLanguage = "en"
enableEmoji = true
paginate = 20
@@ -14,6 +15,7 @@ pygmentsStyle = "emacs"
description = "You miss 100% of the shots you don't take"
avatarURL = "https://upload.wikimedia.org/wikipedia/commons/7/7a/1859-Martinique.web.jpg"
customHTML = ""
showPostsOnHomePage = "popular"
[menu]
[[menu.main]]

File diff suppressed because it is too large Load Diff

View File

@@ -1,61 +0,0 @@
---
title: "First Post"
date: 2021-05-15T23:39:49+05:30
tags: ["abc", "def"]
type: post
---
Yo yo yo
# This is a heading
- And
- this
- is
- a
- list
1. This
2. is
3. a
4. numbered
5. list
> And this is a really really really really really long blockquote which spans across multple lines
One importnant thing to keep in mind is that using multi-stage will not impact the build time of your container, the time difference between the build times is negligible
| Language | Normal | Multi-Stage |
|-------|----------------|-------|
| Python | 274 MB | 84.5 MB |
| Golang | 829 MB | 15.3MB |
Multi-stage builds are useful where space is a constraint, and whilst it is always better to build small concise containers, it is easy to get carried away trying to shave off a few megabytes. Even though they are great to use, they shouldnt be abused, the effort should always spent be towards improving the workflow.
```py
# Codeblocks look like this
def print():
print('Hello world!')
```
```golang
package main
import (
"fmt"
)
// This is a comment
func main () {
fmt.Println("Hello, world!")
}
```
```bash
PATH=$HOME
cat $HOME/file.txt | while read -n data; do
echo $data
done
```

View File

@@ -1,8 +1,9 @@
---
title: "Second Post"
title: "Lorem Ipsum"
date: 2021-04-15T23:39:49+05:30
tags: ["xyz", "def"]
type: "post"
weight: 3
---
# Heading 1

View File

@@ -0,0 +1,139 @@
---
title: "Markdown Syntax Guide"
date: 2019-06-01T17:55:28+08:00
description: "Sample article showcasing basic Markdown syntax and formatting for HTML elements."
tags: ["markdown", "css", "html"]
type: post
---
This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme.
<!--more-->
## Headings
The following HTML `<h1>``<h6>` elements represent six levels of section headings. `<h1>` is the highest section level while `<h6>` is the lowest.
# H1
## H2
### H3
#### H4
##### H5
###### H6
## Paragraph
Xerum, quo qui aut unt expliquam qui dolut labo. Aque venitatiusda cum, voluptionse latur sitiae dolessi aut parist aut dollo enim qui voluptate ma dolestendit peritin re plis aut quas inctum laceat est volestemque commosa as cus endigna tectur, offic to cor sequas etum rerum idem sintibus eiur? Quianimin porecus evelectur, cum que nis nust voloribus ratem aut omnimi, sitatur? Quiatem. Nam, omnis sum am facea corem alique molestrunt et eos evelece arcillit ut aut eos eos nus, sin conecerem erum fuga. Ri oditatquam, ad quibus unda veliamenimin cusam et facea ipsamus es exerum sitate dolores editium rerore eost, temped molorro ratiae volorro te reribus dolorer sperchicium faceata tiustia prat.
Itatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sapicia is sinveli squiatum, core et que aut hariosam ex eat.
## Blockquotes
The blockquote element represents content that is quoted from another source, optionally with a citation which must be within a `footer` or `cite` element, and optionally with in-line changes such as annotations and abbreviations.
#### Blockquote without attribution
> Tiam, ad mint andaepu dandae nostion secatur sequo quae.
> **Note** that you can use *Markdown syntax* within a blockquote.
#### Blockquote with attribution
> Don't communicate by sharing memory, share memory by communicating.<br>
> — <cite>Rob Pike[^1]</cite>
[^1]: The above quote is excerpted from Rob Pike's [talk](https://www.youtube.com/watch?v=PAAkCSZUG1c) during Gopherfest, November 18, 2015.
## Tables
Tables aren't part of the core Markdown spec, but Hugo supports them out-of-the-box.
Name | Age
--------|------
Bob | 27
Alice | 23
#### Inline Markdown within tables
| Italics | Bold | Code |
| -------- | -------- | ------ |
| *italics* | **bold** | `code` |
## Code Blocks
#### Code block with backticks
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example HTML5 Document</title>
</head>
<body>
<p>Test</p>
</body>
</html>
```
#### Code block indented with four spaces
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example HTML5 Document</title>
</head>
<body>
<p>Test</p>
</body>
</html>
#### Code block with Hugo's internal highlight shortcode
{{< highlight html >}}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example HTML5 Document</title>
</head>
<body>
<p>Test</p>
</body>
</html>
{{< /highlight >}}
## List Types
#### Ordered List
1. First item
2. Second item
3. Third item
#### Unordered List
* List item
* Another item
* And another item
#### Nested list
* Fruit
* Apple
* Orange
* Banana
* Dairy
* Milk
* Cheese
## Other Elements — abbr, sub, sup, kbd, mark
<abbr title="Graphics Interchange Format">GIF</abbr> is a bitmap image format.
H<sub>2</sub>O
X<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>
Press <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>Delete</kbd></kbd> to end the session.
Most <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.

View File

@@ -1,23 +0,0 @@
---
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

@@ -1,7 +1,7 @@
---
title: "Projects"
type: singles
slug: projects
slug: /projects
---

View File

@@ -2,7 +2,7 @@
title: "Tatooine"
date: 2021-05-12T23:39:49+05:30
type: singles
slug: "tatooine"
slug: tatooine
---
### A long time ago in a galaxy far, far away....

View File

@@ -1,20 +1,14 @@
{{ define "main" }}
<!-- TODO: @yash Paginate this if items more than n -->
<div class="container list-posts">
<h2 class="list-title">{{ .Name }}</h2>
{{ $posts := where .Data.Pages "Params.type" "post" }}
{{ range $posts.GroupByDate "2006" }}
{{ range (where .Site.Pages "Params.type" "post" ).GroupByDate "2006" }}
<h2 class="posts-year">{{ .Key }}</h2>
{{- range .Pages -}}
<article class="post-title">
<a href="{{ .RelPermalink }}" class="post-link">{{ .Title }}</a>
<span class="post-date">{{ dateFormat "January 2, 2006" .Date }}</span>
</article>
{{- partial "list-posts.html" . -}}
{{ end }}
{{ end }}

View File

@@ -8,4 +8,25 @@
<h1>{{ .Site.Title }}</h1>
<h3>{{ .Site.Params.Description }}</h3>
</section>
{{ if isset .Site.Params "showpostsonhomepage" }}
<div class="home-posts list-posts">
<h2>{{ .Site.Params.ShowPostsOnHomePage | humanize }} Posts</h2>
{{ $posts := where .Site.Pages "Params.type" "post" }}
{{ if eq .Site.Params.ShowPostsOnHomePage "popular" }}
{{ range $posts.ByWeight | first 4 }}
{{- partial "list-posts.html" . -}}
{{ end }}
{{ else if eq .Site.Params.ShowPostsOnHomePage "recent" }}
{{ range $posts.ByDate.Reverse | first 4 }}
{{- partial "list-posts.html" . -}}
{{ end }}
{{ end }}
</div>
{{ end }}
{{ end }}

View File

@@ -3,7 +3,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Jost&family=Nunito&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Jost&family=Arvo&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"
integrity="sha512-NhSC1YmyruXifcj/KFRWoC561YpHpc5Jtzgvbuzx5VozKpWvQ+4nXhPdFgmx8xqexRcpAglTj9sIBWINXa8x5w=="

View File

@@ -0,0 +1,4 @@
<article class="post-title">
<a href="{{ .RelPermalink }}" class="post-link">{{ .Title }}</a>
<span class="post-date">{{ dateFormat "January 2, 2006" .Date }}</span>
</article>

View File

@@ -256,6 +256,10 @@ table td {
width: 15rem;
}
.home-posts {
padding-top: 20px;
}
/* SINGLE */
main#content .post {
font-size: 1.2rem;