Skip to content

Commit

Permalink
Fix the image styling (#30)
Browse files Browse the repository at this point in the history
* fix: styling images appropriately

* feat: also adds linting

* chore: fix lint

* chore: improve the styling
  • Loading branch information
shivan-s authored Oct 26, 2024
1 parent 98fe5a4 commit 00680b4
Show file tree
Hide file tree
Showing 23 changed files with 846 additions and 126 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ hugo.linux

# Temporary lock file while building
/.hugo_build.lock

/node_modules

.DS_Store
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm exec lint-staged
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore artifacts:
build
coverage
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"plugins": ["prettier-plugin-go-template"],
"overrides": [
{
"files": ["*.html"],
"options": {
"parser": "go-template"
}
}
]
}
1 change: 0 additions & 1 deletion archetypes/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ title: '{{ replace .File.ContentBaseName "-" " " | title }}'
date: { { .Date | time.Format "2006-01-02" } }
author: Author Name
summary: Summary
categories: [""]
tags: [""]
draft: true
cover:
Expand Down
36 changes: 27 additions & 9 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ h3 {
color: var(--primary-color);
}

body>header {
body > header {
font-family:
Optician Sans,
sans-serif;
Expand Down Expand Up @@ -149,7 +149,7 @@ div.tags {
outline: 2px ridge var(--text-color);
filter: none;
border-radius: var(--large-border-radius);
box-shadow: 0 0 0 2pt var(--text-color);
box-shadow: 0 0 0 2px var(--text-color);
}

& li {
Expand Down Expand Up @@ -336,8 +336,9 @@ main {
}

/* footer */
body>footer {
padding: 1rem 0rem;
body > footer {
width: 100%;
padding: 1rem 0;
margin-top: 1rem;
border-top: 1px solid var(--text-color);
font-family:
Expand All @@ -351,17 +352,21 @@ body>footer {
text-align: center;
}

& p:not(:last-child)::after {
padding: 0 calc(var(--letter-gap) / 2);
content: "·";
& div {
max-width: 75ch;
width: 100%;
display: flex;
align-items: center;
justify-content: space-around;
gap: calc(var(--letter-gap) / 2);
}
}

div.content {
white-space: break-spaces;
word-break: break-word;

& * {
& p {
margin: var(--small-gap) 0rem;
}

Expand All @@ -370,15 +375,28 @@ div.content {
}

& pre:has(code) {
max-width: 100%;
border-radius: calc(var(--normal-border-radius) * 2);
padding: calc(var(--small-gap)) calc(var(--small-gap) / 2);
box-shadow: 0px 0px 2pt var(--text-color);
box-shadow: 0px 0px 2px var(--text-color);
overflow-x: scroll;
}

& code {
font-family: "Monaspace Radon";
}

& img {
max-width: 100%;
max-height: 90dvh;
object-fit: contain;
border-radius: var(--normal-border-radius);
box-shadow: 0 0 0 2px var(--text-color);

&:hover {
border-radius: 0;
}
}
}

@font-face {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log('This site was generated by Hugo.');
console.log("This site was generated by Hugo.");
32 changes: 32 additions & 0 deletions content/posts/test-post/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Test Post
date: 1980-01-02
author: Test Author
summary: Test Summary
tags: ["test", "lorem"]
draft: true
cover:
image: test.jpg
alt: test
caption: test caption
relative: false
hidden: true
audio:
src: audio.mp3
caption: caption
hidden: true
---

Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.

![Test page](./testing.jpg)

Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit enim labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet. Nisi anim cupidatat excepteur officia. Reprehenderit nostrud nostrud ipsum Lorem est aliquip amet voluptate voluptate dolor minim nulla est proident. Nostrud officia pariatur ut officia. Sit irure elit esse ea nulla sunt ex occaecat reprehenderit commodo officia dolor Lorem duis laboris cupidatat officia voluptate. Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis officia eiusmod. Aliqua reprehenderit commodo ex non excepteur duis sunt velit enim. Voluptate laboris sint cupidatat ullamco ut ea consectetur et est culpa et culpa duis.

```py
# Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat. Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.

print("Hello world")
```

Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit enim labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet. Nisi anim cupidatat excepteur officia. Reprehenderit nostrud nostrud ipsum Lorem est aliquip amet voluptate voluptate dolor minim nulla est proident. Nostrud officia pariatur ut officia. Sit irure elit esse ea nulla sunt ex occaecat reprehenderit commodo officia dolor Lorem duis laboris cupidatat officia voluptate. Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis officia eiusmod. Aliqua reprehenderit commodo ex non excepteur duis sunt velit enim. Voluptate laboris sint cupidatat ullamco ut ea consectetur et est culpa et culpa duis.
Binary file added content/posts/test-post/testing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 12 additions & 11 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<!doctype html>
<html lang="{{ site.Language.LanguageCode }}" dir="{{ or site.Language.LanguageDirection `ltr` }}">

<head>
{{ partial "head.html" . }}
</head>

<body>
<header>{{ partial "header.html" . }}</header>
<main>{{ block "main" . }}{{ end }}</main>
<footer>{{ partial "footer.html" . }}</footer>
</body>
<html
lang="{{ site.Language.LanguageCode }}"
dir="{{ or site.Language.LanguageDirection `ltr` }}"
>
<head>
{{ partial "head.html" . }}
</head>

<body>
<header>{{ partial "header.html" . }}</header>
<main>{{ block "main" . }}{{ end }}</main>
<footer>{{ partial "footer.html" . }}</footer>
</body>
</html>
43 changes: 22 additions & 21 deletions layouts/_default/home.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{{ define "main" }} {{ with .GetPage "About" }}
<h1 hidden>{{ .Page.Title }}</h1>
<section class="about">
<header>
<a href="{{ .RelPermalink }}">
<h2>About</h2>
</a>
</header>
<p>{{ truncate 128 .Content }}</p>
<footer>
<a href="{{ .RelPermalink }}">Read more...</a>
</footer>
</section>
{{ end }}
<section class="posts">
<header>
<h2>Posts</h2>
</header>
{{ partial "posts-list.html" . }}
<footer />
</section>
{{ define "main" }}
{{ with .GetPage "About" }}
<h1 hidden>{{ .Page.Title }}</h1>
<section class="about">
<header>
<a href="{{ .RelPermalink }}">
<h2>About</h2>
</a>
</header>
<p>{{ truncate 128 .Content }}</p>
<footer>
<a href="{{ .RelPermalink }}">Read more...</a>
</footer>
</section>
{{ end }}
<section class="posts">
<header>
<h2>Posts</h2>
</header>
{{ partial "posts-list.html" . }}
<footer />
</section>
{{ end }}
9 changes: 5 additions & 4 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{ define "main" }}
<header>
<h2>{{ .Title }}</h2>
</header>
<header>
<h2>{{ .Title }}</h2>
</header>

{{ partial "posts-list.html" . }} {{ end }}
{{ partial "posts-list.html" . }}
{{ end }}
12 changes: 6 additions & 6 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{ define "main" }}
<article>
<header>
<h2>{{ .Title }}</h2>
</header>
<div class="content">{{ .Content }}</div>
</article>
<article>
<header>
<h2>{{ .Title }}</h2>
</header>
<div class="content">{{ .Content }}</div>
</article>
{{ end }}
10 changes: 6 additions & 4 deletions layouts/_default/taxonomy.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }} {{ range .Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }} {{ end }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ range .Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ end }}
32 changes: 20 additions & 12 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<p>
Made with <span title="Love">💗</span> by
<a title="{{ .Site.Params.author.email }}" href="mailto:{{ .Site.Params.author.email }}">{{ .Site.Params.author.name
}}</a>
</p>
<p>
<span title="Powered"></span> by
<a title="Hugo" href="https://gohugo.io">Hugo</a> in
<time datetime='{{ dateFormat "2006" now
}}'>{{ dateFormat "2006" now }}</time>
</p>
<p><a title="Back to top" href="#top">Back to Top</a></p>
<div>
<p>
Made with <span title="Love">💗</span> by
<a
title="{{ .Site.Params.author.email }}"
href="mailto:{{ .Site.Params.author.email }}"
>{{ .Site.Params.author.name }}</a
>
</p>
<p>
<span title="Powered"></span> by
<a title="Hugo" href="https://gohugo.io">Hugo</a> in
<time datetime="{{ dateFormat " 2006" now }}"
>{{ dateFormat "2006" now }}</time
>
</p>
<p>
<a title="Back to top" href="#top">Back to Top</a>
</p>
</div>
12 changes: 9 additions & 3 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }}</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>
{{ if .IsHome }}
{{ site.Title }}
{{ else }}
{{ printf "%s | %s" .Title site.Title }}
{{ end }}
</title>
{{ partialCached "head/css.html" . }}
{{ partialCached "head/js.html" . }}
9 changes: 7 additions & 2 deletions layouts/partials/head/css.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{{- with resources.Get "css/main.css" }}
{{- if eq hugo.Environment "development" }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
<link rel="stylesheet" href="{{ .RelPermalink }}" />
{{- else }}
{{- with . | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
<link
rel="stylesheet"
href="{{ .RelPermalink }}"
integrity="{{ .Data.Integrity }}"
crossorigin="anonymous"
/>
{{- end }}
{{- end }}
{{- end }}
6 changes: 5 additions & 1 deletion layouts/partials/head/js.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
{{- else }}
{{- $opts := dict "minify" true }}
{{- with . | js.Build $opts | fingerprint }}
<script src="{{ .RelPermalink }}" integrity="{{- .Data.Integrity }}" crossorigin="anonymous"></script>
<script
src="{{ .RelPermalink }}"
integrity="{{- .Data.Integrity }}"
crossorigin="anonymous"
></script>
{{- end }}
{{- end }}
{{- end }}
48 changes: 28 additions & 20 deletions layouts/partials/posts-list.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ range $pages.GroupByPublishDate "2006" }}
<div class="posts-groupby">
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
<li>
<a href="{{ .RelPermalink }}"><span title={{ .LinkTitle }} class="post-title">{{ if .Draft }}<em
title="Draft post">[D]&nbsp;</em>{{
end }}{{
.LinkTitle | truncate 128 }}</span>
<small class="post-metadata">
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00"
}} {{ $dateHuman := .Date | time.Format "2 Jan" }}
<span title={{ .Date | time.Format "January 2, 2006" }}><time datetime="{{ $dateMachine }}">{{ $dateHuman
}}</time></span>
<span title="{{ .WordCount }} words">
{{ .ReadingTime }} min</span></small></a>
</li>
{{ end }}
</ul>
</div>
<div class="posts-groupby">
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
<li>
<a href="{{ .RelPermalink }}"
><span title="{{ .LinkTitle }}" class="post-title"
>{{ if .Draft }}
<em title="Draft post">[D]&nbsp;</em>
{{ end }}{{ .LinkTitle | truncate 128 }}</span
>
<small class="post-metadata">
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
{{ $dateHuman := .Date | time.Format "2 Jan" }}
<span title="{{ .Date | time.Format "January 2, 2006" }}"
><time datetime="{{ $dateMachine }}"
>{{ $dateHuman }}</time
></span
>
<span title="{{ .WordCount }} words">
{{ .ReadingTime }} min</span
></small
></a
>
</li>
{{ end }}
</ul>
</div>
{{ end }}
Loading

0 comments on commit 00680b4

Please sign in to comment.