Merge pull request #34 from 526avijitgupta/documentation

Documentation and some minor tweaks
This commit is contained in:
Avijit Gupta
2021-08-02 14:06:08 +02:00
committed by GitHub
16 changed files with 402 additions and 33 deletions

View File

@@ -8,13 +8,13 @@ enableEmoji = true
paginate = 20 paginate = 20
# Choose one of emacs, trac or perldoc # Choose one of emacs, trac or perldoc
pygmentsStyle = "emacs" pygmentsStyle = "monokai"
[params] [params]
footer = "The Marauders" footer = "The Marauders"
description = "You miss 100% of the shots you don't take" description = "Sky above, sand below & peace within"
avatarURL = "https://upload.wikimedia.org/wikipedia/commons/7/7a/1859-Martinique.web.jpg" avatarURL = "https://upload.wikimedia.org/wikipedia/commons/7/7a/1859-Martinique.web.jpg"
customHTML = "" customHeadHTML = ""
showPostsOnHomePage = "popular" showPostsOnHomePage = "popular"
[menu] [menu]
@@ -34,18 +34,18 @@ pygmentsStyle = "emacs"
weight = 3 weight = 3
[[menu.main]] [[menu.main]]
name = "Resume" name = "Tags"
url = "/resume/" url = "/tags/"
weight = 4 weight = 4
[[menu.main]] [[menu.main]]
identifier = "linkedin" identifier = "coffee"
pre = "<span data-feather='linkedin'></span>" pre = "<span data-feather='coffee'></span>"
url = "/a/" url = "/a/"
weight = 5 weight = 5
[[menu.main]] [[menu.main]]
identifier = "github" identifier = "github"
pre = "<span data-feather='github'></span>" pre = "<span data-feather='github'></span>"
url = "/b/" url = "https://github.com/526avijitgupta/gokarna"
weight = 6 weight = 6

View File

@@ -4,7 +4,7 @@ date: 2020-10-01T17:55:28+08:00
description: "Guide to emoji usage in Hugo and DoIt." description: "Guide to emoji usage in Hugo and DoIt."
tags: ["emoji"] tags: ["emoji"]
type: post type: post
weight: 1 weight: 25
--- ---
Emoji can be enabled in a Hugo project in a number of ways. Emoji can be enabled in a Hugo project in a number of ways.

View File

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

View File

@@ -1,9 +1,10 @@
--- ---
title: "Markdown Syntax Guide" title: "Markdown Syntax Guide"
date: 2019-06-01T17:55:28+08:00 date: 2019-06-19
description: "Sample article showcasing basic Markdown syntax and formatting for HTML elements." description: "Sample article showcasing basic Markdown syntax and formatting for HTML elements."
tags: ["markdown", "css", "html"] tags: ["markdown", "css", "html"]
type: post type: post
weight: 20
--- ---
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. 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.

View File

@@ -0,0 +1,103 @@
---
weight: 15
title: "Theme Documentation - Advanced"
date: 2020-05-06T21:29:01+08:00
description: "Discover what the Hugo - gokarna theme is all about and the core-concepts behind it."
tags: ["installation", "configuration", "markdown"]
type: post
---
Discover what the Hugo - Gokarna theme is all about and the core-concepts behind it.
TODO: Similar intro as in README, opinionated, authors
## Content Types
This theme supports two types of content types: `post` and `page`. To specify them, you need to add them in your markdown metadata.
### Post
This is the default blog post type which will be shown in your "Posts" section and who's tags will be indexed. Basically, a normal blog post.
```markdown
---
title: "Hello, world!"
date: 2021-01-01
description: "A blog post"
type: "post"
tags: ["blog"]
---
# Hello World!
This is my blog.
```
### Page
We introduced this type to distinguish between blog posts and normal markdown pages. The reason to create this was to give the user complete freedom in creating their website. You can use this to create a portfolio of your projects or showcase your designs. The possibilites are endless and the choice is yours.
```markdown
---
title: "Hello, world!"
type: "page"
---
# Projects
Keep an eye on this space for my upcoming projects
```
## Weights
The `weight` attribute can be added in the markdown metadata for `post` types. We have an option in our config.toml: `params.showPostsOnHomePage` which allows you to:
1. Show popular posts on home page if the value is set to `popular`. It sorts the all the posts by it's weight attribute in ascending order.
2. Show recent posts on home page if the value is set to `recent`
3. Do not show anything if the variable is unset or an empty string.
## Custom Head HTML
The goal of this feature is to give the user more control over the theme. It's functioning is very straightforward - "You can inject any HTML you want in the `<head>` tag" . This may seem simple at first, but it opens up a lot of possibilities.
### Bring your own scripts
Add your own JavaScript or CSS by putting them in the `static/` folder and importing them into your HTML.
```toml
[params]
customHeadHTML = """
<script>console.log("Custom script or import");</script>
<script src="/js/custom.js"></script>
"""
```
### Analytics
Integration with any analytics tool: This was a personal pet peeve. User privacy is our primary concern and this meant not using Google Analytics or any of the popular tools.
We preferred privacy friendly tools like Umami(TODO link) & fathom(TODO link), but the downside was that no theme supported them out of the box which led to either changing the theme source code or contributing supporting code to the original theme (both of which are good ways to extend the theme, but not our ideal choice)
Giving users the freedom to add anything in the HTML via config.toml seemed like an elegant way to solve the problem.
```toml
[params]
customHeadHTML = """
<script async defer data-website-id="webiste-id" src="https://analytics.example.com/script.js"></script>
"""
```
## Syntax Highlighting
Hugo lets you choose the color scheme for the codeblocks. You can choose from the options here: https://xyproto.github.io/splash/docs/all.html
After choosing your theme, just update the `pygmentsStyle` attribute in config.toml.
```toml
pygmentsStyle = "monokai"
```
You can read more about syntax highlighting on the [official hugo docs](TODO).

View File

@@ -0,0 +1,230 @@
---
weight: 10
title: "Theme Documentation - Basics"
date: 2020-03-06T21:29:01+08:00
description: "Discover what the Hugo - gokarna theme is all about and the core-concepts behind it."
tags: ["installation", "configuration", "markdown"]
type: post
---
Discover what the Hugo - Gokarna theme is all about and the core-concepts behind it.
TODO: Similar intro as in README, opinionated, authors
## 1 Requirements
Thanks to the simplicity of Hugo, [Hugo](https://gohugo.io/) is the only dependency of this theme.
## 2 Installation
The following steps are here to help you initialize your new website. If you dont know Hugo at all, we strongly suggest you learn more about it by following this [great documentation for beginners](https://gohugo.io/getting-started/quick-start/).
### 2.1 Create Your Project
Hugo provides a `new` command to create a new website:
```bash
hugo new site my_website
cd my_website
```
### 2.2 Install the Theme
The themes repository is: [https://github.com/526avijitgupta/gokarna](https://github.com/526avijitgupta/gokarna).
You can download the [latest release :books: .zip file](https://github.com/526avijitgupta/gokarna/releases) of the theme and extract it in the `themes` directory.
Alternatively, clone this repository to the `themes` directory:
```bash
git clone https://github.com/526avijitgupta/gokarna.git themes/gokarna
```
Or, create an empty git repository and make this repository a submodule of your site directory:
```bash
git init
git submodule add https://github.com/526avijitgupta/gokarna.git themes/gokarna
```
### 2.3 Basic Configuration {#basic-configuration}
The following is a basic configuration for the gokarna theme:
```toml
baseURL = "http://example.org/"
defaultContentLanguage = "en"
languageCode = "en"
title = "My New Hugo Site"
theme = "gokarna"
[params]
# URL for the avatar on homepage
avatarURL = ""
# Description to display on homepage
description = "Sky above, sand below & peace within"
# You can use this to inject any HTML in the <head> tag.
# Ideal usecase for this is to import custom js/css or add your analytics snippet
customHeadHTML = ""
# If you want to display posts on the homepage, the options are
# "popular" (order posts by weight), "recent" (order posts by date)
# or "" (do not display, default option)
showPostsOnHomePage = ""
# Footer text
footer = "The Marauders"
[menu]
[[menu.main]]
# Unique identifer for a menu item
identifier = "posts"
url = "/posts/"
# You can add extra information before the name (HTML format is supported), such as icons
pre = ""
# You can add extra information after the name (HTML format is supported), such as icons
post = ""
# Display name
name = "Posts"
# Weights are used to determine the ordering
weight = 1
[[menu.main]]
identifier = "tags"
name = "Tags"
url = "/tags/"
weight = 2
[[menu.main]]
identifier = "github"
url = "https://github.com"
weight = 3
# We use feather-icons
pre = "<span data-feather='github'></span>"
```
### 2.4 Create Your First Post
Here is the way to create your first post:
```bash
hugo new posts/first_post.md
```
Feel free to edit the post file by adding some sample content and replacing the title value in the beginning of the file.
For posts you need to add `type: "post"` in the markdown metadata. We currently support 2 types of content:
1. Post (`type: "post"`): A normal blog-post with tags, date, & content.
2. Page (`type: "page"`): A standalone content page that will just render the markdown you wrote. You can use it to write custom pages which should not be a part of posts. Like, showing your projects portfolio. You can read in detail about this on the [Theme Documentation - Advanced](/link-TODO) page.
By default all posts and pages are created as a draft. If you want to render these pages, remove the property `draft: true` from the metadata, set the property `draft: false` or add `-D`/`--buildDrafts` parameter to `hugo` command.
### 2.5 Launching the Website Locally
Launch by using the following command:
```bash
hugo serve
```
Go to `http://localhost:1313`.
### 2.6 Build the Website
When your site is ready to deploy, run the following command:
```bash
hugo
```
A `public` folder will be generated, containing all static content and assets for your website. It can now be deployed on any web server.
The website can be automatically published and hosted with [Netlify](https://www.netlify.com/) (Read more about [Automated HUGO deployments with Netlify](https://www.netlify.com/blog/2015/07/30/hosting-hugo-on-netlifyinsanely-fast-deploys/)).
Alternatively, you can use [AWS Amplify](https://gohugo.io/hosting-and-deployment/hosting-on-aws-amplify/), [Github pages](https://gohugo.io/hosting-and-deployment/hosting-on-github/), [Render](https://gohugo.io/hosting-and-deployment/hosting-on-render/) and more...
## 3 Configuration
### 3.1 Site Configuration {#site-configuration}
In addition to [Hugo global configuration](https://gohugo.io/overview/configuration/) and [menu configuration](#basic-configuration), **gokarna** lets you define the following parameters in your site configuration (here is a `config.toml`, whose values are default).
Please open the code block below to view the complete sample configuration :(far fa-hand-point-down fa-fw)::
```toml
[params]
version = "1.0.X"
# site description
description = "This is My New Hugo Site"
# site keywords
keywords = ["Theme", "Hugo"]
# site default theme ("light", "dark", "auto")
defaultTheme = "auto"
# public git repo url only then enableGitInfo is true
gitRepo = ""
# ("sha256", "sha384", "sha512", "md5")
fingerprint = ""
dateFormat = "2006-01-02"
# website images for Open Graph and Twitter Cards
images = ["/logo.png"]
SourceMap = true
[params.pwa]
# whether to enable PWA support
enable = true
# service-worker version
version = "1.0.1"
[params.app]
# optional site title override for the app when added to an iOS home screen or Android launcher
title = "gokarna"
# whether to omit favicon resource links
noFavicon = false
# modern SVG favicon to use in place of older style .png and .ico files
svgFavicon = ""
# Android browser theme color
themeColor = "#ffffff"
# Safari mask icon color
iconColor = "#5bbad5"
# Windows v8-10 tile color
tileColor = "#da532c"
[params.search]
enable = true
# type of search engine ("lunr", "algolia")
# Header config
[params.header]
# desktop header mode ("fixed", "normal", "auto")
desktopMode = "fixed"
# mobile header mode ("fixed", "normal", "auto")
mobileMode = "auto"
[params.header.title]
# URL of the LOGO
logo = ""
rss = true
```
### 3.2 Favicons, Browserconfig, Manifest
It is recommended to put your own favicons:
* apple-touch-icon.png (180x180)
* favicon-32x32.png (32x32)
* favicon-16x16.png (16x16)
* mstile-150x150.png (150x150)
* android-chrome-192x192.png (192x192)
* android-chrome-512x512.png (512x512)
into `/static`. Theyre easily created via [https://realfavicongenerator.net/](https://realfavicongenerator.net/).

View File

@@ -1,6 +1,6 @@
--- ---
title: "Projects" title: "Projects"
type: singles type: page
--- ---

View File

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

View File

@@ -1,6 +1,6 @@
{{ define "main" }} {{ define "main" }}
{{ if eq .Type "singles" }} {{ if eq .Type "page" }}
{{- partial "single.html" . -}} {{- partial "page.html" . -}}
{{ else }} {{ else }}
{{- partial "list.html" . -}} {{- partial "list.html" . -}}
{{ end }} {{ end }}

View File

@@ -3,7 +3,7 @@
{{- partial "post.html" . -}} {{- partial "post.html" . -}}
{{ end }} {{ end }}
{{ if eq .Type "singles" }} {{ if eq .Type "page" }}
{{- partial "single.html" . -}} {{- partial "page.html" . -}}
{{ end }} {{ end }}
{{ end }} {{ end }}

View File

@@ -3,11 +3,11 @@
<h2 class="list-title">Tags</h2> <h2 class="list-title">Tags</h2>
<ul class="post-tags"> <ul class="post-tags">
{{ range $key, $value := .Data.Terms.ByCount }} {{ range $.Site.Taxonomies.tags.ByCount }}
<li class="post-tag"> <li class="post-tag">
<a href="/tags/{{ $value.Name | urlize }}/"> <a href="/tags/{{ .Name | urlize }}/">
<div class="tag-name">{{ $value.Name }}</div> <div class="tag-name">{{ .Name }}</div>
<div class="tag-posts-count">{{ $value.Count }}</div> <div class="tag-posts-count">{{ .Count }}</div>
</a> </a>
</li> </li>
{{ end }} {{ end }}

View File

@@ -15,8 +15,8 @@
<script src="/js/main.js"></script> <script src="/js/main.js"></script>
<!-- Option for user to inject custom html --> <!-- Option for user to inject custom html -->
{{ if .Site.Params.CustomHTML }} {{ if .Site.Params.CustomHeadHTML }}
{{ .Site.Params.CustomHTML | safeHTML }} {{ .Site.Params.CustomHeadHTML | safeHTML }}
{{ end }} {{ end }}
{{ $title := print .Site.Title " | " .Title }} {{ $title := print .Site.Title " | " .Title }}

View File

@@ -2,7 +2,7 @@
/* dark theme colors */ /* dark theme colors */
--dark-bg-color: #121212; --dark-bg-color: #121212;
--dark-text-color: white; --dark-text-color: white;
--dark-header-bg-color: #1f1f1f; --dark-header-bg-color: #121212;
--dark-header-divider-color: #484848; --dark-header-divider-color: #484848;
} }
@@ -12,8 +12,7 @@ html {
} }
.header { .header {
box-shadow: rgba(102, 102, 102, 0.5) 0px 1px 2px 0px; background-color: var(--dark-bg-color);
background-color: var(--dark-header-bg-color);
} }
.nav-hamburger-list { .nav-hamburger-list {
@@ -55,6 +54,15 @@ table th {
border-bottom-color: var(--dark-header-divider-color); border-bottom-color: var(--dark-header-divider-color);
} }
:not(pre) > code {
background-color: #272822 !important;
color: var(--dark-text-color);
}
.header-shadow {
box-shadow: rgb(33, 38, 45) 0px -1px 0px 0px inset;
}
/* TODO: Check if this is needed or not */ /* TODO: Check if this is needed or not */
/* /*
img, img,

View File

@@ -4,7 +4,7 @@
/* light theme colors */ /* light theme colors */
--light-bg-color: white; --light-bg-color: white;
--light-text-color: black; --light-text-color: black;
--light-header-bg-color: #f0f0f0; --light-header-bg-color: white;
--light-header-divider-color: #dfdfdf; --light-header-divider-color: #dfdfdf;
} }
@@ -42,15 +42,16 @@ img {
/* HEADER */ /* HEADER */
.header { .header {
background-color: rgba(240, 240, 240, 0.95); background-color: var(--light-bg-color);
box-shadow: rgba(170, 170, 170, 0.5) 0px 1px 2px 0px;
color: inherit; color: inherit;
font-size: 1.05rem; font-size: 1.25rem;
height: 50px; height: 50px;
left: 0; left: 0;
position: fixed; position: fixed;
top: 0; top: 0;
width: 100%; width: 100%;
opacity: 0.95;
transition: box-shadow 0.3s ease-in-out;
} }
.header a { .header a {
@@ -82,7 +83,6 @@ img {
padding-left: 15px; padding-left: 15px;
} }
.nav-title a { .nav-title a {
font-size: 20px;
height: 50px; height: 50px;
} }
.header-nav .nav-links { .header-nav .nav-links {
@@ -177,11 +177,15 @@ img {
visibility: hidden; visibility: hidden;
} }
.header-shadow {
box-shadow: rgb(220, 220, 220) 0px 1px 5px;
}
/* ICONS */ /* ICONS */
.feather { .feather {
height: 20px; height: 20px;
margin: -3px auto; margin: -3px auto;
stroke-width: 1.25; stroke-width: 2;
width: 20px; width: 20px;
} }
@@ -212,7 +216,7 @@ img {
/* CODE BLOCKS */ /* CODE BLOCKS */
code, code,
pre { pre {
background-color: #1f1f1f !important; background-color: #272822 !important;
box-sizing: border-box; box-sizing: border-box;
color: white; color: white;
} }
@@ -227,6 +231,17 @@ code {
box-decoration-break: clone; box-decoration-break: clone;
padding: 0 3px; padding: 0 3px;
word-wrap: break-word; word-wrap: break-word;
font-size: 0.8em;
}
:not(pre) > code {
background-color: #e0e0e0 !important;
color: var(--light-text-color);
padding: 1px 4px;
}
pre code {
font-size: 1em;
} }
blockquote { blockquote {

View File

@@ -34,6 +34,19 @@ function ready() {
}) })
} }
window.addEventListener('scroll', () => {
if (window.scrollY > 100) {
document.querySelectorAll('.header').forEach(function(item) {
item.classList.add('header-shadow')
})
} else {
document.querySelectorAll('.header').forEach(function(item) {
item.classList.remove('header-shadow')
})
}
});
function setTheme(themeToSet) { function setTheme(themeToSet) {
localStorage.setItem(THEME_PREF_STORAGE_KEY, themeToSet); localStorage.setItem(THEME_PREF_STORAGE_KEY, themeToSet);
darkThemeCss.disabled = themeToSet === 'light'; darkThemeCss.disabled = themeToSet === 'light';