Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more Pre-commit checks #55

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ repos:
- id: check-xml
- id: check-yaml
- id: end-of-file-fixer
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: detect-private-key
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

Expand All @@ -34,3 +40,12 @@ repos:
hooks:
- id: prettier
files: \.(js|ts|jsx|tsx|css|less|json|markdown|md|scss)$

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.3.0
hooks:
- id: prettier
files: \.(html)$
additional_dependencies:
- [email protected]
- [email protected]
7 changes: 3 additions & 4 deletions layouts/404.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{{ define "main" }}
<article class="space-y-4">
<h1 class="text-4xl font-medium">
Page not found!
</h1>
<h1 class="text-4xl font-medium">Page not found!</h1>

<h2 class="font-medium">
Sorry, but the page you are looking for does not exist.
</h2>

<p>
Try going back to the <a href="{{ .Site.BaseURL }}">homepage</a> for more content.
Try going back to the <a href="{{ .Site.BaseURL }}">homepage</a> for
more content.
</p>
</article>
{{ end }}
10 changes: 9 additions & 1 deletion layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if (or (strings.HasPrefix .Destination "http") (strings.HasSuffix .Destination ".pdf")) }} target="_blank" rel="external nofollow noopener"{{ end }}>{{ .Text | safeHTML }}</a>
<a
href="{{ .Destination | safeURL }}"
{{ with .Title }}
title="{{ . }}"
{{ end }}{{ if (or (strings.HasPrefix .Destination "http") (strings.HasSuffix .Destination ".pdf")) }}
target="_blank" rel="external nofollow noopener"
{{ end }}
>{{ .Text | safeHTML }}</a
>
23 changes: 16 additions & 7 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
<!DOCTYPE html>
<html {{ with .Site.LanguageCode }}lang="{{ . }}"{{ end }} itemscope itemtype="http://schema.org/{{ if .IsHome }}WebSite{{ else if .IsPage }}Article{{ else }}WebPage{{ end }}">
{{/* Head */}}
<html
{{ with .Site.LanguageCode }}lang="{{ . }}"{{ end }}
itemscope
itemtype="http://schema.org/{{ if .IsHome }}
WebSite
{{ else if .IsPage }}
Article
{{ else }}
WebPage
{{ end }}"
>
{{/* Head */}}
{{ partial "head" . }}

{{/* Body */}}
{{/* Body */}}
<body class="mx-auto text-primary bg-background">

{{/* Header */}}
{{/* Header */}}
{{ partial "header" . }}

{{/* Main */}}
{{/* Main */}}
<main class="mt-24 md:mt-14 mb-12 md:mb-8 p-4 space-y-4">
{{ block "main" . }}{{ end }}
</main>

{{/* Footer */}}
{{/* Footer */}}
{{ partial "footer" . }}
</body>
</html>
1 change: 1 addition & 0 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h2 class="font-medium">
</div>
{{ end }}


<div>
{{ partial "list" . }}
</div>
Expand Down
18 changes: 13 additions & 5 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ <h2 class="font-medium">
{{ end }}
</header>

<div class="sm:float-right sm:w-1/3 md:w-1/4 sm:ml-4 text-center space-y-2">
<div
class="sm:float-right sm:w-1/3 md:w-1/4 sm:ml-4 text-center space-y-2"
>
{{ with resources.Get "img/prof_pic.jpg" }}
{{ partial "img" (dict "img" . "class" "rounded" "alt" .RelPermalink) }}
{{ end }}
Expand All @@ -34,27 +36,33 @@ <h2 class="font-medium">
</div>
{{ end }}


<div class="space-y-1">
<h3 class="text-2xl">
<a href="/news/" class="text-primary font-semibold no-underline">Recent News</a>
<a href="/news/" class="text-primary font-semibold no-underline"
>Recent News</a
>
</h3>
{{ partial "news/recents" . }}
</div>

<div class="space-y-1">
<h3 class="text-2xl">
<a href="/posts/" class="text-primary font-semibold no-underline">Recent Posts</a>
<a
href="/posts/"
class="text-primary font-semibold no-underline"
>Recent Posts</a
>
</h3>
{{ partial "posts/recents" . }}
</div>


{{ if .Site.Params.socialHomePage }}
<div class="pt-4 text-4xl">
{{ if .Site.Menus.social }}
{{ partial "social" . }}
{{ end }}
</div>
{{ end }}
{{ end }}
</article>
{{ end }}
16 changes: 10 additions & 6 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<footer class="fixed inset-x-0 bottom-0 p-2 bg-footer text-center text-xs font-light border-t border-divider">
<footer
class="fixed inset-x-0 bottom-0 p-2 bg-footer text-center text-xs font-light border-t border-divider"
>
{{ with .Site.Copyright }}
{{ . }}
{{ end }}
&bull;
Powered by <a href="https://gohugo.io">Hugo</a> with
<a href="https://github.com/rohandebsarkar/academic-folio">Academic Folio</a> theme
&bull; Powered by <a href="https://gohugo.io">Hugo</a> with
<a href="https://github.com/rohandebsarkar/academic-folio"
>Academic Folio</a
>
theme
{{ if .Site.Params.footerLastUpdated }}
&bull;
Last updated: {{ now.Format "02 Jan 2006"}}
&bull; Last updated:
{{ now.Format "02 Jan 2006" }}
{{ end }}
</footer>
21 changes: 11 additions & 10 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<head>
{{/* Metadata */}}
{{/* Metadata */}}
{{ partial "metadata" . }}

{{/* Title */}}
{{/* Title */}}
<title>
{{ if eq .Title .Site.Title }}
{{ .Site.Title }}
{{ else }}
{{ .Title }} - {{ .Site.Title }}
{{ .Title }} -
{{ .Site.Title }}
{{ end }}
</title>

{{/* Canonical URL */}}
<link rel="canonical" href="{{ .Permalink }}">
{{/* Canonical URL */}}
<link rel="canonical" href="{{ .Permalink }}" />

{{/* Stylesheet Configuarations */}}
{{/* Stylesheet Configuarations */}}
{{ $styles := resources.Get "css/main.css" | resources.ExecuteAsTemplate "main.scss" . | toCSS | postCSS }}

{{ if hugo.IsProduction }}
Expand All @@ -23,16 +24,16 @@
{{ $styles = $styles | resources.ExecuteAsTemplate (printf "main.dev.%v.css" now.UnixMilli) . }}
{{ end }}

{{/* Stylesheets */}}
{{/* Stylesheets */}}
{{ partial "styles/layout" . }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}">
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" />
{{ if .Site.Params.email }}
{{ partial "styles/cloakemail" . }}
{{ end }}

{{/* Scripts */}}
{{/* Scripts */}}
{{ partial "scripts/theme" . }}
{{ if .Params.math}}
{{ if .Params.math }}
{{ partial "scripts/katex" . }}
{{ end }}
</head>
6 changes: 5 additions & 1 deletion layouts/partials/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<li class="py-4 space-y-2 border-b border-dashed">
<div>
<h3>
<a class="text-2xl font-medium text-primary no-underline" href="{{ .RelPermalink }}">{{ .Title }}</a>
<a
class="text-2xl font-medium text-primary no-underline"
href="{{ .RelPermalink }}"
>{{ .Title }}</a
>
</h3>
<p>
{{ .Params.Description }}
Expand Down
23 changes: 17 additions & 6 deletions layouts/partials/metadata.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
<meta charset="utf-8">
<meta charset="utf-8" />

<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="{{ .Site.Params.firstName }} {{ .Site.Params.lastName }}" />
<meta name="description" content="{{ .Site.Params.description }}">
<meta name="keywords" content='{{ with .Params.tags }}{{ delimit . ", " }}{{ else }}{{ delimit .Site.Params.tags ", " }}{{ end }}' />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="author"
content="{{ .Site.Params.firstName }} {{ .Site.Params.lastName }}"
/>
<meta name="description" content="{{ .Site.Params.description }}" />
<meta
name="keywords"
content="{{ with .Params.tags }}
{{ delimit . ", " }}
{{ else }}
{{ delimit .Site.Params.tags ", " }}
{{ end }}
"
/>

{{ if (eq .RelPermalink "/404.html") }}
<meta http-equiv="refresh" content="10; url={{ .Site.BaseURL }}">
<meta http-equiv="refresh" content="10; url={{ .Site.BaseURL }}" />
{{ end }}

{{ template "_internal/opengraph.html" . }}
Expand Down
9 changes: 6 additions & 3 deletions layouts/partials/modules/responsive-images/__img.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{/*
Only include image if image width exceeds breakpoint width, and if breakpoint
{{/* Only include image if image width exceeds breakpoint width, and if breakpoint
shouldn't be skipped.
*/}}
{{ $width := cond (eq .width -1) .img.Width .width }}
Expand All @@ -9,6 +8,10 @@
{{ with $.breakpoint }}
{{ $breakpoint = printf "media=(min-width:%dpx)" . }}
{{ end }}
<source {{$breakpoint|safeHTMLAttr}} srcset="{{.RelPermalink}}" type="image/webp" />
<source
{{ $breakpoint|safeHTMLAttr }}
srcset="{{ .RelPermalink }}"
type="image/webp"
/>
{{ end }}
{{ end }}
8 changes: 6 additions & 2 deletions layouts/partials/modules/responsive-images/_img.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
{{ $attributes = printf `%s %s="%s"` $attributes $v . }}
{{ end }}
{{ end }}
<img src="{{.RelPermalink}}" height="{{.Height}}" width="{{.Width}}"
{{$attributes|safeHTMLAttr}} />
<img
src="{{ .RelPermalink }}"
height="{{ .Height }}"
width="{{ .Width }}"
{{ $attributes|safeHTMLAttr }}
/>
</picture>
{{ end }}
3 changes: 1 addition & 2 deletions layouts/partials/modules/responsive-images/img.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"quality" 75)
}}

{{/*
Hugo doesn't seem to distinguish between image resources well.
{{/* Hugo doesn't seem to distinguish between image resources well.
Therefore, pass the image path as another variant.
*/}}
{{ partialCached "modules/responsive-images/_img" $opts . .img.Key }}
24 changes: 12 additions & 12 deletions layouts/partials/news/recents.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<table class="text-left">
<tbody>
{{ range ( where .Site.RegularPages "Type" "news" | first .Site.Params.recentNews ) }}
<tr>
<th class="pr-2 py-1">
{{ .Date.Format "January 02, 2006" }}
</th>
<td class="pl-2 py-1">
{{ if .Content }}
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
{{ else }}
<span class="font-medium">{{ .Title }}</span>
{{ end }}
</td>
</tr>
<tr>
<th class="pr-2 py-1">
{{ .Date.Format "January 02, 2006" }}
</th>
<td class="pl-2 py-1">
{{ if .Content }}
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
{{ else }}
<span class="font-medium">{{ .Title }}</span>
{{ end }}
</td>
</tr>
{{ end }}
</tbody>
</table>
Expand Down
22 changes: 18 additions & 4 deletions layouts/partials/posts/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

<div>
<h3>
<a class="text-2xl font-medium text-primary no-underline" href="{{ .RelPermalink }}">
<a
class="text-2xl font-medium text-primary no-underline"
href="{{ .RelPermalink }}"
>
{{ .Title }}
</a>
</h3>
Expand All @@ -24,18 +27,29 @@ <h3>
{{ $currentPage := . }}
<p class="text-sm italic text-secondary">
{{ with .Page.ReadingTime }}
<span>{{ partial "svg" "fas fa-clock" }}&nbsp;{{ . }}&nbsp;min read&nbsp;</span>
<span
>{{ partial "svg" "fas fa-clock" }}&nbsp;{{ . }}&nbsp;min
read&nbsp;</span
>
{{ end }}
{{ with .Page.Params.tags }}
&bull;&nbsp;
{{ range . }}
<a href="/tags/{{ . }}" class="text-secondary no-underline">{{ partial "svg" "fas fa-hashtag" }}&nbsp;{{ . }}&nbsp;</a>
<a
href="/tags/{{ . }}"
class="text-secondary no-underline"
>{{ partial "svg" "fas fa-hashtag" }}&nbsp;{{ . }}&nbsp;</a
>
{{ end }}
{{ end }}
{{ with .Page.Params.categories }}
&bull;&nbsp;
{{ range . }}
<a href="/categories/{{ . }}" class="text-secondary no-underline">{{ partial "svg" "fas fa-tag" }}&nbsp;{{ . }}&nbsp;</a>
<a
href="/categories/{{ . }}"
class="text-secondary no-underline"
>{{ partial "svg" "fas fa-tag" }}&nbsp;{{ . }}&nbsp;</a
>
{{ end }}
{{ end }}
</p>
Expand Down
Loading