generate latest site

This commit is contained in:
KemoNine 2022-12-03 13:19:00 -05:00
parent 7bc6e6e656
commit f09ec3af6f
29 changed files with 406 additions and 43 deletions

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

1
public/index.json Normal file
View file

@ -0,0 +1 @@
[{"categories":null,"contents":"Notes spices are a must break pasta in half or quarters prior to cooking to make the mixing of everything at the end easier ","permalink":"https://culinary.kemonine.info/recipes/lemon-chicken-fettuccine/","tags":["Pasta","Fettuccine","Chicken","Lemon"],"title":"Lemon Chicken 'Fettuccine'"},{"categories":null,"contents":" Pepper Scoville Units Bananna 0 - 500 SHU Poblano 1000 - 1500 SHU Anaheim 500 - 2500 SHU Jalapeno 3500 - 8000 SHU Fresno 2500 - 10000 SHU Serrano 10000 - 23000 SHU Cayenne 30000 - 50000 SHU Habanero 100000 - 350000 SHU ","permalink":"https://culinary.kemonine.info/notes/scoville-unit-table/","tags":["Information","Heat","Spice"],"title":"Scoville Unit Table"},{"categories":null,"contents":"This page was adapted from https://makewithhugo.com/add-search-to-a-hugo-site/\n","permalink":"https://culinary.kemonine.info/search/","tags":null,"title":"Search"}]

View file

@ -25,5 +25,14 @@
<description> Pepper Scoville Units Bananna 0 - 500 SHU Poblano 1000 - 1500 SHU Anaheim 500 - 2500 SHU Jalapeno 3500 - 8000 SHU Fresno 2500 - 10000 SHU Serrano 10000 - 23000 SHU Cayenne 30000 - 50000 SHU Habanero 100000 - 350000 SHU </description>
</item>
<item>
<title>Search</title>
<link>https://culinary.kemonine.info/search/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://culinary.kemonine.info/search/</guid>
<description>This page was adapted from https://makewithhugo.com/add-search-to-a-hugo-site/</description>
</item>
</channel>
</rss>

9
public/js/fuse.min.js vendored Normal file

File diff suppressed because one or more lines are too long

13
public/js/mark.min.js vendored Normal file

File diff suppressed because one or more lines are too long

134
public/js/search.js Normal file
View file

@ -0,0 +1,134 @@
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
// How many characters to include on either side of match keyword
const summaryInclude=60;
// Options for fuse.js
let fuseOptions = {
shouldSort: true,
includeMatches: true,
tokenize: true,
matchAllTokens: true,
threshold: 0.0,
location: 0,
distance: 100,
maxPatternLength: 64,
minMatchCharLength: 3,
keys: [
{name:"title",weight:0.8},
{name:"tags",weight:0.5},
{name:"categories",weight:0.5},
{name:"contents",weight:0.4}
]
};
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
let regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
let results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
let searchQuery = getUrlParameter('q');
if(searchQuery){
document.getElementById("search-query").value = searchQuery;
executeSearch(searchQuery);
} else {
document.getElementById('search-results').innerHTML = "<p class=\"no-results\">Please enter a word or phrase above</p>";
}
function executeSearch(searchQuery) {
// Look for "index.json" in the same directory where this script is called.
fetch("/index.json").
then(function (response) {
return response.json()
}).
then(function (data) {
let fuse = new Fuse(data, fuseOptions);
let result = fuse.search(searchQuery);
if (result.length > 0) {
populateResults(result);
} else {
document.getElementById('search-results').innerHTML = "<p class=\"no-results\">No matches found</p>";
}
});
}
function populateResults(result){
result.forEach( function (value, key) {
let contents= value.item.contents;
let snippet = "";
let snippetHighlights=[];
snippetHighlights.push(searchQuery);
if(snippet.length<1){
var getSentenceByWordRegex = new RegExp(
`[^.?!]*(?<=[.?\\s!])${searchQuery}(?=[\\s.?!])[^.?!]*[.?!]`,
'i'
);
var maxTextLength = summaryInclude*2
// Index of the matched search term
var indexOfMatch = contents.toLowerCase().indexOf(
searchQuery.toLowerCase()
);
// Index of the first word of the sentence with the search term in it
var indexOfSentence = contents.indexOf(
getSentenceByWordRegex.exec(contents)
);
var start
var cutStart = false
// Is the match in the result?
if(indexOfSentence+maxTextLength < indexOfMatch){
// Make sure that the match is in the result
start = indexOfMatch
// This bool is used to replace the first part with '...'
cutStart = true
} else {
// Match is in view, even if we show the whole sentence
start = indexOfSentence
}
// Change end length to the text length if it is longer than
// the text length to prevent problems
var end = start + maxTextLength
if (end > contents.length){
end = contents.length
}
if(cutStart){
// Replace first three characters with '...'
end -= 3;
snippet += "…" + contents.substring(start, end).trim();
}
else{
snippet += contents.substring(start, end).trim();
}
}
snippet += "…";
// Lifted from https://stackoverflow.com/posts/3700369/revisions
var elem = document.createElement('textarea');
elem.innerHTML = snippet;
var decoded = elem.value;
// Pull template from hugo template definition
let frag = document.getElementById('search-result-template').content.cloneNode(true);
// Replace values
frag.querySelector(".search_summary").setAttribute("id", "summary-" + key);
frag.querySelector(".search_link").setAttribute("href", value.item.permalink);
frag.querySelector(".search_title").textContent = value.item.title;
frag.querySelector(".search_snippet").textContent = decoded;
let tags = value.item.tags;
if (tags) {
frag.querySelector(".search_tags").textContent = tags;
} else {
frag.querySelector(".search_iftags").remove();
}
snippetHighlights.forEach( function (snipvalue, snipkey) {
let markjs = new Mark(frag);
markjs.mark(snipvalue);
});
document.getElementById("search-results").appendChild(frag);
});
}
// @license-end

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -7,7 +7,7 @@
<meta name="description" content="a confused culinary notebook">
<meta name="keywords" content="recipes">
<title>KemoNine&#39;s Culinary Notebook</title>
<title>Notes · KemoNine&#39;s Culinary Notebook</title>
<link rel="canonical" href="https://culinary.kemonine.info/notes/">
<link rel="stylesheet" href="https://unpkg.com/normalize.css@8.0.1/normalize.css" integrity="sha384-M86HUGbBFILBBZ9ykMAbT3nVb0+2C7yZlF8X2CiKNpDOQjKroMJqIeGZ/Le8N2Qp" crossorigin="anonymous" />
@ -50,30 +50,27 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">
<section class="container list">
<h1 class="title">Note: Notes</h1>
<h1 class="title">Notes</h1>
<div class="pure-g">
<div class="pure-u-1">
<h3><a href="https://culinary.kemonine.info/notes/heat/">Heat</a></h3>
</div>
<div class="pure-g">
<div class="pure-u-1-3">
January 1, 0001
</div>
<div class="pure-g">
<div class="pure-u-1">
<h3><a href="https://culinary.kemonine.info/notes/information/">Information</a></h3>
</div>
</div>
<div class="pure-g">
<div class="pure-u-1">
<h3><a href="https://culinary.kemonine.info/notes/spice/">Spice</a></h3>
</div>
<div class="pure-u-2-3">
<a href="https://culinary.kemonine.info/notes/scoville-unit-table/">Scoville Unit Table</a>
</div>
</div>
@ -82,7 +79,8 @@
</section>
</section>
</main>
<footer class="footer">

View file

@ -7,30 +7,12 @@
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language><atom:link href="https://culinary.kemonine.info/notes/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Heat</title>
<link>https://culinary.kemonine.info/notes/heat/</link>
<title>Scoville Unit Table</title>
<link>https://culinary.kemonine.info/notes/scoville-unit-table/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://culinary.kemonine.info/notes/heat/</guid>
<description></description>
</item>
<item>
<title>Information</title>
<link>https://culinary.kemonine.info/notes/information/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://culinary.kemonine.info/notes/information/</guid>
<description></description>
</item>
<item>
<title>Spice</title>
<link>https://culinary.kemonine.info/notes/spice/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://culinary.kemonine.info/notes/spice/</guid>
<description></description>
<guid>https://culinary.kemonine.info/notes/scoville-unit-table/</guid>
<description> Pepper Scoville Units Bananna 0 - 500 SHU Poblano 1000 - 1500 SHU Anaheim 500 - 2500 SHU Jalapeno 3500 - 8000 SHU Fresno 2500 - 10000 SHU Serrano 10000 - 23000 SHU Cayenne 30000 - 50000 SHU Habanero 100000 - 350000 SHU </description>
</item>
</channel>

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -52,6 +52,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -52,6 +52,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

94
public/search/index.html Normal file
View file

@ -0,0 +1,94 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="KemoNine">
<meta name="description" content="a confused culinary notebook">
<meta name="keywords" content="recipes">
<title>KemoNine&#39;s Culinary Notebook</title>
<link rel="canonical" href="https://culinary.kemonine.info/search/">
<link rel="stylesheet" href="https://unpkg.com/normalize.css@8.0.1/normalize.css" integrity="sha384-M86HUGbBFILBBZ9ykMAbT3nVb0+2C7yZlF8X2CiKNpDOQjKroMJqIeGZ/Le8N2Qp" crossorigin="anonymous" />
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/grids-responsive-min.css" integrity="sha384-b92sF+wDNTHrfEtRaYo+EpcA8FUyHOSXrdxKc9XB9kaaX1rSQAgMevW6cYeE5Bdv" crossorigin="anonymous">
<link rel="stylesheet" href="https://culinary.kemonine.info/css/gochowdown.min.dd262c68478a4de0b500d7fb0c62e11c7e5d18a8915d6adf7f5609b93b7d14ce.css" integrity="sha256-3SYsaEeKTeC1ANf7DGLhHH5dGKiRXWrff1YJuTt9FM4=" crossorigin="anonymous" media="screen" />
<link rel="stylesheet" href="https://culinary.kemonine.info/style.css">
<script defer data-domain="culinary.kemonine.info" src="https://plausible.kemonine.info/js/plausible.js"></script>
<link rel="icon" type="image/png" href="https://culinary.kemonine.info/images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="https://culinary.kemonine.info/images/favicon-16x16.png" sizes="16x16">
<meta name="generator" content="Hugo 0.107.0">
</head>
<body>
<nav class="navigation pure-g">
<section class="pure-u-1 pure-u-md-1-2 nav-left">
<a href="https://culinary.kemonine.info">
<h1 class="nav-title title-shadow white">KemoNine&#39;s Culinary Notebook</h1>
</a>
</section>
<section class="pure-u-1 pure-u-md-1-2 nav-right">
<a href="https://culinary.kemonine.info/category/">By Category</a>
<a href="https://culinary.kemonine.info/cuisine/">By Cuisine</a>
<a href="https://culinary.kemonine.info/tags/">By Tag</a>
<a href="https://culinary.kemonine.info/notes/">Notes</a>
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">
<div id="search-results"></div>
<template id="search-result-template"><div class="search_summary">
<h2 class="post-title no-text-decoration"><a class="search_link search_title" href=""></a></h2>
<p><em class="search_snippet"></em></p>
<small>
<table>
<tr class="search_iftags"><td><strong>Tags</strong></td><td class="search_tags"></td></tr>
</table>
</small>
</div></template>
<script src="https://culinary.kemonine.info/js/fuse.min.js"></script>
<script src="https://culinary.kemonine.info/js/mark.min.js"></script>
<script src="https://culinary.kemonine.info/js/search.js"></script>
</div>
</main>
<footer class="footer">
© 2022
·
Powered by <a href="https://gohugo.io/">Hugo</a> &amp; <a href="https://github.com/seanlane/gochowdown">GoChowdown</a>
</footer>
</body>
</html>

View file

@ -52,6 +52,9 @@
<loc>https://culinary.kemonine.info/notes/</loc>
</url><url>
<loc>https://culinary.kemonine.info/notes/scoville-unit-table/</loc>
</url><url>
<loc>https://culinary.kemonine.info/search/</loc>
<priority>0.1</priority>
</url><url>
<loc>https://culinary.kemonine.info/tags/spice/</loc>
</url><url>

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">

View file

@ -50,6 +50,12 @@
</section>
<section class="pure-u-1 nav-center">
<form class="form" action="https://culinary.kemonine.info/search" method="GET">
<input class="title" type="search" name="q" id="search-query" placeholder="Search....">
<button class="button" type="submit">Search</button>
</form>
</section>
</nav>
<main class="content">