archive rework: search, archive by year

This commit is contained in:
wgroeneveld 2020-06-10 15:51:32 +02:00
parent b3635042a0
commit db76f45272
29 changed files with 515 additions and 85 deletions

61
build-lunr-index.js Normal file
View File

@ -0,0 +1,61 @@
const fs = require('fs').promises;
const { resolve } = require('path');
const {promisify} = require('util');
const frontMatterParser = require('parser-front-matter');
const parse = promisify(frontMatterParser.parse.bind(frontMatterParser));
// https://stackoverflow.com/questions/5827612/node-js-fs-readdir-recursive-directory-search
async function getFiles(dir) {
const dirents = await fs.readdir(dir, { withFileTypes: true });
const files = await Promise.all(dirents.map((dirent) => {
const res = resolve(dir, dirent.name);
return dirent.isDirectory() ? getFiles(res) : res;
}));
return Array.prototype.concat(...files);
}
async function loadPostsWithFrontMatter(postsDirectoryPath) {
const postNames = await getFiles(postsDirectoryPath);
const posts = await Promise.all(
// could be .DS_Store stuff found using recursive function above...
postNames.filter(name => name.endsWith('.md')).map(async fileName => {
const fileContent = await fs.readFile(fileName, 'utf8');
const {content, data} = await parse(fileContent);
return {
content: content.slice(0, 3000),
...data
};
})
);
return posts;
}
const lunrjs = require('lunr');
function makeIndex(posts) {
return lunrjs(function() {
this.ref('title');
this.field('title');
this.field('content');
this.field('tags');
posts.forEach(p => {
this.add(p);
});
});
}
async function run() {
const posts = await loadPostsWithFrontMatter(`${__dirname}/content/post`);
const essays = await loadPostsWithFrontMatter(`${__dirname}/content/essays`);
const index = makeIndex(posts.concat(essays));
console.log(JSON.stringify(index));
}
run()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});

View File

@ -62,7 +62,7 @@ enableGitInfo = true
weight = 2
[[menu.main]]
name = "Tags"
name = "Archives"
pre = "<svg width='24' height='24'><use xlink:href='#tag'></use></svg> "
url = "/tags"
weight = 3

10
content/post/2013.md Normal file
View File

@ -0,0 +1,10 @@
---
title: "Archive by year: 2013"
category: "archive"
bigimg: Archive.jpg
icontag: tag
url: /post/2013/
disableComments: true
---
{{< archive 2013 >}}

10
content/post/2014.md Normal file
View File

@ -0,0 +1,10 @@
---
title: "Archive by year: 2014"
category: "archive"
bigimg: Archive.jpg
icontag: tag
url: /post/2014/
disableComments: true
---
{{< archive 2014 >}}

10
content/post/2015.md Normal file
View File

@ -0,0 +1,10 @@
---
title: "Archive by year: 2015"
category: "archive"
bigimg: Archive.jpg
icontag: tag
url: /post/2015/
disableComments: true
---
{{< archive 2015 >}}

10
content/post/2016.md Normal file
View File

@ -0,0 +1,10 @@
---
title: "Archive by year: 2016"
category: "archive"
bigimg: Archive.jpg
icontag: tag
url: /post/2016/
disableComments: true
---
{{< archive 2016 >}}

10
content/post/2017.md Normal file
View File

@ -0,0 +1,10 @@
---
title: "Archive by year: 2017"
category: "archive"
bigimg: Archive.jpg
icontag: tag
url: /post/2017/
disableComments: true
---
{{< archive 2017 >}}

10
content/post/2018.md Normal file
View File

@ -0,0 +1,10 @@
---
title: "Archive by year: 2018"
category: "archive"
bigimg: Archive.jpg
icontag: tag
url: /post/2018/
disableComments: true
---
{{< archive 2018 >}}

10
content/post/2019.md Normal file
View File

@ -0,0 +1,10 @@
---
title: "Archive by year: 2019"
category: "archive"
bigimg: Archive.jpg
icontag: tag
url: /post/2019/
disableComments: true
---
{{< archive 2019 >}}

10
content/post/2020.md Normal file
View File

@ -0,0 +1,10 @@
---
title: "Archive by year: 2020"
category: "archive"
bigimg: Archive.jpg
icontag: tag
url: /post/2020/
disableComments: true
---
{{< archive 2020 >}}

View File

@ -7,4 +7,10 @@ icontag: tech
A continuous pursuit of knowledge for either personal or professional reasons is called [Lifelong learning](https://en.wikipedia.org/wiki/Lifelong_learning). As a great deal of my life is dedicated to Computer Science, so it's only natural to do some heavy [_Brain Baking_](/) work in that technical area of expertise. I discovered that in order for me to teach and inspire others, I first had to teach and inspire myself. You are looking at the result of that work.
I wanted to make the profound difference clear between a [<svg class='icon'><use xlink:href='#tech'></use></svg>technical blog](/post) and [<svg class='icon'><use xlink:href='#book'></use></svg>essayistic works](/essays) by separating them in different categories, each with their own intention and language.
I wanted to make the profound difference clear between a [<svg class='icon'><use xlink:href='#tech'></use></svg>technical blog](/post) and [<svg class='icon'><use xlink:href='#book'></use></svg>essayistic works](/essays) by separating them in different categories, each with their own intention and language.
I mainly write about the following topics: {{< popular-categories >}}.
Besides these posts, I also write about retro PC/Handheld gaming and bread baking on sister websites of Brain Baking: [Jefklak's Retro Codex](https://jefklakscodex.com) and [Red Zuurdesem](https://redzuurdesem.be), respectively.
Not finding what you're looking for? [Browse the archives](/tags).

8
content/search.md Normal file
View File

@ -0,0 +1,8 @@
---
title: Search
disableComments: true
---
Not finding what youre looking for? Try your luck here:
{{< searchresults >}}

View File

@ -1,9 +1,33 @@
---
title: Tags
title: Archives
bigimg: Archive.jpg
icontag: tag
---
> The good life is one inspired by love and guided by knowledge. <span>Russell</span>
Not finding what you're looking for? Behold a list of alphabetically sorted tags used in every article on this very website. Related articles share a set of tags.
Not finding what you're looking for? Try browsing the archives:
### By search
<form method="get" action="/search" class="search-form">
<input id="zoekentxt" placeholder="e.g. 'philosophy'" name="q" type="text" style="width: 56%" />
<button type="submit" class="button" style="width: 36%">Search!</button>
</form>
### By year
- [2020](/post/2020) ... when I started paying attention to webdesign again
- [2019](/post/2019) ... when I started taking computing education blogging seriously
- [2018](/post/2018) ... when my PhD work started and I tried writing essays in Dutch
- [2017](/post/2017) ... when self-improvement meta-posts started popping up more often
- [2016](/post/2016) ... when legacy code convinced me to successfully unit test Visual Basic 6
- [2015](/post/2015) ... when I completely forgot about blogging at all
- [2014](/post/2014) ... when I switched from mostly programming in Java to C#
- [2013](/post/2013) ... when this site was a wiki running on pmWiki, and then DokuWiki
### By tag
Behold a list of alphabetically sorted tags used in every article on this very website. Related articles share a set of tags.

View File

@ -0,0 +1,12 @@
{{ $year := index .Params 0 }}
<div class="list">
<h2>{{ $year }}</h2>
{{ range (where (where $.Site.Pages "Section" "post") ".Params.date.Year" "eq" $year).GroupByDate "Jan" }}
<h3>{{ .Key }}</h3>
{{ partial "list-ul" . }}
{{ end }}
</div>

View File

@ -1 +0,0 @@
<a href="dokuwiki.org/wiki:{{ index .Params 0 }}" target="_blank">{{ index .Params 0 }}</a>

View File

@ -0,0 +1,6 @@
<svg class='icon icon-text'><use xlink:href="#tag"></use></svg>
<span class='list-tags'>
{{ range first 10 $.Site.Taxonomies.tags.ByCount }}
<a href="{{ $.Site.BaseURL }}tags/{{ .Name | urlize }}"><kbd class="item-tag">{{ .Name }}</kbd></a>
{{ end }}
</span>

After

Width:  |  Height:  |  Size: 262 B

View File

@ -0,0 +1,28 @@
<article>
<form method="get" action="" class="search-form">
<input id="zoekentxt" placeholder="philosophy" name="q" type="text" style="width: 56%" />
<button type="submit" class="button" style="width: 36%">Search!</button>
</form>
</article>
<div id="resultaten">
<hr/>
<h2>
Search results
<span class="pages"></span> &raquo;
</h2>
<div id="searchapp">Searching, please wait... </div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</div>
<script src="/js/lunr.min.js"></script>
{{ $p := slice }}
{{ range (where .Site.RegularPages "Section" "!=" "") }}
{{ $post := dict "link" .RelPermalink "title" .Title "content" (substr .Plain 0 200) -}}
{{ $p = $p | append $post -}}
{{ end }}
<script>
window.searchposts = JSON.parse(
{{ $p | jsonify }}
);
</script>

167
package-lock.json generated
View File

@ -1047,6 +1047,15 @@
}
}
},
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dev": true,
"requires": {
"sprintf-js": "~1.0.2"
}
},
"arr-diff": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz",
@ -1491,6 +1500,12 @@
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
},
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true
},
"esutils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
@ -1629,6 +1644,16 @@
}
}
},
"file-is-binary": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-is-binary/-/file-is-binary-1.0.0.tgz",
"integrity": "sha1-XkGAbRvK5FjI/sMv484SLbu8Q1Y=",
"dev": true,
"requires": {
"is-binary-buffer": "^1.0.0",
"isobject": "^3.0.0"
}
},
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
@ -1674,8 +1699,7 @@
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
"integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=",
"dev": true,
"optional": true
"dev": true
},
"fragment-cache": {
"version": "0.2.1",
@ -1779,6 +1803,35 @@
"dev": true,
"optional": true
},
"gray-matter": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-3.1.1.tgz",
"integrity": "sha512-nZ1qjLmayEv0/wt3sHig7I0s3/sJO0dkAaKYQ5YAOApUtYEOonXSFdWvL1khvnZMTvov4UufkqlFsilPnejEXA==",
"dev": true,
"requires": {
"extend-shallow": "^2.0.1",
"js-yaml": "^3.10.0",
"kind-of": "^5.0.2",
"strip-bom-string": "^1.0.0"
},
"dependencies": {
"extend-shallow": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"dev": true,
"requires": {
"is-extendable": "^0.1.0"
}
},
"kind-of": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz",
"integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==",
"dev": true
}
}
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
@ -1873,6 +1926,15 @@
}
}
},
"is-binary-buffer": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-binary-buffer/-/is-binary-buffer-1.0.0.tgz",
"integrity": "sha1-vGAxKQtly/eZudlQK1D9U3VSQAc=",
"dev": true,
"requires": {
"is-buffer": "^1.1.5"
}
},
"is-binary-path": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz",
@ -1887,8 +1949,7 @@
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
"dev": true,
"optional": true
"dev": true
},
"is-data-descriptor": {
"version": "0.1.4",
@ -1937,8 +1998,7 @@
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
"integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=",
"dev": true,
"optional": true
"dev": true
},
"is-extglob": {
"version": "2.1.1",
@ -1984,11 +2044,16 @@
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"dev": true,
"optional": true,
"requires": {
"isobject": "^3.0.1"
}
},
"is-whitespace": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/is-whitespace/-/is-whitespace-0.3.0.tgz",
"integrity": "sha1-Fjnssb4DauxppUy7QBz77XEUq38=",
"dev": true
},
"is-windows": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz",
@ -2007,8 +2072,7 @@
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=",
"dev": true,
"optional": true
"dev": true
},
"js-tokens": {
"version": "4.0.0",
@ -2016,6 +2080,16 @@
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
},
"js-yaml": {
"version": "3.14.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz",
"integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"jsesc": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
@ -2038,6 +2112,15 @@
"dev": true,
"optional": true
},
"lazy-cache": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-2.0.2.tgz",
"integrity": "sha1-uRkKT5EzVGlIQIWfio9whNiCImQ=",
"dev": true,
"requires": {
"set-getter": "^0.1.0"
}
},
"leven": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz",
@ -2078,6 +2161,12 @@
"js-tokens": "^3.0.0 || ^4.0.0"
}
},
"lunr": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.8.tgz",
"integrity": "sha512-oxMeX/Y35PNFuZoHp+jUj5OSEmLCaIH4KTFJh7a93cHBoFmpw2IoPs22VIz7vyO2YUnx2Tn9dzIwO2P/4quIRg==",
"dev": true
},
"make-dir": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
@ -2147,7 +2236,6 @@
"resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz",
"integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==",
"dev": true,
"optional": true,
"requires": {
"for-in": "^1.0.2",
"is-extendable": "^1.0.1"
@ -2158,7 +2246,6 @@
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
"integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
"dev": true,
"optional": true,
"requires": {
"is-plain-object": "^2.0.4"
}
@ -2317,6 +2404,32 @@
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
"dev": true
},
"parser-front-matter": {
"version": "1.6.4",
"resolved": "https://registry.npmjs.org/parser-front-matter/-/parser-front-matter-1.6.4.tgz",
"integrity": "sha512-eqtUnI5+COkf1CQOYo8FmykN5Zs+5Yr60f/7GcPgQDZEEjdE/VZ4WMaMo9g37foof8h64t/TH2Uvk2Sq0fDy/g==",
"dev": true,
"requires": {
"extend-shallow": "^2.0.1",
"file-is-binary": "^1.0.0",
"gray-matter": "^3.0.2",
"isobject": "^3.0.1",
"lazy-cache": "^2.0.2",
"mixin-deep": "^1.2.0",
"trim-leading-lines": "^0.1.1"
},
"dependencies": {
"extend-shallow": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"dev": true,
"requires": {
"is-extendable": "^0.1.0"
}
}
}
},
"pascalcase": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz",
@ -2557,6 +2670,15 @@
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true
},
"set-getter": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/set-getter/-/set-getter-0.1.0.tgz",
"integrity": "sha1-12nBgsnVpR9AkUXy+6guXoboA3Y=",
"dev": true,
"requires": {
"to-object-path": "^0.3.0"
}
},
"set-value": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz",
@ -2742,6 +2864,12 @@
"extend-shallow": "^3.0.0"
}
},
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true
},
"static-extend": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz",
@ -2775,6 +2903,12 @@
"safe-buffer": "~5.1.0"
}
},
"strip-bom-string": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz",
"integrity": "sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI=",
"dev": true
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
@ -2795,7 +2929,6 @@
"resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz",
"integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=",
"dev": true,
"optional": true,
"requires": {
"kind-of": "^3.0.2"
},
@ -2805,7 +2938,6 @@
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"dev": true,
"optional": true,
"requires": {
"is-buffer": "^1.1.5"
}
@ -2836,6 +2968,15 @@
"repeat-string": "^1.6.1"
}
},
"trim-leading-lines": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/trim-leading-lines/-/trim-leading-lines-0.1.1.tgz",
"integrity": "sha1-DnysPoMELc+Vp07TaWbxd0TVwWk=",
"dev": true,
"requires": {
"is-whitespace": "^0.3.0"
}
},
"unicode-canonical-property-names-ecmascript": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz",

View File

@ -10,11 +10,13 @@
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6"
"@babel/preset-env": "^7.9.6",
"lunr": "^2.3.6",
"parser-front-matter": "^1.6.4"
},
"scripts": {
"build": "/usr/local/bin/hugo",
"install": "node goodreads-fetch.js > static/js/goodreads.js"
"install": "node goodreads-fetch.js > static/js/goodreads.js && node build-lunr-index.js > static/js/brainbaking-post.json"
},
"repository": {
"type": "git",

File diff suppressed because one or more lines are too long

View File

@ -28,4 +28,43 @@ document.addEventListener("DOMContentLoaded",function() {
const box = new SimpleLightbox('.lbox', { /* options */ });
(function() {
const $target = document.querySelector('#searchapp');
const $pages = document.querySelector('#resultaten .pages');
if(!($target && window.searchposts)) return;
const query = new URLSearchParams(window.location.search);
const searchString = query.get('q') || "";
document.querySelector('#zoekentxt').value = searchString;
// Our index uses title as a reference
const postsByTitle = window.searchposts.reduce((acc, curr) => {
acc[curr.title] = curr;
return acc;
}, {});
fetch('/js/brainbaking-post.json').then(function (res) {
return res.json();
}).then(function (data) {
const index = lunr.Index.load(data);
const matches = index.search(searchString);
const matchPosts = [];
matches.forEach((m) => {
matchPosts.push(postsByTitle[m.ref]);
});
$pages.innerHTML = `(${matches.length})`;
if (matchPosts.length > 0) {
$target.innerHTML = matchPosts.filter(p => p).map(p => {
return `<article>
<h3><a href="${p.link}">${p.title}</a></h3>
<p>${p.content}...</p>
</article>`;
}).join('');
} else {
$target.innerHTML = `<article>No relevant search results found.</article>`;
}
});
})()
});

View File

@ -79,9 +79,8 @@ main
blockquote p
margin: 0 !important
&.single
article a
text-decoration: underline
a
text-decoration: underline !important
&.post article > p:first-of-type::first-letter,
&.essays article > p:first-of-type::first-letter
@ -96,11 +95,14 @@ main
margin-top: 3.5rem
.list-tags
a
text-decoration: none !important
header
margin: auto
padding-top: 1rem
padding-bottom: 1.5rem
max-width: 80%
h1
color: var(--accent)
@ -149,6 +151,11 @@ kbd
transition: left .1s ease-in
.sl-counter
font-size: 1.2rem !important
font-weight: bold
.sl-wrapper
.sl-counter
font-weight: bold
font-size: 1.2rem !important
.sl-caption
text-align: center
background: rgba(0,0,0,0.65) !important

View File

@ -0,0 +1,13 @@
.search-form
padding-top: 1rem
padding-bottom: 1rem
button[type=submit]
background-color: white
border: 1px solid var(--accent)
color: var(--accent)
&:hover
color: white
background-color: var(--accent)

View File

@ -10,3 +10,4 @@ $grey: #333
@import 'listing'
@import 'commento'
@import 'goodreads'
@import 'forms'

View File

@ -21,36 +21,16 @@
{{ end }}
{{ end }}
{{ if (not .Params.disableList) }}
<div class="list">
{{ range .Paginator.Pages.GroupByDate "2006" "desc" }}
{{ range (where .Paginator.Pages ".Params.category" "ne" "archive").GroupByDate "2006" "desc" }}
<h2>{{ .Key }}</h2>
{{ range .Pages.GroupByDate "Jan" }}
<h3>{{ .Key }}</h3>
<ul class="list-ul">
{{ range .Pages.ByDate.Reverse }}
<li>
<span class="list-date">{{ .Date.Format ("02") }}</span>
<div class="list-title">
<h4>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h4>
{{ .Params.subtitle }}
</div>
{{ if isset .Params "tags" }}
<div class="list-tags">
<svg class='icon icon-inline'><use xlink:href="#tag"></use></svg>&nbsp;
{{ range .Params.tags }}
<a href="{{ $.Site.BaseURL }}tags/{{ . | urlize }}"><kbd class="item-tag">{{ . }}</kbd></a>
{{ end }}
</div>
{{ end }}
</li>
{{ end }}
</ul>
{{ partial "list-ul" . }}
{{ end }}
{{ end }}
</div>

View File

@ -17,41 +17,37 @@
</article>
{{ end }}
<div class="list">
<article>
<div class="list">
<!-- https://discourse.gohugo.io/t/lists-of-content-divided-by-posts-first-letter/8534/2 - create a list with all uppercase letters -->
{{ $letters := split "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "" }}
<!-- https://discourse.gohugo.io/t/lists-of-content-divided-by-posts-first-letter/8534/2 - create a list with all uppercase letters -->
{{ $letters := split "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "" }}
<!-- range all pages sorted by their title -->
{{ range .Data.Pages.ByTitle }}
<!-- get the first character of each title. Assumes that the title is never empty! -->
{{ $firstChar := substr .Title 0 1 | upper }}
<!-- in case $firstChar is a letter -->
{{ if $firstChar | in $letters }}
<!-- get the current letter -->
{{ $curLetter := $.Scratch.Get "curLetter" }}
<!-- if $curLetter isn't set or the letter has changed -->
{{ if ne $firstChar $curLetter }}
<!-- update the current letter and print it -->
</ul>
<hr style="clear: both;"/>
{{ $.Scratch.Set "curLetter" $firstChar }}
<!-- range all pages sorted by their title -->
{{ range .Data.Pages.ByTitle }}
<!-- get the first character of each title. Assumes that the title is never empty! -->
{{ $firstChar := substr .Title 0 1 | upper }}
<!-- in case $firstChar is a letter -->
{{ if $firstChar | in $letters }}
<!-- get the current letter -->
{{ $curLetter := $.Scratch.Get "curLetter" }}
<!-- if $curLetter isn't set or the letter has changed -->
{{ if ne $firstChar $curLetter }}
<!-- update the current letter and print it -->
</span></li></ul><div style="clear: both;"></div>
{{ $.Scratch.Set "curLetter" $firstChar }}
<h4 style="float: left; color: grey;">
<svg class='icon' style='position: relative; top: 5px'><use xlink:href='#tag'></use></svg>{{ $firstChar }}
</h4>
<ul style="text-align: left; float: left; margin-left: 20px; width: 80%; list-style-type: none; border-left: #eee 1px solid;">
{{ end }}
<h3>{{ $firstChar }}</h3>
<li>
<h4>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h4>
</li>
{{ end }}
{{ end }}
</div>
<ul class="list-ul" style="padding-top: 1rem"><li><span class='list-tags'>
{{ end }}
<a href="{{ .RelPermalink }}"><kbd class="item-tag">{{ .Title }}</kbd></a>
{{ end }}
{{ end }}
</div>
</article>
</main>

View File

@ -0,0 +1,23 @@
<article>
<ul class="list-ul">
{{ range .Pages.ByDate.Reverse }}
<li>
<span class="list-date">{{ .Date.Format ("02") }}</span>
<div class="list-title">
<h4>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h4>
{{ .Params.subtitle }}
</div>
{{ if isset .Params "tags" }}
<div class="list-tags">
<svg class='icon icon-inline'><use xlink:href="#tag"></use></svg>&nbsp;
{{ range .Params.tags }}
<a href="{{ site.BaseURL }}tags/{{ . | urlize }}"><kbd class="item-tag">{{ . }}</kbd></a>
{{ end }}
</div>
{{ end }}
</li>
{{ end }}
</ul>
</article>

View File

@ -38,8 +38,10 @@
<use xlink:href='#tag'></use>
</svg>
{{ end }}
{{ range .Params.tags }}
<a href="{{ $.Site.BaseURL }}tags/{{ . | urlize }}"><kbd class="item-tag">{{ . }}</kbd></a>
{{ end }}
<span class='list-tags'>
{{ range .Params.tags }}
<a href="{{ $.Site.BaseURL }}tags/{{ . | urlize }}"><kbd class="item-tag">{{ . }}</kbd></a>
{{ end }}
</span>
</header>

File diff suppressed because one or more lines are too long