Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
SingularisArt committed Jul 21, 2024
1 parent e676ec3 commit 57e49a6
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 333 deletions.
81 changes: 31 additions & 50 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1155,14 +1155,26 @@ video {
position: fixed;
}

.absolute {
position: absolute;
}

.relative {
position: relative;
}

.bottom-0 {
bottom: 0px;
}

.left-0 {
left: 0px;
}

.right-0 {
right: 0px;
}

.top-0 {
top: 0px;
}
Expand Down Expand Up @@ -1255,6 +1267,10 @@ video {
margin-right: 0.5rem;
}

.mt-0 {
margin-top: 0px;
}

.mt-1 {
margin-top: 0.25rem;
}
Expand All @@ -1267,10 +1283,6 @@ video {
margin-top: 0.2em;
}

.mt-0 {
margin-top: 0px;
}

.block {
display: block;
}
Expand Down Expand Up @@ -1319,6 +1331,10 @@ video {
height: 2rem;
}

.max-h-96 {
max-height: 24rem;
}

.min-h-0 {
min-height: 0px;
}
Expand All @@ -1327,8 +1343,8 @@ video {
min-height: 100vh;
}

.w-1\/3 {
width: 33.333333%;
.w-3\/4 {
width: 75%;
}

.w-6 {
Expand Down Expand Up @@ -1444,10 +1460,6 @@ video {
gap: 0.25rem;
}

.gap-3 {
gap: 0.75rem;
}

.gap-5 {
gap: 1.25rem;
}
Expand All @@ -1464,6 +1476,10 @@ video {
overflow: hidden;
}

.overflow-y-auto {
overflow-y: auto;
}

.whitespace-nowrap {
white-space: nowrap;
}
Expand Down Expand Up @@ -1622,38 +1638,14 @@ video {
padding-bottom: 2rem;
}

.pt-20 {
padding-top: 5rem;
}

.pt-4 {
padding-top: 1rem;
}

.pt-\[10em\] {
padding-top: 10em;
}

.pt-\[5em\] {
padding-top: 5em;
}

.pt-\[2em\] {
padding-top: 2em;
}

.pt-\[3em\] {
padding-top: 3em;
}

.pt-\[4em\] {
padding-top: 4em;
}

.pt-5 {
padding-top: 1.25rem;
}

.text-center {
text-align: center;
}
Expand Down Expand Up @@ -2361,6 +2353,11 @@ textarea.form-control.is-invalid {
border-color: rgb(55 65 81 / var(--tw-border-opacity));
}

:is(.dark .dark\:border-gray-800) {
--tw-border-opacity: 1;
border-color: rgb(31 41 55 / var(--tw-border-opacity));
}

:is(.dark .dark\:border-neutral-700) {
--tw-border-opacity: 1;
border-color: rgb(64 64 64 / var(--tw-border-opacity));
Expand Down Expand Up @@ -2416,14 +2413,6 @@ textarea.form-control.is-invalid {
display: none;
}

.sm\:w-2\/3 {
width: 66.666667%;
}

.sm\:grid-cols-1 {
grid-template-columns: repeat(1, minmax(0, 1fr));
}

.sm\:px-8 {
padding-left: 2rem;
padding-right: 2rem;
Expand Down Expand Up @@ -2464,10 +2453,6 @@ textarea.form-control.is-invalid {
flex: 1 1 0%;
}

.md\:grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}

.md\:grid-cols-\[13rem_auto\] {
grid-template-columns: 13rem auto;
}
Expand All @@ -2491,10 +2476,6 @@ textarea.form-control.is-invalid {
.lg\:block {
display: block;
}

.lg\:grid-cols-3 {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}

.ltr\:block:where([dir="ltr"], [dir="ltr"] *) {
Expand Down
105 changes: 105 additions & 0 deletions assets/js/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
var index = new FlexSearch.Document({
tokenize: "forward",
cache: 100,
document: {
id: "id",
store: [
"href", "title", "description", "content", "summary", "date", "type", "url"
],
index: [
"title", "description", "content", "summary", "date", "type", "url"
]
}
});

// Load index data asynchronously
let dataStore = [];
fetch("/search/index.json")
.then(response => response.json())
.then(data => {
dataStore = data;
data.forEach(item => {
index.add({
id: item.id,
href: item.href,
title: item.title,
summary: item.summary,
type: item.type,
date: item.date
});
});
})
.catch(error => {
console.error("Error fetching data:", error);
});

const searchIcon = document.querySelector("[data-open-modal]");
const searchOverlay = document.querySelector("[data-modal]");
var inputElement = document.getElementById("search-query");
var resultsElement = document.getElementById("search-results");
console.log(inputElement, resultsElement)

// Toggle search overlay
searchIcon.addEventListener("click", function() {
searchOverlay.showModal();
document.body.classList.add("modal-open");
inputElement.focus();
});

// Close overlay on outside click
searchOverlay.addEventListener("click", function(e) {
if (e.target === searchOverlay) {
searchOverlay.close();
document.body.classList.remove("modal-open");
}
});

// Search input event
inputElement.addEventListener("input", function() {
var query = inputElement.value;
var results = index.search(query);

// Clear previous results
resultsElement.innerHTML = "";

// Flatten and deduplicate the results
var docIds = new Set();
results.forEach(function(result) {
if (result.result) {
result.result.forEach(function(id) {
docIds.add(id);
});
}
});

// Display search results
docIds.forEach(function(docId) {
// Find the document in the original data store
var doc = dataStore.find(item => item.id === docId);
if (doc) {
var li = document.createElement("li");

// Construct result display
li.innerHTML = `
<div class="p-1">
<a class="text-gray-700 bg-neutral-100 dark:text-gray-300 dark:bg-gray-900 dark:hover:bg-sky-600 hover:bg-sky-600 hover:text-gray-300 flex items-center px-3 py-2 rounded-md appearance-none focus:bg-primary-100 dark:focus:bg-primary-900 focus:outline-dotted focus:outline-transparent focus:outline-2" href="/" tabindex="0">
<div class="grow">
<div class="-mb-1 text-lg font-bold">
${doc.title}
</div>
<div class="text-sm text-neutral-500 dark:text-neutral-400 capitalize">
${doc.type}
<span class="px-2 text-primary-500">·</span>
${doc.date}
</div>
</div>
<div class="ml-2 ltr:block rtl:hidden text-neutral-500">→</div>
</a>
</div>
`;

li.querySelector("a").href = doc.url;
resultsElement.appendChild(li);
}
});
});
5 changes: 5 additions & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{ $style := resources.Get "css/style.css" }}

{{ $flexsearch := resources.Get "js/flexsearch.js" }}
{{ $enable_dialog := resources.Get "js/enable-dialog.js" }}
{{ $search := resources.Get "js/search.js" }}
{{ $disqus := resources.Get "js/disqus.js" }}
{{ $header := resources.Get "js/header.js" }}
{{ $latex := resources.Get "js/latex.js" }}
Expand Down Expand Up @@ -39,6 +41,9 @@
<script defer type="text/javascript" src="{{ $header.Permalink }}"></script>
<script defer type="text/javascript" src="{{ $latex.Permalink }}"></script>
<script defer type="text/javascript" src="{{ $theme.Permalink }}"></script>
<script defer type="text/javascript" src="{{ $flexsearch.Permalink }}"></script>
<script defer type="text/javascript" src="{{ $search.Permalink }}"></script>
<script defer type="text/javascript" src="{{ $enable_dialog.Permalink }}"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.js"></script>
<script type="text/javascript">
tocbot.init({
Expand Down
66 changes: 39 additions & 27 deletions layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
{{ define "main" }}

{{- $showTitle := .Params.showTitle -}}
{{ $tutorials := .Site.GetPage "section" "tutorials" }}

<div class="prose-singularisart dark:prose-invert px-4 py-4 md:py-3 md:px-8 max-w-[1000px] mx-auto min-h-[100vh] flex flex-col">
{{ $tutorials := .Site.GetPage "section" "tutorials" }}
{{- if eq $showTitle true -}}
<h1 class="text-center">{{ .Title }}</h1>
{{- end -}}
{{ .Content }}

{{ range $tutorials.Pages }}
{{- if not .Params.series }}
{{- $url := .Page.Permalink }}
{{- with .Params.introFile }}
{{- $url = printf "%s%s" $url . }}
{{- end }}

<div class="mb-[2em]">
<a class="hover:no-underline text-gray-700 dark:text-gray-300" href={{ $url }}>
<div class="text-[80%] font-small-caps lowercase font-[700]">
<span>{{ .Page.Date.Format "January 2 Monday, 2006" }}</span>
{{ if ne .Lastmod .Date }}
<span class="px-2 text-primary-500"></span>
Updated: {{ .Page.Lastmod.Format "January 2 Monday, 2006" }}
{{ end }}
<span class="px-2 text-primary-500"></span>
<span>{{ .Page.WordCount }} word{{ if (ne .Page.WordCount 1) }}s{{ end }}</span>
<span class="px-2 text-primary-500"></span>
<span title="reading-time">{{ .Page.ReadingTime }} minute{{ if (ne .Page.ReadingTime 1) }}s{{ end }}</span>
</div>
<h2 class="mb-[0.2em] mr-0 mt-0 ml-0 font-[600] leading-7">{{ .Title }}</h2>
<p class="m-0">{{ .Summary }}</p>
</a>

<section class="relative">
<h2>Tutorials</h2>

Single articles/multi-part series that I've written explaining any topic
that piques my interest. I write them in a way that I would have liked to
have read them when I was learning the topic. Here are the three most
recent tutorials that I've written.

<br />
<br />

{{ range $tutorials.Pages | first 3 }}
{{ partial "list-tutorial.html" . }}
{{ end }}

{{- if gt (len $tutorials.Pages) 3 -}}
<div class="text-center">
<a class="text-primary-500 hover:text-primary-700" href="{{ $tutorials.RelPermalink }}">View More</a>
</div>
{{- end -}}

{{ partial "line.html" . }}
</section>

<section class="relative">
<h2>Projects</h2>

{{ range $tutorials.Pages | first 3 }}
{{ partial "list-tutorial.html" . }}
{{ end }}
{{ end }}

{{- if gt (len $tutorials.Pages) 3 -}}
<div class="text-center">
<a class="text-primary-500 hover:text-primary-700" href="{{ $tutorials.RelPermalink }}">View More</a>
</div>
{{- end -}}

{{ partial "line.html" . }}
</section>
</div>

{{ end }}
1 change: 1 addition & 0 deletions layouts/partials/line.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="absolute bottom-0 left-0 right-0 mx-auto border-2 border-gray-200 dark:border-gray-800"></div>
Loading

0 comments on commit 57e49a6

Please sign in to comment.