Skip to content

Commit

Permalink
fix: undo Algolia search hack / add configurable meta tags (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
muenzpraeger authored Jan 29, 2021
1 parent 2ef063e commit 8eb9995
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
3 changes: 3 additions & 0 deletions content/_includes/head.njk
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ toggleDarkLightMode(true);
<link rel="mask-icon" href="{{ '/assets/favicons/safari-pinned-tab.svg' | addHash }}" color="#5bbad5">
<link rel="shortcut icon" href="{{ '/assets/favicons/favicon.ico' | addHash }}">
<link rel="canonical" href="{{ page.url | absoluteUrl }}" />
{% for name, item in meta %}
<meta name="{{ name }}" content="{{ item.value }}">
{% endfor %}
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="{{ '/assets/favicons/browserconfig.xml' | addHash }}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand Down
3 changes: 3 additions & 0 deletions content/archive.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
eleventyExcludeFromCollections: true
layout: base.njk
title: Archive
meta:
robots:
value: noindex
---

<div class="postlist pb-8 mt-8 font-light dark:font-extralight pt-4">
Expand Down
3 changes: 3 additions & 0 deletions content/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ pagination:
size: 10
alias: posts
reverse: true
meta:
robots:
value: noindex
---

<div class="postlist pb-8 mt-8 font-light dark:font-extralight">
Expand Down
24 changes: 11 additions & 13 deletions src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,17 @@ const searchContent = (e) => {
}
let hits = 0;
for (const item of json.hits) {
if (item.url.startsWith("/posts/")) {
const liEl = document.createElement("li");
liEl.setAttribute(
"class",
"bg-gradient-to-r from-white via-gray-100 to-white dark:via-dark-middle dark:from-dark-outer dark:to-dark-outer mb-4 py-2 truncate"
);
const aEl = document.createElement("a");
aEl.setAttribute("href", item.url);
aEl.textContent = item.title.split("|")[0];
liEl.appendChild(aEl);
ulEl.appendChild(liEl);
hits = hits + 1;
}
const liEl = document.createElement("li");
liEl.setAttribute(
"class",
"bg-gradient-to-r from-white via-gray-100 to-white dark:via-dark-middle dark:from-dark-outer dark:to-dark-outer mb-4 py-2 truncate"
);
const aEl = document.createElement("a");
aEl.setAttribute("href", item.url);
aEl.textContent = item.title.split("|")[0];
liEl.appendChild(aEl);
ulEl.appendChild(liEl);
hits = hits + 1;
}
searchDesktopTitleEl.textContent = `Search (${hits} hit/s)`;
searchMobileTitleEl.textContent = `${hits} hit/s`;
Expand Down

0 comments on commit 8eb9995

Please sign in to comment.