1st request #1

Merged
dtomlinson merged 70 commits from develop into master 2020-06-04 16:46:03 +00:00
9 changed files with 313 additions and 3 deletions
Showing only changes of commit fe9385c2e6 - Show all commits

2
.gitignore vendored
View File

@@ -12,3 +12,5 @@ hugo.darwin
hugo.linux
# End of https://www.gitignore.io/api/hugo
blog/node_modules

BIN
blog/.DS_Store vendored

Binary file not shown.

View File

@@ -0,0 +1,70 @@
const fs = require("fs").promises;
const { promisify } = require("util");
const frontMatterParser = require("parser-front-matter");
const lunrjs = require("lunr");
const readdirp = require("readdirp");
const parse = promisify(frontMatterParser.parse.bind(frontMatterParser));
async function loadPostsWithFrontMatter(postsDirectoryPath) {
// We read the content directory, but avoid indexing of these directories:
// .DS_Store, old.
const postEntryInfos = await readdirp.promise(postsDirectoryPath, {
fileFilter: ["!.DS_Store", "!_index.md", "!*.jpg", "!*.svg", "!*.png"],
directoryFilter: "!old",
});
// We take each post and map their paths.
const postNames = postEntryInfos.map((file) => file.path);
// To debug index building, un-comment the following line to get a list of
// postNames. Do NOT keep it un-commented or the search will fail.
// console.error(postNames);
const posts = await Promise.all(
postNames.map(async (fileName) => {
const fileContent = await fs.readFile(
`${postsDirectoryPath}/${fileName}`,
"utf8"
);
const { content, data } = await parse(fileContent);
return {
// we only take a 10,000 character slice of the post to index. this ensures
// our index doesn't grow too large
content: content.slice(0, 10000),
...data,
};
})
);
return posts;
}
function makeIndex(posts) {
return lunrjs(function () {
// list of fields we are gathering from each post. we use the Title as our
// reference marker (identifying feature)
this.ref("title");
this.field("title");
// this.field('authors');
// this.field('date');
this.field("content");
this.field("tags");
// this.field('resources.src');
// this.field('imageDescription')
posts.forEach((p) => {
this.add(p);
});
});
}
async function run() {
// The following line specifies which directory to use for indexing. See above
// for excluded directories and filetypes.
const posts = await loadPostsWithFrontMatter(`${__dirname}/content/`);
const index = makeIndex(posts);
console.log(JSON.stringify(index));
}
run()
.then(() => process.exit(0))
.catch((error) => {
console.error(error.stack);
process.exit(1);
});

View File

@@ -20,13 +20,25 @@ LanguageName = "English"
identifier = "home"
name = "Home"
url = "/"
weight = 10
weight = 1
[[menu.main]]
identifier = "about"
name = "About"
url = "/about/"
weight = 0
weight = 2
[[menu.main]]
identifier = "tags"
name = "Tags"
url = "/tags/"
weight = 3
[[menu.main]]
identifier = "search"
name = "Search"
url = "/search/"
weight = 4
[taxonomies]
category = "categories"

View File

@@ -5,7 +5,7 @@ date: "2020-05-04T02:14:50+01:00"
images: ["images/first_post.svg"]
draft: true
authors: ["Daniel Tomlinson"]
tags: ["Introduction"]
tags: ["Introduction", "another"]
---
Hugo ships with several [Built-in Shortcodes](https://gohugo.io/content-management/shortcodes/#use-hugo-s-built-in-shortcodes) for rich content, along with a [Privacy Config](https://gohugo.io/about/hugo-and-gdpr/) and a set of Simple Shortcodes that enable static and no-JS versions of various social media embeds.

7
blog/package.json Normal file
View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"lunr": "^2.3.8",
"parser-front-matter": "^1.6.4",
"readdirp": "^3.4.0"
}
}

File diff suppressed because one or more lines are too long

36
blog/yarn-error.log Normal file
View File

@@ -0,0 +1,36 @@
Arguments:
/usr/local/Cellar/node/13.2.0/bin/node /usr/local/bin/yarn init
PATH:
/Users/dtomlinson/.pyenv/shims:/Users/dtomlinson/.pyenv/bin:/usr/local/python/python-3.8/lib/python3.8/site-packages:/usr/local/opt/openssl/bin:/Users/dtomlinson/.local/bin:/Users/dtomlinson/.poetry/bin:/Users/dtomlinson/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Yarn version:
1.22.0
Node version:
13.2.0
Platform:
darwin x64
Trace:
Error: canceled
at Interface.<anonymous> (/usr/local/lib/node_modules/yarn/lib/cli.js:136987:13)
at Interface.emit (events.js:210:5)
at Interface._ttyWrite (readline.js:885:16)
at ReadStream.onkeypress (readline.js:191:10)
at ReadStream.emit (events.js:210:5)
at emitKeys (internal/readline/utils.js:433:14)
at emitKeys.next (<anonymous>)
at ReadStream.onData (readline.js:1151:36)
at ReadStream.emit (events.js:210:5)
at addChunk (_stream_readable.js:326:12)
npm manifest:
No manifest
yarn manifest:
No manifest
Lockfile:
No lockfile

182
blog/yarn.lock Normal file
View File

@@ -0,0 +1,182 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
dependencies:
sprintf-js "~1.0.2"
esprima@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
extend-shallow@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
integrity sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=
dependencies:
is-extendable "^0.1.0"
file-is-binary@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/file-is-binary/-/file-is-binary-1.0.0.tgz#5e41806d1bcae458c8fec32fe3ce122dbbbc4356"
integrity sha1-XkGAbRvK5FjI/sMv484SLbu8Q1Y=
dependencies:
is-binary-buffer "^1.0.0"
isobject "^3.0.0"
for-in@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=
gray-matter@^3.0.2:
version "3.1.1"
resolved "https://registry.yarnpkg.com/gray-matter/-/gray-matter-3.1.1.tgz#101f80d9e69eeca6765cdce437705b18f40876ac"
integrity sha512-nZ1qjLmayEv0/wt3sHig7I0s3/sJO0dkAaKYQ5YAOApUtYEOonXSFdWvL1khvnZMTvov4UufkqlFsilPnejEXA==
dependencies:
extend-shallow "^2.0.1"
js-yaml "^3.10.0"
kind-of "^5.0.2"
strip-bom-string "^1.0.0"
is-binary-buffer@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-binary-buffer/-/is-binary-buffer-1.0.0.tgz#bc6031290b65cbf799b9d9502b50fd5375524007"
integrity sha1-vGAxKQtly/eZudlQK1D9U3VSQAc=
dependencies:
is-buffer "^1.1.5"
is-buffer@^1.1.5:
version "1.1.6"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==
is-extendable@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=
is-extendable@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4"
integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==
dependencies:
is-plain-object "^2.0.4"
is-plain-object@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"
integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==
dependencies:
isobject "^3.0.1"
is-whitespace@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/is-whitespace/-/is-whitespace-0.3.0.tgz#1639ecb1be036aec69a54cbb401cfbed7114ab7f"
integrity sha1-Fjnssb4DauxppUy7QBz77XEUq38=
isobject@^3.0.0, isobject@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
js-yaml@^3.10.0:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
kind-of@^3.0.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=
dependencies:
is-buffer "^1.1.5"
kind-of@^5.0.2:
version "5.1.0"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d"
integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==
lazy-cache@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-2.0.2.tgz#b9190a4f913354694840859f8a8f7084d8822264"
integrity sha1-uRkKT5EzVGlIQIWfio9whNiCImQ=
dependencies:
set-getter "^0.1.0"
lunr@^2.3.8:
version "2.3.8"
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.8.tgz#a8b89c31f30b5a044b97d2d28e2da191b6ba2072"
integrity sha512-oxMeX/Y35PNFuZoHp+jUj5OSEmLCaIH4KTFJh7a93cHBoFmpw2IoPs22VIz7vyO2YUnx2Tn9dzIwO2P/4quIRg==
mixin-deep@^1.2.0:
version "1.3.2"
resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566"
integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==
dependencies:
for-in "^1.0.2"
is-extendable "^1.0.1"
parser-front-matter@^1.6.4:
version "1.6.4"
resolved "https://registry.yarnpkg.com/parser-front-matter/-/parser-front-matter-1.6.4.tgz#71fe3288a51c7b8734163f3793f3fdc24b0a8a90"
integrity sha512-eqtUnI5+COkf1CQOYo8FmykN5Zs+5Yr60f/7GcPgQDZEEjdE/VZ4WMaMo9g37foof8h64t/TH2Uvk2Sq0fDy/g==
dependencies:
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"
picomatch@^2.2.1:
version "2.2.2"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
readdirp@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.4.0.tgz#9fdccdf9e9155805449221ac645e8303ab5b9ada"
integrity sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==
dependencies:
picomatch "^2.2.1"
set-getter@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/set-getter/-/set-getter-0.1.0.tgz#d769c182c9d5a51f409145f2fba82e5e86e80376"
integrity sha1-12nBgsnVpR9AkUXy+6guXoboA3Y=
dependencies:
to-object-path "^0.3.0"
sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
strip-bom-string@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/strip-bom-string/-/strip-bom-string-1.0.0.tgz#e5211e9224369fbb81d633a2f00044dc8cedad92"
integrity sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI=
to-object-path@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af"
integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=
dependencies:
kind-of "^3.0.2"
trim-leading-lines@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/trim-leading-lines/-/trim-leading-lines-0.1.1.tgz#0e7cac3e83042dcf95a74ed36966f17744d5c169"
integrity sha1-DnysPoMELc+Vp07TaWbxd0TVwWk=
dependencies:
is-whitespace "^0.3.0"