mirror of
https://github.com/davegallant/davegallant.github.io.git
synced 2025-08-06 00:33:39 +00:00
Tweak theme
This commit is contained in:
28
themes/custom-theme/assets/css/critical/00-vendor.css
Normal file
28
themes/custom-theme/assets/css/critical/00-vendor.css
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Critical CSS for above-the-fold content, delivered inline to increase first
|
||||
paint performance
|
||||
*/
|
||||
|
||||
/*! purgecss start ignore */
|
||||
|
||||
/* Typefaces */
|
||||
@import "typeface-roboto-slab";
|
||||
@import "typeface-fira-code";
|
||||
|
||||
/* Normalize */
|
||||
@import "normalize.css/normalize.css";
|
||||
|
||||
/*! purgecss end ignore */
|
||||
|
||||
/*! CC BY-SA 3.0 License | https://stackoverflow.com/a/36118384/1154965 */
|
||||
@keyframes blink {
|
||||
50% {
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Default license header for non-vendor CSS source code that follows */
|
||||
/*! MIT License | github.com/schnerring/hugo-theme-gruvbox */
|
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Bootstrap 5 breakpoints
|
||||
See: https://getbootstrap.com/docs/5.0/layout/breakpoints/#available-breakpoints
|
||||
*/
|
||||
@custom-media --sm (min-width: 576px);
|
||||
@custom-media --md (min-width: 768px);
|
||||
@custom-media --lg (min-width: 992px);
|
||||
@custom-media --xl (min-width: 1200px);
|
||||
@custom-media --xxl (min-width: 1400px);
|
49
themes/custom-theme/assets/css/critical/15-colors.css
Normal file
49
themes/custom-theme/assets/css/critical/15-colors.css
Normal file
@@ -0,0 +1,49 @@
|
||||
{{ $themeContrast := .Param "themeContrast" | default "medium" }}
|
||||
{{ $backgroundColor := "bg0" }}
|
||||
{{ if eq $themeContrast "soft" }}
|
||||
{{ $backgroundColor = "bg0_s" }}
|
||||
{{ else if eq $themeContrast "hard" }}
|
||||
{{ $backgroundColor = "bg0_h" }}
|
||||
{{ end }}
|
||||
|
||||
:root[data-theme="dark"] {
|
||||
--bg: var(--{{ $backgroundColor }});
|
||||
--bg0: #1a1b26;
|
||||
--bg0_h: #1d2021;
|
||||
--bg0_s: #32302f;
|
||||
--bg1: #181922;
|
||||
--bg2: #32344a;
|
||||
--bg3: #665c54;
|
||||
--bg4: #32344a;
|
||||
--fg: var(--fg1);
|
||||
--fg0: #89DDFF;
|
||||
--fg1: #dddfeb;
|
||||
--fg2: #7da6ff;
|
||||
--fg3: #9ece6a;
|
||||
--fg4: #32344a;
|
||||
--gray1: var(--fg4);
|
||||
--gray2: #444b6a;
|
||||
--red1: #f7768e;
|
||||
--red2: #ff7a93;
|
||||
--green1: #9ece6a;
|
||||
--green2: #b9f27c;
|
||||
--yellow1: #e0af68;
|
||||
--yellow2: #ff9e64;
|
||||
--blue1: #89DDFF;
|
||||
--blue2: #89DDFF;
|
||||
--purple1: #ad8ee6;
|
||||
--purple2: #bb9af7;
|
||||
--aqua1: #449dab;
|
||||
--aqua2: #0db9d7;
|
||||
--orange1: #d65d0e;
|
||||
--orange2: #fe8019;
|
||||
|
||||
& .dark--hidden {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
:root {
|
||||
--primary: var(--blue1);
|
||||
--primary-alt: var(--blue2);
|
||||
}
|
238
themes/custom-theme/assets/css/critical/20-base.css
Normal file
238
themes/custom-theme/assets/css/critical/20-base.css
Normal file
@@ -0,0 +1,238 @@
|
||||
:root {
|
||||
--font-monospace: "Fira Code", "Lucida Console", Monaco, monospace;
|
||||
--font-sans-serif: Verdana, Helvetica, sans-serif;
|
||||
--font-serif: "Roboto Slab", Georgia, serif;
|
||||
}
|
||||
|
||||
html {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 1rem;
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--fg);
|
||||
line-height: 1.675;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
strong {
|
||||
letter-spacing: 0.35px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.link--external::after {
|
||||
/* 2009 = Thin Space */
|
||||
content: "\2009↗";
|
||||
}
|
||||
|
||||
img,
|
||||
video {
|
||||
border: 2px solid var(--bg1);
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
figure {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
color: var(--fg3);
|
||||
font-family: var(--font-serif);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
*::selection {
|
||||
color: var(--fg0);
|
||||
background: var(--bg4);
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
color: var(--fg0);
|
||||
font-family: var(--font-monospace);
|
||||
font-weight: 300;
|
||||
line-height: 1.4;
|
||||
|
||||
& code {
|
||||
font-size: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
border-bottom: 1px solid var(--bg1);
|
||||
}
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.875rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.75rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.625rem;
|
||||
}
|
||||
|
||||
@media (--md) {
|
||||
h1 {
|
||||
font-size: 2.375rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.375rem;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
table {
|
||||
table-layout: fixed;
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin: 2rem 0;
|
||||
}
|
||||
|
||||
table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid var(--bg1);
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: none;
|
||||
background: var(--bg1);
|
||||
height: 1px;
|
||||
margin: 3rem auto;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
mark {
|
||||
background: var(--yellow1);
|
||||
color: var(--bg0);
|
||||
}
|
||||
|
||||
abbr {
|
||||
text-underline-offset: 0.2rem;
|
||||
}
|
||||
|
||||
blockquote,
|
||||
code,
|
||||
kbd,
|
||||
mark,
|
||||
pre {
|
||||
border-radius: 0.2rem;
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
|
||||
pre code {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
blockquote,
|
||||
code,
|
||||
kbd,
|
||||
pre,
|
||||
th {
|
||||
background: var(--bg1);
|
||||
}
|
||||
|
||||
code,
|
||||
kbd,
|
||||
pre,
|
||||
th {
|
||||
font-family: var(--font-monospace);
|
||||
}
|
||||
|
||||
code,
|
||||
kbd {
|
||||
& code,
|
||||
& kbd {
|
||||
background: var(--bg2);
|
||||
}
|
||||
}
|
||||
|
||||
blockquote,
|
||||
pre {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
pre {
|
||||
/* TODO is !important really needed because of Prism? */
|
||||
background: var(--bg1) !important;
|
||||
overflow: auto;
|
||||
|
||||
& code {
|
||||
background: none;
|
||||
}
|
||||
}
|
||||
|
||||
blockquote,
|
||||
blockquote.twitter-tweet {
|
||||
border-left: var(--primary-alt) 5px solid;
|
||||
margin: 0.5rem 0;
|
||||
|
||||
& code {
|
||||
background: var(--bg2);
|
||||
}
|
||||
|
||||
& p:first-of-type {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
& p:last-of-type {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
blockquote.twitter-tweet {
|
||||
border-color: var(--blue2);
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
|
||||
& a {
|
||||
color: var(--blue2);
|
||||
}
|
||||
|
||||
& a:hover {
|
||||
color: var(--blue1);
|
||||
text-decoration: none !important;
|
||||
}
|
||||
}
|
14
themes/custom-theme/assets/css/critical/20-scrollbar.css
Normal file
14
themes/custom-theme/assets/css/critical/20-scrollbar.css
Normal file
@@ -0,0 +1,14 @@
|
||||
pre::-webkit-scrollbar {
|
||||
height: 0.5rem;
|
||||
scrollbar-width: auto;
|
||||
}
|
||||
|
||||
pre::-webkit-scrollbar-track {
|
||||
background: var(--bg2);
|
||||
border-radius: 0.2rem;
|
||||
}
|
||||
|
||||
pre::-webkit-scrollbar-thumb {
|
||||
background: var(--bg4);
|
||||
border-radius: 0.2rem;
|
||||
}
|
48
themes/custom-theme/assets/css/critical/25-layout.css
Normal file
48
themes/custom-theme/assets/css/critical/25-layout.css
Normal file
@@ -0,0 +1,48 @@
|
||||
.layout {
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
"header"
|
||||
"main"
|
||||
"footer";
|
||||
grid-template-rows: auto 1fr auto;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
main {
|
||||
align-items: start;
|
||||
display: grid;
|
||||
grid-area: main;
|
||||
grid-template-areas: "empty content sidebar";
|
||||
grid-template-columns: 2fr minmax(0, 860px) 2fr;
|
||||
}
|
||||
|
||||
header {
|
||||
background: var(--bg1);
|
||||
grid-area: header;
|
||||
}
|
||||
|
||||
footer {
|
||||
grid-area: footer;
|
||||
}
|
||||
|
||||
main,
|
||||
footer {
|
||||
margin: 0.5em 1.1em;
|
||||
}
|
||||
|
||||
.content {
|
||||
grid-area: content;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
grid-area: sidebar;
|
||||
margin-top: 3rem;
|
||||
position: sticky;
|
||||
top: 2rem;
|
||||
|
||||
@media (--lg) {
|
||||
display: flex;
|
||||
}
|
||||
}
|
285
themes/custom-theme/assets/css/critical/30-header.css
Normal file
285
themes/custom-theme/assets/css/critical/30-header.css
Normal file
@@ -0,0 +1,285 @@
|
||||
header {
|
||||
display: grid;
|
||||
font-family: var(--font-monospace);
|
||||
font-size: 1.125rem;
|
||||
grid-template-columns: auto auto 1fr auto;
|
||||
grid-template-areas: "heading search nav theme-toggle";
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.logo {
|
||||
color: var(--fg0);
|
||||
display: flex;
|
||||
font-weight: 700;
|
||||
grid-area: heading;
|
||||
|
||||
&:hover .logo__cursor {
|
||||
animation: 1s blink infinite;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.logo__chevron,
|
||||
.logo__cursor {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.logo__cursor {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.logo__text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (--md) {
|
||||
.logo__text {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
/*! purgecss start ignore */
|
||||
|
||||
.search {
|
||||
display: flex;
|
||||
grid-area: search;
|
||||
margin: 0 1rem;
|
||||
}
|
||||
|
||||
#search__text {
|
||||
border: 1px solid var(--bg2);
|
||||
border-radius: 0.2rem;
|
||||
background: var(--bg2);
|
||||
caret-color: var(--fg);
|
||||
color: var(--fg);
|
||||
outline: none;
|
||||
padding: 0 0.5rem;
|
||||
width: 100%;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--bg3);
|
||||
}
|
||||
|
||||
&:focus {
|
||||
border-color: var(--bg4);
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: var(--fg1);
|
||||
}
|
||||
|
||||
&[type="search"]::-webkit-search-cancel-button {
|
||||
appearance: none;
|
||||
}
|
||||
}
|
||||
|
||||
#search__suggestions {
|
||||
background: var(--bg);
|
||||
border-radius: 0.2rem;
|
||||
box-shadow: 0 0.5rem 1rem var(--bg1);
|
||||
font-family: var(--font-serif);
|
||||
left: 0;
|
||||
margin-top: 2rem;
|
||||
position: absolute;
|
||||
width: 95vw;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
@media (--md) {
|
||||
.search {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#search__suggestions {
|
||||
width: 60vw;
|
||||
}
|
||||
}
|
||||
|
||||
.search__suggestions--hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.search__suggestion-item {
|
||||
border-bottom: 1px dashed var(--bg2);
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 2fr;
|
||||
|
||||
&:focus,
|
||||
&:focus-visible,
|
||||
&:hover {
|
||||
background: var(--bg1);
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
.search__suggestion-title,
|
||||
.search__suggestion-description {
|
||||
padding: 0 1rem;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.search__suggestion-title {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.search__suggestion-description {
|
||||
border-left: 1px solid var(--bg2);
|
||||
}
|
||||
|
||||
.search__no-results {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
/*! purgecss end ignore */
|
||||
|
||||
.theme__toggle {
|
||||
align-items: center;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--yellow1);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
grid-area: theme-toggle;
|
||||
margin: 0 1rem;
|
||||
|
||||
&:hover {
|
||||
color: var(--yellow2);
|
||||
}
|
||||
|
||||
& svg {
|
||||
height: 28px;
|
||||
width: 28px;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: simplify deep nesting */
|
||||
nav#menu {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
grid-area: nav;
|
||||
justify-content: flex-end;
|
||||
|
||||
& .menu__item {
|
||||
color: var(--fg);
|
||||
|
||||
&:hover {
|
||||
color: var(--fg3);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
& ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
& ul.menu--horizontal {
|
||||
align-items: center;
|
||||
display: none;
|
||||
|
||||
& li {
|
||||
display: inline-block;
|
||||
margin: 0 0.75rem;
|
||||
}
|
||||
|
||||
@media (--md) {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
& ul.menu--vertical {
|
||||
background: var(--bg1);
|
||||
bottom: 0;
|
||||
margin: 0;
|
||||
padding: 3rem;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
transform: translate(100%, 0);
|
||||
transition: transform 0.5s cubic-bezier(0.9, 0, 0.1, 1);
|
||||
width: 50%;
|
||||
z-index: 10;
|
||||
|
||||
& .menu__item {
|
||||
color: var(--fg1);
|
||||
|
||||
&:hover {
|
||||
color: var(--fg3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
& .menu__burger {
|
||||
display: flex;
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
|
||||
& > * {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
& svg {
|
||||
width: inherit;
|
||||
z-index: 20;
|
||||
height: inherit;
|
||||
|
||||
& line {
|
||||
transition-duration: 0.5s;
|
||||
transition-property: stroke, opacity, transform;
|
||||
transition-timing-function: cubic-bezier(0.9, 0, 0.1, 1);
|
||||
}
|
||||
|
||||
& line:nth-of-type(1) {
|
||||
transform-origin: center 6px;
|
||||
}
|
||||
|
||||
& line:nth-of-type(2) {
|
||||
transform-origin: center 12px;
|
||||
}
|
||||
|
||||
& line:nth-of-type(3) {
|
||||
transform-origin: center 18px;
|
||||
}
|
||||
}
|
||||
|
||||
& input {
|
||||
height: inherit;
|
||||
opacity: 0;
|
||||
width: inherit;
|
||||
z-index: 30;
|
||||
|
||||
&:checked {
|
||||
& ~ ul.menu--vertical {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
& ~ svg {
|
||||
stroke: var(--fg1);
|
||||
|
||||
& line:nth-of-type(1) {
|
||||
transform: translate(0, 6px) rotate(45deg);
|
||||
}
|
||||
|
||||
& line:nth-of-type(2) {
|
||||
opacity: 0;
|
||||
transform: scale(0.2);
|
||||
}
|
||||
|
||||
& line:nth-of-type(3) {
|
||||
transform: translate(0, -6px) rotate(-45deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (--md) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
70
themes/custom-theme/assets/css/critical/35-sidebar.css
Normal file
70
themes/custom-theme/assets/css/critical/35-sidebar.css
Normal file
@@ -0,0 +1,70 @@
|
||||
.sidebar {
|
||||
font-family: var(--font-monospace);
|
||||
max-width: 350px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
padding-left: 2.5rem;
|
||||
|
||||
& hr {
|
||||
margin: 1.5rem auto;
|
||||
}
|
||||
|
||||
& svg {
|
||||
fill: var(--fg);
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar__heading {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
|
||||
aside.toc {
|
||||
& a {
|
||||
color: var(--primary-alt);
|
||||
}
|
||||
|
||||
& a:hover {
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
& ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
& ul {
|
||||
font-size: 0.9rem;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
& li {
|
||||
line-height: 1.1;
|
||||
|
||||
& a {
|
||||
display: block;
|
||||
padding: 0.2rem 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.jr-basics__image {
|
||||
background: var(--bg1);
|
||||
border: 2px solid var(--bg2);
|
||||
}
|
||||
|
||||
.jr-basics__summary {
|
||||
color: var(--fg3);
|
||||
font-family: var(--font-serif);
|
||||
margin: 0.75rem 0;
|
||||
}
|
||||
|
||||
.jr-basics__profile {
|
||||
& a:hover {
|
||||
color: var(--fg3);
|
||||
|
||||
& svg {
|
||||
fill: var(--fg3);
|
||||
}
|
||||
}
|
||||
}
|
76
themes/custom-theme/assets/css/critical/40-post.css
Normal file
76
themes/custom-theme/assets/css/critical/40-post.css
Normal file
@@ -0,0 +1,76 @@
|
||||
.post,
|
||||
.content-section {
|
||||
border-bottom: 2px dotted var(--bg1);
|
||||
padding: 2rem 0;
|
||||
}
|
||||
|
||||
.post {
|
||||
& figure,
|
||||
& img:not(figure img),
|
||||
& video:not(figure video) {
|
||||
margin: 0.5rem 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
.post-header,
|
||||
.post-content__read-more {
|
||||
font-family: var(--font-monospace);
|
||||
}
|
||||
|
||||
.post-meta__author {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.post-content {
|
||||
margin: 1.3rem 0;
|
||||
}
|
||||
|
||||
.post-content__read-more {
|
||||
color: var(--primary-alt);
|
||||
margin-top: 1.3rem;
|
||||
}
|
||||
|
||||
.content-section,
|
||||
.post-header,
|
||||
.post-content {
|
||||
& a {
|
||||
color: var(--primary-alt);
|
||||
}
|
||||
|
||||
& a:hover {
|
||||
color: var(--primary);
|
||||
}
|
||||
}
|
||||
|
||||
.post-tags {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.9rem;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.post-tag {
|
||||
font-size: 0.9rem;
|
||||
line-height: 1;
|
||||
|
||||
&::before {
|
||||
content: "#";
|
||||
}
|
||||
}
|
||||
|
||||
.post-heading__anchor {
|
||||
display: none;
|
||||
}
|
||||
|
||||
h1:hover,
|
||||
h2:hover,
|
||||
h3:hover,
|
||||
h4:hover,
|
||||
h5:hover,
|
||||
h6:hover {
|
||||
& .post-heading__anchor {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
24
themes/custom-theme/assets/css/non-critical/00-vendor.css
Normal file
24
themes/custom-theme/assets/css/non-critical/00-vendor.css
Normal file
@@ -0,0 +1,24 @@
|
||||
/*! purgecss start ignore */
|
||||
|
||||
/* Prism Plugins */
|
||||
{{ range $.Site.Params.prism.plugins }}
|
||||
{{ $path := printf "prismjs/plugins/%s/prism-%s.css" . . }}
|
||||
{{ $plugin := resources.Get $path }}
|
||||
{{ if $plugin }}
|
||||
{{ printf "/*%s*/" $plugin }}
|
||||
@import "{{ $plugin }}";
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
/* Prism Font */
|
||||
code,
|
||||
kbd,
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
font-family: var(--font-monospace);
|
||||
}
|
||||
|
||||
/*! purgecss end ignore */
|
||||
|
||||
/* Default license header for non-vendor CSS source code that follows */
|
||||
/*! MIT License | github.com/schnerring/hugo-theme-gruvbox */
|
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Bootstrap 5 breakpoints
|
||||
See: https://getbootstrap.com/docs/5.0/layout/breakpoints/#available-breakpoints
|
||||
*/
|
||||
@custom-media --sm (min-width: 576px);
|
||||
@custom-media --md (min-width: 768px);
|
||||
@custom-media --lg (min-width: 992px);
|
||||
@custom-media --xl (min-width: 1200px);
|
||||
@custom-media --xxl (min-width: 1400px);
|
11
themes/custom-theme/assets/css/non-critical/15-footer.css
Normal file
11
themes/custom-theme/assets/css/non-critical/15-footer.css
Normal file
@@ -0,0 +1,11 @@
|
||||
footer {
|
||||
align-items: center;
|
||||
color: var(--fg3);
|
||||
display: flex;
|
||||
font-family: var(--font-monospace);
|
||||
font-size: 0.8rem;
|
||||
justify-content: center;
|
||||
padding-bottom: 0.5rem;
|
||||
padding-top: 2rem;
|
||||
text-align: center;
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
.pagination {
|
||||
display: flex;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.pagination__button {
|
||||
color: var(--primary-alt);
|
||||
font-family: var(--font-monospace);
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
.pagination__button:hover {
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
.pagination__button--next {
|
||||
margin-left: auto;
|
||||
}
|
46
themes/custom-theme/assets/js/dark-mode.js
Normal file
46
themes/custom-theme/assets/js/dark-mode.js
Normal file
@@ -0,0 +1,46 @@
|
||||
function getTheme() {
|
||||
if (localStorage && localStorage.getItem("theme")) {
|
||||
return localStorage.getItem("theme");
|
||||
}
|
||||
return "auto";
|
||||
}
|
||||
|
||||
function saveTheme(theme) {
|
||||
localStorage.setItem("theme", theme);
|
||||
}
|
||||
|
||||
function setPrismTheme(theme) {
|
||||
const prismDark = document.getElementById("prism-dark");
|
||||
const prismLight = document.getElementById("prism-light");
|
||||
prismDark.toggleAttribute("disabled", theme === "light");
|
||||
prismLight.toggleAttribute("disabled", theme === "dark");
|
||||
}
|
||||
|
||||
function setCommentsTheme(theme) {
|
||||
if (document.querySelector(".utterances-frame")) {
|
||||
const iframe = document.querySelector(".utterances-frame");
|
||||
var message = {
|
||||
type: "set-theme",
|
||||
theme: theme == "dark" ? "gruvbox-dark" : "github-light",
|
||||
};
|
||||
iframe.contentWindow.postMessage(message, "https://utteranc.es");
|
||||
}
|
||||
}
|
||||
|
||||
function setTheme(theme) {
|
||||
document.documentElement.setAttribute("data-theme", theme);
|
||||
setPrismTheme(theme);
|
||||
setCommentsTheme(theme);
|
||||
}
|
||||
|
||||
|
||||
setTheme("dark");
|
||||
|
||||
// This script is inlined in the <head> of the document, so we have to wait
|
||||
// for the DOM content before can add event listeners to the toggle buttons
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const toggleButtons = document.querySelectorAll(".theme__toggle");
|
||||
toggleButtons.forEach((btn) => {
|
||||
btn.addEventListener("click", toggleTheme);
|
||||
});
|
||||
});
|
137
themes/custom-theme/assets/js/flexsearch.js
Normal file
137
themes/custom-theme/assets/js/flexsearch.js
Normal file
@@ -0,0 +1,137 @@
|
||||
//! Source: https://github.com/h-enk/doks/blob/master/assets/js/index.js
|
||||
|
||||
import { Document } from "flexsearch";
|
||||
|
||||
const search = document.getElementById("search__text");
|
||||
const suggestions = document.getElementById("search__suggestions");
|
||||
|
||||
if (search !== null) {
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.ctrlKey && e.key === "/") {
|
||||
// Focus search bar with CTRL + /
|
||||
e.preventDefault();
|
||||
search.focus();
|
||||
} else if (e.key === "Escape") {
|
||||
// Unfocus search bar with ESC
|
||||
search.blur();
|
||||
suggestions.classList.add("search__suggestions--hidden");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("click", (e) => {
|
||||
const clickInsideSuggestions = suggestions.contains(e.target);
|
||||
if (!clickInsideSuggestions) {
|
||||
// Hide search suggestions if clicking elsewhere
|
||||
suggestions.classList.add("search__suggestions--hidden");
|
||||
}
|
||||
});
|
||||
|
||||
/*! Source: https://dev.to/shubhamprakash/trap-focus-using-javascript-6a3 */
|
||||
document.addEventListener("keydown", (e) => {
|
||||
const suggestionsHidden = suggestions.classList.contains(
|
||||
"search__suggestions--hidden"
|
||||
);
|
||||
if (suggestionsHidden) return;
|
||||
|
||||
const focusableSuggestions = [...suggestions.querySelectorAll("a")];
|
||||
if (focusableSuggestions.length === 0) return;
|
||||
|
||||
const currentIndex = focusableSuggestions.indexOf(document.activeElement);
|
||||
|
||||
if (e.key === "ArrowDown") {
|
||||
// Focus next suggestion
|
||||
e.preventDefault();
|
||||
const nextIndex =
|
||||
currentIndex + 1 < focusableSuggestions.length
|
||||
? currentIndex + 1
|
||||
: currentIndex;
|
||||
focusableSuggestions[nextIndex].focus();
|
||||
} else if (e.key === "ArrowUp") {
|
||||
// Focus previous suggestion
|
||||
e.preventDefault();
|
||||
nextIndex = currentIndex > 0 ? currentIndex - 1 : 0;
|
||||
focusableSuggestions[nextIndex].focus();
|
||||
}
|
||||
});
|
||||
|
||||
(function () {
|
||||
const index = new Document({
|
||||
tokenize: "forward",
|
||||
cache: 100,
|
||||
document: {
|
||||
id: "id",
|
||||
store: ["href", "title", "description"],
|
||||
index: ["title", "description", "content"],
|
||||
},
|
||||
});
|
||||
|
||||
//! Source: https://discourse.gohugo.io/t/range-length-or-last-element/3803/2
|
||||
{{ $list := (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) }}
|
||||
{{ $len := (len $list) }}
|
||||
|
||||
index.add(
|
||||
{{ range $index, $element := $list }}
|
||||
{
|
||||
id: {{ $index }},
|
||||
href: "{{ .RelPermalink }}",
|
||||
title: {{ .Title | jsonify }},
|
||||
{{ with .Description }}
|
||||
description: {{ . | jsonify }},
|
||||
{{ else }}
|
||||
description: {{ .Summary | plainify | jsonify }},
|
||||
{{ end }}
|
||||
content: {{ .Plain | jsonify }}
|
||||
})
|
||||
{{ if ne (add $index 1) $len }}
|
||||
.add(
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if eq 0 $len }}
|
||||
)
|
||||
{{ end }}
|
||||
;
|
||||
|
||||
search.addEventListener("input", function () {
|
||||
const maxResultsCount = {{ $.Site.Params.flexsearch.maxResultsCount | default 5 }};
|
||||
const searchText = this.value;
|
||||
const searchResults = index.search(searchText, maxResultsCount, { enrich: true });
|
||||
const searchResultsMap = new Map();
|
||||
|
||||
// Deduplicate search results by href
|
||||
for (const searchResult of searchResults.flatMap((r) => r.result)) {
|
||||
if (searchResultsMap.has(searchResult.href)) continue;
|
||||
searchResultsMap.set(searchResult.doc.href, searchResult.doc);
|
||||
}
|
||||
|
||||
suggestions.innerHTML = "";
|
||||
suggestions.classList.remove("search__suggestions--hidden");
|
||||
|
||||
if (searchResultsMap.size === 0 && searchText) {
|
||||
const noResultsMessage = document.createElement("div")
|
||||
noResultsMessage.innerHTML = `No results for "<strong>${searchText}</strong>"`
|
||||
noResultsMessage.classList.add("search__no-results");
|
||||
suggestions.appendChild(noResultsMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const [href, searchResult] of searchResultsMap) {
|
||||
const suggestion = document.createElement("a");
|
||||
suggestion.href = href;
|
||||
suggestion.classList.add("search__suggestion-item");
|
||||
suggestions.appendChild(suggestion);
|
||||
|
||||
const title = document.createElement("div");
|
||||
title.textContent = searchResult.title;
|
||||
title.classList.add("search__suggestion-title");
|
||||
suggestion.appendChild(title);
|
||||
|
||||
const description = document.createElement("div");
|
||||
description.textContent = searchResult.description;
|
||||
description.classList.add("search__suggestion-description");
|
||||
suggestion.appendChild(description);
|
||||
|
||||
if (suggestions.childElementCount === maxResultsCount) break;
|
||||
}
|
||||
});
|
||||
})();
|
11
themes/custom-theme/assets/js/prism.js
Normal file
11
themes/custom-theme/assets/js/prism.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import Prism from "prismjs";
|
||||
|
||||
{{ range $.Site.Params.prism.languages }}
|
||||
import "prismjs/components/prism-{{ . }}";
|
||||
{{ end }}
|
||||
|
||||
{{ range $.Site.Params.prism.plugins }}
|
||||
import "prismjs/plugins/{{ . }}/prism-{{ . }}";
|
||||
{{ end }}
|
||||
|
||||
Prism.highlightAll();
|
Reference in New Issue
Block a user