chore: add PaperMod theme files

This commit is contained in:
James committed 2026-11-14 19:45:55 +08:00
1 parent a3365e53a5
commit 58fda1b0b3
126 files changed
+6260 -1

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
.not-found {
position: absolute;
left: 0;
right: 0;
display: flex;
align-items: center;
justify-content: center;
height: 80%;
font-size: 160px;
font-weight: 700;
}
@@ -0,0 +1,44 @@
.archive-posts {
width: 100%;
font-size: 16px;
}
.archive-year {
margin-top: 40px;
}
.archive-year:not(:last-of-type) {
border-bottom: 2px solid var(--border);
}
.archive-month {
display: flex;
align-items: flex-start;
padding: 10px 0;
}
.archive-month-header {
margin: 25px 0;
width: 200px;
}
.archive-month:not(:last-of-type) {
border-bottom: 1px solid var(--border);
}
.archive-entry {
position: relative;
padding: 5px;
margin: 10px 0;
}
.archive-entry-title {
margin: 5px 0;
font-weight: 400;
}
.archive-count,
.archive-meta {
color: var(--secondary);
font-size: 14px;
}
@@ -0,0 +1,56 @@
.footer,
.top-link {
font-size: 12px;
color: var(--secondary);
}
.footer {
max-width: calc(var(--main-width) + var(--gap) * 2);
margin: auto;
padding: calc((var(--footer-height) - var(--gap)) / 2) var(--gap);
text-align: center;
line-height: 24px;
}
.footer span {
margin-inline-start: 1px;
margin-inline-end: 1px;
}
.footer span:last-child {
white-space: nowrap;
}
.footer a {
color: inherit;
text-underline-offset: 0.25rem;
text-decoration: underline;
}
.top-link {
position: fixed;
bottom: 4rem;
right: 2rem;
z-index: 99;
background: var(--tertiary);
width: 2.5rem;
height: 2.5rem;
padding: 10px;
border-radius: 64px;
transition: visibility .3s, opacity .3s cubic-bezier(0.4, 0, 1, 1);
}
.hidden {
visibility: hidden;
opacity: 0;
}
.top-link,
.top-link svg {
filter: drop-shadow(0px 0px 0px var(--theme));
}
.footer a:hover,
.top-link:hover {
color: var(--primary);
}
@@ -0,0 +1,101 @@
.header-nav {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
max-width: calc(var(--nav-width) + var(--gap) * 2);
margin: auto;
line-height: var(--header-height);
padding: 0 var(--gap);
column-gap: var(--gap);
}
.header-nav a {
display: block;
}
.logo,
.menu {
display: flex;
}
.logo {
align-items: center;
column-gap: 0.55rem;
flex-wrap: wrap;
}
.logo a {
font-size: 24px;
font-weight: 700;
display: flex;
align-items: center;
column-gap: 0.55rem;
}
.logo a img,
.logo a svg {
pointer-events: none;
border-radius: 6px;
}
.theme-toggle {
padding: 0 0.4rem;
}
[data-theme="dark"] .moon {
display: none;
}
[data-theme="light"] .sun {
display: none;
}
.logo-switches {
display: inline-flex;
gap: 0.4rem;
align-items: inherit;
min-height: stretch;
flex-wrap: inherit;
}
.logo-switches>* {
min-height: inherit;
align-items: center;
display: inline-flex;
}
.nav-sep {
color: var(--secondary);
}
.lang-menu * {
display: inherit;
min-height: inherit;
align-items: inherit;
}
.lang-menu a {
font-size: 1rem;
font-weight: 500;
padding: 0 0.4rem;
display: inline-flex
}
.menu {
list-style: none;
word-break: keep-all;
overflow-x: auto;
white-space: nowrap;
column-gap: var(--gap);
}
.menu a {
font-size: 16px;
}
.menu .active {
font-weight: 500;
text-decoration: underline;
text-underline-offset: 0.3rem;
text-decoration-thickness: 2px;
}
@@ -0,0 +1,66 @@
.main {
position: relative;
min-height: calc(100vh - var(--header-height) - var(--footer-height));
max-width: calc(var(--main-width) + var(--gap) * 2);
margin: auto;
padding: var(--gap);
}
.page-header h1 {
font-size: 40px;
}
.pagination {
display: flex;
}
.pagination a {
color: var(--theme);
font-size: 13px;
line-height: 36px;
background: var(--primary);
border-radius: calc(36px / 2);
padding: 0 16px;
}
.pagination .next {
margin-inline-start: auto;
}
.social-icons a {
display: inline-flex;
padding: 10px;
}
.social-icons a svg {
height: 26px;
width: 26px;
}
code {
direction: ltr;
}
div.highlight,
pre {
position: relative;
}
.copy-code {
display: none;
position: absolute;
top: 4px;
right: 4px;
color: rgba(255, 255, 255, 0.8);
background: rgba(78, 78, 78, 0.8);
border-radius: var(--radius);
padding: 0 5px;
font-size: 14px;
user-select: none;
}
div.highlight:hover .copy-code,
pre:hover .copy-code {
display: block;
}
@@ -0,0 +1,228 @@
.md-content h3,
.md-content h4,
.md-content h5,
.md-content h6 {
margin: 24px 0 16px;
}
.md-content h1 {
margin: 40px auto 32px;
font-size: 40px;
}
.md-content h2 {
margin: 32px auto 24px;
font-size: 32px;
}
.md-content h3 {
font-size: 24px;
}
.md-content h4 {
font-size: 16px;
}
.md-content h5 {
font-size: 14px;
}
.md-content h6 {
font-size: 12px;
}
.md-content a:not(.anchor) {
text-underline-offset: 0.3rem;
text-decoration: underline;
}
.md-content del {
text-decoration: line-through;
}
.md-content dl:not(:last-child),
.md-content ol:not(:last-child),
.md-content p:not(:last-child),
.md-content figure:not(:last-child),
.md-content ul:not(:last-child) {
margin-bottom: var(--content-gap);
}
.md-content ol,
.md-content ul {
padding-inline-start: 1.25rem;
}
.md-content li {
margin-top: 0.3rem;
}
.md-content li p {
margin-bottom: 0;
}
.md-content dl {
display: flex;
flex-wrap: wrap;
margin: 0;
}
.md-content dt {
width: 25%;
font-weight: 700;
}
.md-content dd {
width: 75%;
margin-inline-start: 0;
padding-inline-start: 10px;
}
.md-content dd~dd,
.md-content dt~dt {
margin-top: 10px;
}
.md-content table {
margin-bottom: var(--content-gap);
}
.md-content table th,
.md-content table:not(.highlight table, .gist .highlight) td {
min-width: 80px;
padding: 6px 13px;
line-height: 1.5;
border: 1px solid var(--border);
}
.md-content table th {
text-align: start;
}
.md-content table td code:only-child {
margin: auto 0;
}
.md-content .highlight table {
border-radius: var(--radius);
}
.md-content .highlight:not(table) {
margin-bottom: var(--content-gap);
background: var(--code-block-bg) !important;
border-radius: var(--radius);
direction: ltr;
}
.md-content .highlight pre {
margin: 0;
}
.post-content code {
padding: 0.2rem 0.3rem;
font-size: 0.78em;
line-height: 1.5;
background: var(--code-bg);
border-radius: 0.2rem;
}
.md-content pre code {
display: grid;
margin: auto 0;
padding: 10px;
color: rgb(213, 213, 214);
background: var(--code-block-bg) !important;
border-radius: var(--radius);
overflow-x: auto;
word-break: break-all;
}
.md-content blockquote {
margin: 1rem 0;
padding-inline-start: 1rem;
border-inline-start: 0.3rem solid var(--content);
}
.md-content hr {
margin: 30px 0;
height: 2px;
background: var(--tertiary);
border: 0;
}
.md-content iframe {
max-width: 100%;
}
.md-content img {
border-radius: var(--radius);
margin: 1rem 0;
}
.md-content img[src*="#center"] {
margin: 1rem auto;
}
.md-content figure.align-center {
text-align: center;
}
.md-content figure>figcaption {
color: var(--primary);
font-size: 16px;
font-weight: bold;
margin: 8px 0 16px;
}
.md-content figure>figcaption>p {
color: var(--secondary);
font-size: 14px;
font-weight: normal;
}
.md-content h1:hover .anchor,
.md-content h2:hover .anchor,
.md-content h3:hover .anchor,
.md-content h4:hover .anchor,
.md-content h5:hover .anchor,
.md-content h6:hover .anchor {
display: inline-flex;
color: var(--secondary);
margin-inline-start: 0.5em;
font-weight: 500;
user-select: none;
}
.anchor:hover {
color: var(--content) !important;
}
.md-content img.in-text {
display: inline;
margin: auto;
}
mark {
border-radius: 2px;
padding: 0 2px;
}
audio {
display: block;
width: 100%;
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
height: 2.5rem;
margin-bottom: var(--content-gap);
}
audio::-webkit-media-controls-enclosure {
border-radius: 0;
}
video {
border: 1px solid var(--code-bg);
border-radius: var(--radius);
max-width: 100%;
}
@@ -0,0 +1,129 @@
.first-entry {
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
min-height: 320px;
margin: var(--gap) 0 calc(var(--gap) * 2) 0;
}
.first-entry .entry-header {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
}
.first-entry .entry-header h1 {
font-size: 34px;
line-height: 1.3;
}
.first-entry .entry-header h2 {
font-size: 40px;
}
.first-entry .entry-content {
margin: 14px 0;
font-size: 16px;
-webkit-line-clamp: 3;
}
.first-entry .entry-footer {
font-size: 14px;
}
.home-info .entry-content {
--content-gap: 0.5rem;
-webkit-line-clamp: unset;
margin: 0;
}
.home-info .social-icons a:first-of-type {
padding-inline-start: 0;
}
.post-entry {
position: relative;
margin-bottom: var(--gap);
padding: var(--gap);
background: var(--entry);
border-radius: var(--radius);
transition: transform 0.25s ease;
border: 1px solid var(--border);
}
.post-entry:hover,
.post-entry:focus-within {
transform: translateY(-2px);
border-color: var(--tertiary);
}
.tag-entry .entry-cover {
display: none;
}
.entry-header h2 {
font-size: 24px;
line-height: 1.3;
}
.entry-content {
margin: 8px 0;
color: var(--secondary);
font-size: 14px;
line-height: 1.6;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.home-info .entry-content p {
margin-block-start: 1em;
margin-block-end: 1em;
}
.entry-footer {
color: var(--secondary);
font-size: 13px;
}
.entry-link {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
border-radius: var(--radius);
}
.entry-hint {
color: var(--secondary);
}
.entry-hint-parent {
display: flex;
justify-content: space-between;
}
.entry-cover {
font-size: 14px;
margin-bottom: var(--gap);
text-align: center;
display: flex;
flex-direction: column;
gap: .5rem;
}
.entry-cover img {
border-radius: var(--radius);
width: 100%;
height: auto;
}
.entry-cover a {
text-underline-offset: 0.3rem;
text-decoration: underline;
}
@@ -0,0 +1,215 @@
.page-header,
.post-header {
margin: 24px auto var(--content-gap) auto;
}
.post-title {
font-size: 40px;
}
.post-description {
margin-top: 10px;
}
.post-meta {
margin-top: 5px;
}
.post-meta,
.breadcrumbs {
color: var(--secondary);
font-size: 14px;
}
.breadcrumbs {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.2rem;
}
.breadcrumbs a {
font-size: 16px;
}
.breadcrumbs svg {
height: 1em;
}
.i18n_list {
display: inline-flex;
}
.post-meta .i18n_list li {
list-style: none;
margin: auto 3px;
}
.post-meta a,
.toc a:hover {
text-underline-offset: 0.3rem;
text-decoration: underline;
}
.post-meta a {
color: var(--secondary);
text-decoration-style: dotted;
}
details.toc {
margin-bottom: var(--content-gap);
background: var(--code-bg);
border-radius: var(--radius);
border: 1px solid var(--border);
}
[data-theme="dark"] details.toc {
background: var(--entry);
}
details.toc summary {
padding: 0.3rem 1.2rem;
border-radius: var(--radius);
}
details summary {
cursor: pointer;
display: list-item;
width: 100%;
margin-inline-start: 0;
user-select: none;
}
details .title {
display: inline;
font-weight: 500;
margin-inline-start: 0.2rem;
}
details {
interpolate-size: allow-keywords;
}
details::details-content {
height: 0;
opacity: 0;
overflow: clip;
transition: height 150ms ease,
opacity 150ms ease,
content-visibility 150ms allow-discrete;
}
details[open]::details-content {
height: auto;
opacity: 1;
}
details .inner {
margin: 0 2.4rem;
padding-bottom: 0.6rem;
}
details li ul {
margin-inline-start: var(--gap);
}
.post-content {
color: var(--content);
margin: 30px 0;
}
.post-footer {
margin-top: var(--content-gap);
}
.post-footer>* {
margin-bottom: 10px;
}
.post-tags {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.post-tags li {
display: inline-block;
}
.post-tags a,
.share-buttons,
.paginav {
border-radius: var(--radius);
background: var(--code-bg);
border: 1px solid var(--border);
}
.post-tags a {
display: block;
padding: 0 14px;
color: var(--secondary);
font-size: 14px;
line-height: 34px;
background: var(--code-bg);
}
.post-tags a:hover,
.paginav a:hover {
background: var(--border);
}
.share-buttons {
padding: 10px;
display: flex;
justify-content: center;
overflow-x: auto;
gap: 10px;
}
.share-buttons li,
.share-buttons a {
display: inline-flex;
}
.share-buttons a:not(:last-of-type) {
margin-inline-end: 12px;
}
.paginav {
display: flex;
line-height: 1.2;
}
.paginav .title {
letter-spacing: 1px;
text-transform: uppercase;
font-size: 0.8rem;
color: var(--secondary);
}
.paginav a {
width: 50%;
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 0.8rem;
border-radius: var(--radius);
}
.paginav span:hover:not(.title) {
text-underline-offset: 0.2rem;
text-decoration: underline;
}
.paginav .next {
margin-inline-start: auto;
text-align: right;
}
[dir="rtl"] .paginav .next {
text-align: left;
}
h1>a>svg {
display: inline;
}
@@ -0,0 +1,34 @@
.buttons,
.main .profile {
display: flex;
justify-content: center;
}
.main .profile {
align-items: center;
min-height: calc(100vh - var(--header-height) - var(--footer-height) - (var(--gap) * 2));
text-align: center;
}
.profile .profile_inner {
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
}
.profile img {
border-radius: 50%;
}
.buttons {
flex-wrap: wrap;
max-width: 400px;
gap: 1rem;
}
.button {
background: var(--tertiary);
border-radius: var(--radius);
padding: 0.4rem 0.8rem;
}
@@ -0,0 +1,41 @@
.searchbox input {
padding: 4px 10px;
width: 100%;
color: var(--primary);
font-weight: bold;
border: 2px solid var(--tertiary);
border-radius: var(--radius);
}
.searchResults li {
list-style: none;
border-radius: var(--radius);
padding: 10px 15px;
position: relative;
font-weight: 500;
display: flex;
align-items: center;
justify-content: space-between;
background: var(--entry);
transition: transform .25s ease;
border: 1px solid var(--border);
}
.searchResults {
margin: var(--content-gap) 0;
width: 100%;
display: flex;
flex-direction: column;
gap: 10px;
}
.searchResults li:hover,
.searchResults li:focus-within {
transform: translateY(-2px);
border-color: var(--tertiary);
}
.searchResults li .entry-link:focus {
outline: 2px solid var(--secondary);
outline-offset: -2px;
}
@@ -0,0 +1,19 @@
.terms-tags {
display: flex;
flex-wrap: wrap;
gap: 1em;
margin-top: var(--content-gap);
}
.terms-tags li {
display: inline-block;
font-weight: 500;
}
.terms-tags a {
display: block;
padding: 4px 10px;
background: var(--tertiary);
border-radius: var(--radius);
transition: transform 0.1s;
}
@@ -0,0 +1,6 @@
/*
PaperMod v8+
License: MIT https://github.com/adityatelange/hugo-PaperMod/blob/master/LICENSE
Copyright (c) 2020 nanxiaobei and adityatelange
Copyright (c) 2021-2026 adityatelange
*/
+118
View File
@@ -0,0 +1,118 @@
*,
::after,
::before {
box-sizing: border-box;
}
html {
-webkit-tap-highlight-color: transparent;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
}
a,
button,
body,
h1,
h2,
h3,
h4,
h5,
h6 {
color: var(--primary);
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 18px;
line-height: 1.6;
word-break: break-word;
background: var(--theme);
}
article,
aside,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
table {
display: block;
}
h1,
h2,
h3,
h4,
h5,
h6 {
line-height: 1.2;
}
h1,
h2,
h3,
h4,
h5,
h6,
p {
margin-top: 0;
margin-bottom: 0;
}
ul {
padding: 0;
}
a {
text-decoration: none;
}
body,
figure,
ul {
margin: 0;
}
table {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
overflow-x: auto;
word-break: keep-all;
}
button,
input,
textarea {
padding: 0;
font: inherit;
background: 0 0;
border: 0;
}
input,
textarea {
outline: 0;
}
button,
input[type=button],
input[type=submit] {
cursor: pointer;
}
input:-webkit-autofill,
textarea:-webkit-autofill {
box-shadow: 0 0 0 50px var(--theme) inset;
}
img {
display: block;
max-width: 100%;
}
@@ -0,0 +1,40 @@
:root {
--gap: 24px;
--content-gap: 20px;
--nav-width: 1024px;
--main-width: 720px;
--header-height: 60px;
--footer-height: 60px;
--radius: 8px;
--theme: rgb(255, 255, 255);
--entry: rgb(255, 255, 255);
--primary: rgb(30, 30, 30);
--secondary: rgb(108, 108, 108);
--tertiary: rgb(214, 214, 214);
--content: rgb(31, 31, 31);
--code-block-bg: rgb(28, 29, 33);
--code-bg: rgb(245, 245, 245);
--border: rgb(238, 238, 238);
color-scheme: light;
}
:root[data-theme="dark"] {
--theme: rgb(29, 30, 32);
--entry: rgb(46, 46, 51);
--primary: rgb(218, 218, 219);
--secondary: rgb(155, 156, 157);
--tertiary: rgb(65, 66, 68);
--content: rgb(196, 196, 197);
--code-block-bg: rgb(46, 46, 51);
--code-bg: rgb(55, 56, 62);
--border: rgb(51, 51, 51);
color-scheme: dark;
}
.list {
background: var(--code-bg);
}
[data-theme="dark"] .list {
background: var(--theme);
}
@@ -0,0 +1,55 @@
@media screen and (max-width: 768px) {
/* theme-vars */
:root {
--gap: 14px;
}
/* profile-mode */
.profile img {
transform: scale(0.85);
}
/* post-entry */
.first-entry {
min-height: 260px;
}
/* archive */
.archive-month {
flex-direction: column;
}
.archive-year {
margin-top: 20px;
}
/* footer */
.footer {
padding: calc((var(--footer-height) - var(--gap) - 10px) / 2) var(--gap);
}
}
/* footer */
@media screen and (max-width: 900px) {
.list .top-link {
transform: translateY(-5rem);
}
}
@media screen and (max-width: 340px) {
.share-buttons {
justify-content: unset;
}
}
@media (prefers-reduced-motion) {
/* terms; profile-mode; post-single; post-entry; post-entry; search; search */
.terms-tags a:active,
.button:active,
.post-entry:active,
.top-link,
.searchResults .focus,
.searchResults li:active {
transform: none;
}
}
@@ -0,0 +1,5 @@
/*
This is just a placeholder blank stylesheet so as to support adding custom styles budled with theme's default styles
Read https://github.com/adityatelange/hugo-PaperMod/wiki/FAQs#bundling-custom-css-with-themes-assets for more info
*/
@@ -0,0 +1,24 @@
.chroma {
background-color: unset !important;
}
.chroma .hl {
display: flex;
}
.chroma .lnt {
padding: 0 0 0 12px;
}
.highlight pre.chroma code {
padding: 8px 0;
}
.highlight pre.chroma .line .cl,
.chroma .ln {
padding: 0 10px;
}
.chroma .lntd:last-of-type {
width: 100%;
}
@@ -0,0 +1,86 @@
/* Background */ .bg { color: #cad3f5; background-color: #24273a; }
/* PreWrapper */ .chroma { color: #cad3f5; background-color: #24273a; }
/* Other */ .chroma .x { }
/* Error */ .chroma .err { color: #ed8796 }
/* CodeLine */ .chroma .cl { }
/* LineLink */ .chroma .lnlinks { outline: none; text-decoration: none; color: inherit }
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
/* LineHighlight */ .chroma .hl { background-color: #474733 }
/* LineNumbersTable */ .chroma .lnt { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #8087a2 }
/* LineNumbers */ .chroma .ln { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #8087a2 }
/* Line */ .chroma .line { display: flex; }
/* Keyword */ .chroma .k { color: #c6a0f6 }
/* KeywordConstant */ .chroma .kc { color: #f5a97f }
/* KeywordDeclaration */ .chroma .kd { color: #ed8796 }
/* KeywordNamespace */ .chroma .kn { color: #8bd5ca }
/* KeywordPseudo */ .chroma .kp { color: #c6a0f6 }
/* KeywordReserved */ .chroma .kr { color: #c6a0f6 }
/* KeywordType */ .chroma .kt { color: #ed8796 }
/* Name */ .chroma .n { }
/* NameAttribute */ .chroma .na { color: #8aadf4 }
/* NameBuiltin */ .chroma .nb { color: #91d7e3 }
/* NameBuiltinPseudo */ .chroma .bp { color: #91d7e3 }
/* NameClass */ .chroma .nc { color: #eed49f }
/* NameConstant */ .chroma .no { color: #eed49f }
/* NameDecorator */ .chroma .nd { color: #8aadf4; font-weight: bold }
/* NameEntity */ .chroma .ni { color: #8bd5ca }
/* NameException */ .chroma .ne { color: #f5a97f }
/* NameFunction */ .chroma .nf { color: #8aadf4 }
/* NameFunctionMagic */ .chroma .fm { color: #8aadf4 }
/* NameLabel */ .chroma .nl { color: #91d7e3 }
/* NameNamespace */ .chroma .nn { color: #f5a97f }
/* NameOther */ .chroma .nx { }
/* NameProperty */ .chroma .py { color: #f5a97f }
/* NameTag */ .chroma .nt { color: #c6a0f6 }
/* NameVariable */ .chroma .nv { color: #f4dbd6 }
/* NameVariableClass */ .chroma .vc { color: #f4dbd6 }
/* NameVariableGlobal */ .chroma .vg { color: #f4dbd6 }
/* NameVariableInstance */ .chroma .vi { color: #f4dbd6 }
/* NameVariableMagic */ .chroma .vm { color: #f4dbd6 }
/* Literal */ .chroma .l { }
/* LiteralDate */ .chroma .ld { }
/* LiteralString */ .chroma .s { color: #a6da95 }
/* LiteralStringAffix */ .chroma .sa { color: #ed8796 }
/* LiteralStringBacktick */ .chroma .sb { color: #a6da95 }
/* LiteralStringChar */ .chroma .sc { color: #a6da95 }
/* LiteralStringDelimiter */ .chroma .dl { color: #8aadf4 }
/* LiteralStringDoc */ .chroma .sd { color: #6e738d }
/* LiteralStringDouble */ .chroma .s2 { color: #a6da95 }
/* LiteralStringEscape */ .chroma .se { color: #8aadf4 }
/* LiteralStringHeredoc */ .chroma .sh { color: #6e738d }
/* LiteralStringInterpol */ .chroma .si { color: #a6da95 }
/* LiteralStringOther */ .chroma .sx { color: #a6da95 }
/* LiteralStringRegex */ .chroma .sr { color: #8bd5ca }
/* LiteralStringSingle */ .chroma .s1 { color: #a6da95 }
/* LiteralStringSymbol */ .chroma .ss { color: #a6da95 }
/* LiteralNumber */ .chroma .m { color: #f5a97f }
/* LiteralNumberBin */ .chroma .mb { color: #f5a97f }
/* LiteralNumberFloat */ .chroma .mf { color: #f5a97f }
/* LiteralNumberHex */ .chroma .mh { color: #f5a97f }
/* LiteralNumberInteger */ .chroma .mi { color: #f5a97f }
/* LiteralNumberIntegerLong */ .chroma .il { color: #f5a97f }
/* LiteralNumberOct */ .chroma .mo { color: #f5a97f }
/* Operator */ .chroma .o { color: #91d7e3; font-weight: bold }
/* OperatorWord */ .chroma .ow { color: #91d7e3; font-weight: bold }
/* Punctuation */ .chroma .p { }
/* Comment */ .chroma .c { color: #6e738d; font-style: italic }
/* CommentHashbang */ .chroma .ch { color: #6e738d; font-style: italic }
/* CommentMultiline */ .chroma .cm { color: #6e738d; font-style: italic }
/* CommentSingle */ .chroma .c1 { color: #6e738d; font-style: italic }
/* CommentSpecial */ .chroma .cs { color: #6e738d; font-style: italic }
/* CommentPreproc */ .chroma .cp { color: #6e738d; font-style: italic }
/* CommentPreprocFile */ .chroma .cpf { color: #6e738d; font-weight: bold; font-style: italic }
/* Generic */ .chroma .g { }
/* GenericDeleted */ .chroma .gd { color: #ed8796; background-color: #363a4f }
/* GenericEmph */ .chroma .ge { font-style: italic }
/* GenericError */ .chroma .gr { color: #ed8796 }
/* GenericHeading */ .chroma .gh { color: #f5a97f; font-weight: bold }
/* GenericInserted */ .chroma .gi { color: #a6da95; background-color: #363a4f }
/* GenericOutput */ .chroma .go { }
/* GenericPrompt */ .chroma .gp { }
/* GenericStrong */ .chroma .gs { font-weight: bold }
/* GenericSubheading */ .chroma .gu { color: #f5a97f; font-weight: bold }
/* GenericTraceback */ .chroma .gt { color: #ed8796 }
/* GenericUnderline */ .chroma .gl { text-decoration: underline }
/* TextWhitespace */ .chroma .w { }
+194
View File
@@ -0,0 +1,194 @@
import * as params from '@params';
const resList = document.getElementById('searchResults');
const sInput = document.getElementById('searchInput');
const searchBox = document.getElementById('searchbox');
let fuse;
let currentElement = null;
let firstResult = null;
let lastResult = null;
const defaultFuseOptions = {
distance: 100,
threshold: 0.4,
ignoreLocation: true,
keys: ['title', 'permalink', 'summary', 'content']
};
const buildFuseOptions = () => {
if (!params.fuseOpts) {
return defaultFuseOptions;
}
return {
isCaseSensitive: params.fuseOpts.iscasesensitive ?? false,
includeScore: params.fuseOpts.includescore ?? false,
includeMatches: params.fuseOpts.includematches ?? false,
minMatchCharLength: params.fuseOpts.minmatchcharlength ?? 1,
shouldSort: params.fuseOpts.shouldsort ?? true,
findAllMatches: params.fuseOpts.findallmatches ?? false,
keys: params.fuseOpts.keys ?? defaultFuseOptions.keys,
location: params.fuseOpts.location ?? 0,
threshold: params.fuseOpts.threshold ?? defaultFuseOptions.threshold,
distance: params.fuseOpts.distance ?? defaultFuseOptions.distance,
ignoreLocation: params.fuseOpts.ignorelocation ?? defaultFuseOptions.ignoreLocation
};
};
const debounce = (fn, delay) => {
let timeout;
return (...args) => {
clearTimeout(timeout);
timeout = window.setTimeout(() => fn(...args), delay);
};
};
const reset = () => {
currentElement = null;
firstResult = null;
lastResult = null;
resList.innerHTML = '';
sInput.value = '';
sInput.focus();
};
const setActiveResult = (element) => {
document.querySelectorAll('.focus').forEach((item) => item.classList.remove('focus'));
if (!element) {
return;
}
element.focus();
element.parentElement?.classList.add('focus');
currentElement = element;
};
const renderResults = (results) => {
if (!Array.isArray(results) || results.length === 0) {
resList.innerHTML = '';
firstResult = lastResult = currentElement = null;
return;
}
const fragment = document.createDocumentFragment();
for (const result of results) {
const li = document.createElement('li');
const titleText = document.createTextNode(result.item.title);
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.setAttribute('width', '24');
svg.setAttribute('height', '24');
svg.setAttribute('viewBox', '0 0 24 24');
svg.setAttribute('fill', 'none');
svg.setAttribute('stroke', 'currentColor');
svg.setAttribute('stroke-width', '2');
svg.setAttribute('stroke-linecap', 'round');
svg.setAttribute('stroke-linejoin', 'round');
svg.classList.add('feather', 'feather-chevrons-right');
svg.innerHTML = '<polyline points="13 17 18 12 13 7"></polyline><polyline points="6 17 11 12 6 7"></polyline>';
const link = document.createElement('a');
link.className = 'entry-link';
link.href = result.item.permalink;
link.setAttribute('aria-label', result.item.title);
li.appendChild(titleText);
li.appendChild(svg);
li.appendChild(link);
fragment.appendChild(li);
}
resList.innerHTML = '';
resList.appendChild(fragment);
firstResult = resList.firstElementChild;
lastResult = resList.lastElementChild;
};
const performSearch = () => {
if (!fuse) {
return;
}
const query = sInput.value.trim();
if (!query) {
renderResults([]);
return;
}
const searchOptions = params.fuseOpts?.limit ? { limit: params.fuseOpts.limit } : undefined;
const results = searchOptions ? fuse.search(query, searchOptions) : fuse.search(query);
renderResults(results);
};
const initSearch = async () => {
if (!sInput || !resList) {
return;
}
sInput.disabled = false;
sInput.focus();
try {
const response = await fetch('../index.json');
if (!response.ok) {
throw new Error(`Search index load failed: ${response.status}`);
}
const data = await response.json();
if (data) {
fuse = new Fuse(data, buildFuseOptions());
}
} catch (error) {
console.error(error);
}
};
window.addEventListener('load', initSearch);
sInput?.addEventListener('input', debounce(performSearch, 150));
sInput?.addEventListener('search', () => {
if (!sInput.value) {
reset();
}
});
document.addEventListener('keydown', (event) => {
const { key } = event;
const active = document.activeElement;
const isInSearchBox = searchBox?.contains(active);
if (key === 'Escape') {
reset();
return;
}
if (!firstResult || !isInSearchBox) {
return;
}
if (key === 'ArrowDown') {
event.preventDefault();
if (active === sInput) {
setActiveResult(firstResult.querySelector('.entry-link'));
} else if (active?.parentElement !== lastResult) {
setActiveResult(active?.parentElement?.nextElementSibling?.querySelector('.entry-link'));
}
} else if (key === 'ArrowUp') {
event.preventDefault();
if (active?.parentElement === firstResult) {
setActiveResult(sInput);
} else if (active !== sInput) {
setActiveResult(active?.parentElement?.previousElementSibling?.querySelector('.entry-link'));
}
} else if (key === 'ArrowRight') {
if (active?.matches?.('.entry-link')) {
active.click();
}
}
});
+9
View File
@@ -0,0 +1,9 @@
/**
* Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
*
* Copyright (c) 2023 Kiro Risk (http://kiro.me)
* All Rights Reserved. Apache Software License 2.0
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
var e,t;e=this,t=function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,h(r.key),r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function h(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function u(e){return Array.isArray?Array.isArray(e):"[object Array]"===m(e)}var l=1/0;function d(e){return null==e?"":function(e){if("string"==typeof e)return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}(e)}function f(e){return"string"==typeof e}function v(e){return"number"==typeof e}function g(e){return!0===e||!1===e||function(e){return function(e){return"object"===n(e)}(e)&&null!==e}(e)&&"[object Boolean]"==m(e)}function y(e){return null!=e}function p(e){return!e.trim().length}function m(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var b=function(e){return"Missing ".concat(e," property in key")},k=function(e){return"Property 'weight' in key '".concat(e,"' must be a positive integer")},M=Object.prototype.hasOwnProperty,w=function(){function e(t){var n=this;r(this,e),this._keys=[],this._keyMap={};var i=0;t.forEach((function(e){var t=x(e);n._keys.push(t),n._keyMap[t.id]=t,i+=t.weight})),this._keys.forEach((function(e){e.weight/=i}))}return o(e,[{key:"get",value:function(e){return this._keyMap[e]}},{key:"keys",value:function(){return this._keys}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function x(e){var t=null,n=null,r=null,i=1,o=null;if(f(e)||u(e))r=e,t=L(e),n=S(e);else{if(!M.call(e,"name"))throw new Error(b("name"));var a=e.name;if(r=a,M.call(e,"weight")&&(i=e.weight)<=0)throw new Error(k(a));t=L(a),n=S(a),o=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:o}}function L(e){return u(e)?e:e.split(".")}function S(e){return u(e)?e.join("."):e}var _={useExtendedSearch:!1,getFn:function(e,t){var n=[],r=!1;return function e(t,i,o){if(y(t))if(i[o]){var a=t[i[o]];if(!y(a))return;if(o===i.length-1&&(f(a)||v(a)||g(a)))n.push(d(a));else if(u(a)){r=!0;for(var c=0,s=a.length;c<s;c+=1)e(a[c],i,o+1)}else i.length&&e(a,i,o+1)}else n.push(t)}(e,f(t)?t.split("."):t,0),r?n:n[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},O=t(t(t(t({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(e,t){return e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1}}),{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1}),{location:0,threshold:.6,distance:100}),_),j=/[^ ]+/g,A=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.getFn,i=void 0===n?O.getFn:n,o=t.fieldNormWeight,a=void 0===o?O.fieldNormWeight:o;r(this,e),this.norm=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=new Map,r=Math.pow(10,t);return{get:Line truncated
+6
View File
@@ -0,0 +1,6 @@
/*
PaperMod v8+
License: MIT https://github.com/adityatelange/hugo-PaperMod/blob/master/LICENSE
Copyright (c) 2020 nanxiaobei and adityatelange
Copyright (c) 2021-2026 adityatelange
*/