14 Commits

Author SHA1 Message Date
98d03cd803 WIP 2023-11-05 17:52:28 -06:00
c980ced2fb Remove back to top button
It's kind of ugly and weird, and probably not necessary. I might add it
back in the future if it's actually needed again.
2023-11-05 17:41:59 -06:00
9ca15a198f Revert "Load bobastyle.css async too"
This reverts commits f33492ef8e and 5c87c2b069.

It turns out this makes performance score even worse because it makes
the CLS really bad
2023-11-05 01:20:20 -05:00
5c87c2b069 Fix async loading of bobastyle.css 2023-11-05 01:00:22 -05:00
6c42ae9518 Lazy load images 2023-11-05 00:56:13 -05:00
f33492ef8e Load bobastyle.css async too 2023-11-05 00:56:01 -05:00
ffcae79156 Load syntax CSS async 2023-11-05 00:31:26 -05:00
a59a87374b Rename config.yaml to hugo.yaml 2023-11-04 20:55:02 -05:00
88adfbdf89 Move site author to under params due to .Site.Author deprecation
See Hugo v0.120.0
2023-11-03 23:33:28 -05:00
0f717e81c0 Patch link issue with delimit due to breaking change in Hugo v0.120
References:
- https://github.com/gohugoio/hugo/releases/tag/v0.120.0
- https://github.com/gohugoio/hugo/issues/10876
- https://github.com/gohugoio/hugo/issues/11502
2023-11-03 22:08:23 -05:00
ede5958a46 Fix main container padding when printing 2023-11-02 01:01:24 -05:00
0b3b160e87 Rename config.yaml to hugo.yaml in exampleSite 2023-10-21 21:45:22 -05:00
12c6efc0fe Add "Skip to main content" tab-focusable button
- https://webaim.org/techniques/skipnav/
- https://css-tricks.com/how-to-create-a-skip-to-content-link/
2023-10-21 20:21:26 -05:00
0e930f7ae1 Clean up dom layout of full-width page lists
They shouldn't be a child of the centered, max-width'd body because they
need to be full width. So put them outside of the main container div.
2023-10-21 19:44:02 -05:00
17 changed files with 96 additions and 133 deletions

View File

@ -8,7 +8,7 @@ comments: true
draft: true
authors:
- {{ with .Site.Author.name }}{{ . }}{{ else }}John Doe{{ end }}
- {{ with .Site.Params.author.name }}{{ . }}{{ else }}John Doe{{ end }}
categories:
- archetype-stuff

View File

@ -6,7 +6,7 @@ toc: true
comments: false
authors:
- {{ with .Site.Author.name }}{{ . }}{{ else }}John Doe{{ end }}
- {{ with .Site.params.author.name }}{{ . }}{{ else }}John Doe{{ end }}
---

View File

@ -177,19 +177,14 @@ body {
margin: 0;
}
.center-body {
margin: 20px;
max-width: 720px;
}
@media (min-width: 760px) {
.center-body {
margin: 20px auto;
}
.main-container {
margin: 20px auto;
padding: 0 20px;
max-width: 760px; /* 720px + 20px for left & right padding */
}
footer {
margin-top: 20px;
margin: 20px 0;
text-align: center;
font-size: smaller;
}
@ -366,20 +361,19 @@ h1 svg.icon {
/* }}} */
/* Back to top {{{ */
#top {
font-size: 0;
/* Skip to main content {{{ */
#skip-to-main {
position: absolute;
padding: 8px;
background-color: var(--text-0);
color: var(--background-0);
transform: translateY(-100%);
}
#back-to-top {
position: fixed;
float: right;
bottom: 25px;
right: 25px;
background-color: var(--background-1);
color: var(--text-1);
border-radius: 100%;
padding: 12px;
display: none;
#skip-to-main:focus {
transform: translateY(0%);
}
#main-content:target {
animation: none; /* prevent it from turning yellow */
}
/* }}} */
@ -864,22 +858,22 @@ aside {
}
aside.note {
background-color: var(--background-blue-1);
background-color: var(--accent-blue-1);
}
aside.info {
background-color: var(--background-green-1);
background-color: var(--accent-green-1);
}
aside.tip {
background-color: var(--background-teal-1);
background-color: var(--accent-teal-1);
}
aside.warning {
background-color: var(--background-yellow-1);
background-color: var(--accent-yellow-1);
}
aside.example {
background-color: var(--background-purple-1);
background-color: var(--accent-purple-1);
}
aside.quote {
background-color: var(--background-1);
background-color: var(--accent-1);
}
/* }}} */
@ -893,47 +887,26 @@ aside.quote {
margin: 25px 0;
}
.full-width-page-list > hr,
.full-width-page-list > h1 {
.related-posts > hr,
.related-posts > h1 {
margin-left: 20px;
margin-right: 20px;
}
.full-width-page-list .page {
.related-posts .page {
min-width: 300px;
max-width: 300px;
}
.full-width-page-list .page:first-child {
.related-posts .page:first-child {
margin-left: 20px;
}
.full-width-page-list .page:last-child {
.related-posts .page:last-child {
margin-right: 20px;
}
@media (max-width: 720px) {
/* when the screen is smaller than max size, make sure that the .related div
* still reaches the screen edge. then if the posts overflow and require
* scrolling, you can see it cut off on the side of your phone screen
*/
.full-width-page-list {
margin-left: -20px;
margin-right: -20px;
}
}
@media (min-width: 720px) {
.full-width-page-list {
/* this makes it full width -- 720px max-width on body it is exactly 720px
* so .related takes up full width
*/
margin-left: calc(-100vw / 2 + 720px / 2);
margin-right: calc(-100vw / 2 + 720px / 2);
}
}
.full-width-page-list .page-list {
.related-posts .page-list {
display: flex;
flex-direction: row;
gap: 20px;
@ -960,8 +933,7 @@ aside.quote {
.post-meta-edit-history,
.prevnext,
.share-buttons,
.related-posts,
.latest-posts {
.related-posts {
display: none;
}
@ -977,9 +949,10 @@ aside.quote {
margin-left: 0;
margin-right: 0;
}
.center-body {
.main-container {
max-width: 100%;
margin: 8px 0;
padding: 0;
}
.breadcrumb {
@ -1000,8 +973,32 @@ aside.quote {
display: block;
}
#back-to-top {
display: none !important;
/*
* reduce usage of background colors
*/
aside {
background-color: unset !important;
border: 4px solid;
}
aside.note {
border-color: var(--background-blue-1);
}
aside.info {
border-color: var(--background-green-1);
}
aside.tip {
border-color: var(--background-teal-1);
}
aside.warning {
border-color: var(--background-yellow-1);
}
aside.example {
border-color: var(--background-purple-1);
}
aside.quote {
border-color: var(--background-1);
}
}

View File

@ -1,13 +1,3 @@
// back to top
const backToTop = document.getElementById("back-to-top");
window.onscroll = function() {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
backToTop.style.display = "block";
} else {
backToTop.style.display = "none";
}
}
// code block copy to clipboard
window.onload = () => {
document.querySelectorAll(".code-block").forEach(codeBlock => {

View File

@ -10,13 +10,13 @@ enableGitInfo: true
taxonomies:
_merge: deep
author:
name: bbaovanc
markup: # this just keeps the bobatheme markup styling
_merge: deep
params:
author:
name: bbaovanc
# these are for the OpenGraph/Twitter embeds in Hugo
description: Example website for bobatheme
@ -32,9 +32,6 @@ params:
# gitFileIcon: github-circle
# gitHistoryURL: https://github.com/BBaoVanC/bobatheme/commits/master
# display a "Latest Posts" section on the homepage below its content
homepageLatestPosts: true
# social media share icons
# shareButtons:
# twitter: true

View File

@ -4,46 +4,37 @@
{{ partial "head.html" . }}
<body>
<a id="top" aria-hidden="true"></a>
<a id="skip-to-main" href="#main-content">Skip to main content</a>
{{ partial "top.html" . }}
<div class="center-body">
<div class="main-container">
{{ if not .IsHome }}
{{ partial "breadcrumb.html" . }}
{{ end }}
<main>
<main id="main-content">
{{ block "main" . }}
THIS TEXT SHOULD NOT SHOW. YUZSIQGHE (that string is so I can grep for it)
{{ end }}
</main>
{{ if or .Site.Copyright .Site.Params.footer }}
<footer>
{{ with .Site.Copyright }}
<p>{{ . | safeHTML }}</p>
{{ end }}
{{ with .Site.Params.footer }}
{{ . | $.RenderString (dict "display" "block") }}
{{ end }}
</footer>
{{ end }}
<a id="back-to-top" href="#top" aria-label="{{ i18n "aria_back_to_top_button" }}">
{{ partial "icon.html" "chevron-up" }}
</a>
<noscript>
<style>
#back-to-top {
display: block;
}
</style>
</noscript>
</div>
{{ block "post-body" . }}
{{/* currently this is only used for related posts */}}
{{ end }}
{{ if or .Site.Copyright .Site.Params.footer }}
<footer>
{{ with .Site.Copyright }}
<p>{{ . | safeHTML }}</p>
{{ end }}
{{ with .Site.Params.footer }}
{{ . | $.RenderString (dict "display" "block") }}
{{ end }}
</footer>
{{ end }}
</body>
</html>

View File

@ -73,17 +73,16 @@
{{ partial "comments.html" . }}
</div>
{{ end }}
{{ end }}
{{ define "post-body" }}
{{ $related := .Site.RegularPages.Related . | first 10 }}
{{ with $related }}
<div class="related-posts full-width-page-list">
<div class="related-posts">
<hr>
<h1>{{ i18n "related_posts" }}</h1>
{{ partial "page-list.html" . }}
</div>
{{ end }}
{{ if .Site.Params.latestPostsOnContent }}
{{ partialCached "latest-posts.html" . }}
{{ end }}
{{ end }}

View File

@ -9,7 +9,7 @@
{{ with index . "src" }}
{{ $media := . }}
{{ if eq .MediaType.MainType "image" }}
<img src="{{ $media.Permalink }}" alt="{{ $media.Title }}" />
<img src="{{ $media.Permalink }}" alt="{{ $media.Title }}" loading="lazy" />
{{ else if eq .MediaType.MainType "video" }}
<video controls preload="metadata">
<source src="{{ $media.Permalink }}" alt="{{ $media.Title }}">

View File

@ -7,10 +7,10 @@
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ with resources.Get "css/syntax.css" | fingerprint "sha512" }}
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous" media="print" onload="this.media='all'">
{{ end }}
{{ with resources.Get "css/syntax-light.css" | fingerprint "sha512" }}
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous" media="print" onload="this.media='all'">
{{ end }}
{{ with resources.Get "js/bobatheme.js" | fingerprint "sha512" }}

View File

@ -1,11 +0,0 @@
<div class="latest-posts full-width-page-list">
<hr>
<h1>
{{ i18n "latest_posts" }}
{{ partial "rss-link.html" .Site.Home }}
</h1>
{{ with .Site.RegularPages | first 5 }}
{{ partial "page-list.html" . }}
{{ end }}
</div>

View File

@ -6,9 +6,9 @@
{{ $authors := slice }}
{{ range . }}
{{ $url := (printf "authors/%s" (. | anchorize)) | absLangURL }}
{{ $authors = $authors | append (printf `<a href="%s">%s</a>` $url . | safeHTML) }}
{{ $authors = $authors | append (printf `<a href="%s">%s</a>` $url .) }}
{{ end }}
{{ delimit $authors ", " }}
{{ delimit $authors ", " | safeHTML }}
{{ else }}
{{ delimit . ", " }}
{{ end }}

View File

@ -6,6 +6,6 @@
<div class="page-metadata-section categories" aria-label="{{ i18n "aria_post_meta_categories" }}">
{{ partial "icon.html" "folder" }}
{{ delimit $categories ", " }}
{{ delimit $categories ", " | safeHTML }}
</div>
{{ end }}

View File

@ -6,6 +6,6 @@
<div class="page-metadata-section series" aria-label="{{ i18n "aria_post_meta_series" }}">
{{ partial "icon.html" "files" }}
{{ delimit $series ", " }}
{{ delimit $series ", " | safeHTML }}
</div>
{{ end }}

View File

@ -6,6 +6,6 @@
<div class="page-metadata-section tags" aria-label="{{ i18n "aria_post_meta_tags" }}">
{{ partial "icon.html" "tag" }}
{{ delimit $tags ", " }}
{{ delimit $tags ", " | safeHTML }}
</div>
{{ end }}

View File

@ -10,7 +10,7 @@
{{ end }}
{{ if eq $type "image" }}
<img src="{{ $src }}" alt="{{ $alt }}" />
<img src="{{ $src }}" alt="{{ $alt }}" loading="lazy" />
{{ else if eq $type "video" }}
<video controls preload="metadata">
<source src="{{ $src }}" alt="{{ $alt }}">

View File

@ -12,6 +12,6 @@
This post is part of a series:
{{ end }}
{{ delimit $series ", " }}
{{ delimit $series ", " | safeHTML }}
</div>
{{ end }}