From 44002abf8bc4538755dc51e11ece455d34bb62d2 Mon Sep 17 00:00:00 2001 From: Ethan Yoo Date: Sun, 14 Apr 2024 14:06:16 -0400 Subject: [PATCH] Update repository to reflect changes to the website --- layouts/_default/index.json | 15 + layouts/_default/permalink.html | 4 + layouts/partials/search.html | 11 + static/css/search.css | 107 ++ static/css/style.css | 6 +- static/js/fixedsearch.js | 238 ++++ static/js/fuse.js | 2240 +++++++++++++++++++++++++++++++ theme.toml | 4 +- 8 files changed, 2621 insertions(+), 4 deletions(-) create mode 100644 layouts/_default/index.json create mode 100644 layouts/partials/search.html create mode 100644 static/css/search.css create mode 100644 static/js/fixedsearch.js create mode 100644 static/js/fuse.js diff --git a/layouts/_default/index.json b/layouts/_default/index.json new file mode 100644 index 0000000..7a62ac0 --- /dev/null +++ b/layouts/_default/index.json @@ -0,0 +1,15 @@ +{{/* layouts/_default/index.json */}} +{{- $index := slice -}} +{{- range where .Site.RegularPages.ByDate.Reverse "Type" "not in" (slice "page" "json") -}} + {{ if .Params.dateCreated }} + {{ $.Scratch.Set "date" (.Params.dateCreated) }} + {{ else }} + {{- if isset site.Params "date_format" -}} + {{- $.Scratch.Set "date" (.Date.Format site.Params.date_format) -}} + {{- else -}} + {{- $.Scratch.Set "date" (.Date.Format "2006-01-02") -}} + {{- end -}} + {{ end }} + {{- $index = $index | append (dict "title" ( .Title | plainify ) "permalink" .Permalink "tags" .Params.tags "description" (.Params.description | markdownify | htmlUnescape | plainify) "date" ($.Scratch.Get "date") ) -}} +{{- end -}} +{{- $index | jsonify -}} \ No newline at end of file diff --git a/layouts/_default/permalink.html b/layouts/_default/permalink.html index 7154f68..ce242de 100644 --- a/layouts/_default/permalink.html +++ b/layouts/_default/permalink.html @@ -3,6 +3,10 @@

{{ .Title }}

+ {{ if .Params.toc }} +

Contents

+ + {{ end }} {{ .Content }}
diff --git a/layouts/partials/search.html b/layouts/partials/search.html new file mode 100644 index 0000000..8e59ef5 --- /dev/null +++ b/layouts/partials/search.html @@ -0,0 +1,11 @@ + +
+ + +
+ + + \ No newline at end of file diff --git a/static/css/search.css b/static/css/search.css new file mode 100644 index 0000000..3f763d3 --- /dev/null +++ b/static/css/search.css @@ -0,0 +1,107 @@ +#search-form { + display: block; + position: fixed; + top: 5px; + right: 5px; + margin: 5px; + padding: 20px; + min-width: var(--icon-size, 1.5rem); + max-width: 15rem; + max-height: 100vh; + z-index: 1000; +} +#search-form.search--display, +#search-form[data-focus='false'] .search--display { + display: none; +} +#search-form[data-focus='true'] .search--display { + display: block; +} +#search-form .search-bar { + display: flex; + height: 1.4rem; + align-items: center; +} +#search-form .search-bar { + color: rgb(var(--text-color, '3,3,3')); +} +#search-form[data-focus='true'] .search-bar { + border: 2.5px solid rgb(var(--accent-color, '0,0,255')); +} +#search-form[data-focus='true'] .search-bar:not(:focus-within) { + color: rgb(var(--page-color, '240,240,240')); + border-color: rgb(var(--text-color, '3,3,3')); +} +#search-input { + display: block; + padding: 0.3rem; + width: 15rem; + max-width: 100vw; + height: 100%; + background: inherit; + border: none; + color: inherit; + outline: none; + text-align: left; + /* font-size: var(--s-2, 0.8rem); */ +} +#search-submit:hover, +#search-submit:focus { + color: rgb(var(--accent-color, '0,0,255')); +} +#search-results { + display: block; + flex-grow: 2; + margin: 0.5px 0 0 0; + padding: 0; + max-height: calc(100vh - 1.4rem - 0.5px); + width: 100%; + overflow-x: hidden; + overflow-y: auto; + backdrop-filter: blur(var(--page-color-blur, 2px)); + border: 2.5px solid; + color: rgb(var(--text-color, '3,3,3')); + font-size: var(--s-2, 0.8rem); + scrollbar-color: rgb(var(--text-color, '3,3,3')) rgb(var(--page-color, '240,240,240')) !important; + scrollbar-width: thin !important; +} +#search-results:empty { + display: none; + opacity: 0; +} +#search-results li { + margin: 0; + width: 100%; + border-top: 0.5px dashed; + list-style: none; +} + #search-results li:first-child { + border: none; + } +#search-results a { + display: block; + padding: 0.3rem; + display: block; + text-decoration: none; +} +#search-results a:hover, +#search-results a:focus { + color: rgb(var(--page-color, '240,240,240')); + outline: 0; +} +#search-results a:active { + color: rgb(var(--page-color, '240,240,240')); +} +#search-results li span:empty { + display: none; +} +#search-results li span:not(:last-child)::after { + content: ' – '; +} +#search-results li .title { + display: block; + margin-bottom: calc(var(--line-height, 1.4em)/3); +} +#search-results li .title::after { + display: none; +} \ No newline at end of file diff --git a/static/css/style.css b/static/css/style.css index e30d3c3..b4317ee 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -8,14 +8,16 @@ h1{font-size:2.1em;}h2{font-size:1.8em;}h3{font-size:1.5em;} article, main {padding:4px 2px;} blockquote{padding:0.5em 1.5em;background:#EEE;color:#000;border-radius:4px;} code{background:#000;font:1em/1.5 monospace, monospace;padding:2px} +img[src$='#center']{display:block;margin-left:auto;margin-right:auto;} /* Light theme */ @media(prefers-color-scheme:light){body{background:#333;color:#FFF;}main a:link{color:#bdf;}main a:visited{color:#ccf;}} /* Classes */ -a.link-000{background:#000;border:none;} .center{display:block;margin-left:auto;margin-right:auto;text-align:center;} -img[src$='#center']{display:block;margin-left:auto;margin-right:auto;} +.nextcloud{width:50px;height:30px;position:relative;top:8px;background-size:contain;display:inline-block;background-repeat:no-repeat;background-position:center center;} .post-title{line-height:1.8;} .subtitle{float:right;} +a.link-000{background:#000;border:none;} +a.link-001{padding:10px;background-color:#0082c9;color:#ffffff;border-radius:3px;padding-left:4px;} html{overflow-y:scroll;visibility:visible;opacity:1;} diff --git a/static/js/fixedsearch.js b/static/js/fixedsearch.js new file mode 100644 index 0000000..3e8a7d3 --- /dev/null +++ b/static/js/fixedsearch.js @@ -0,0 +1,238 @@ +// js/fixedsearch.js +/*-------------------------------------------------------------- +fixedsearch — Super fast, client side search for Hugo.io with Fusejs.io +based on https://gist.github.com/cmod/5410eae147e4318164258742dd053993 +--------------------------------------------------------------*/ + +if (typeof variable !== 'undefined') { + console.log('fixedsearch.js already loaded'); +} else { +fixedsearch = function(){ + var search_form = document.getElementById('search-form'); // search form + var search_input = document.getElementById('search-input'); // input box for search + var search_submit = document.getElementById('search-submit'); // form submit button + var search_results = document.getElementById('search-results'); // targets the