Add pagefind.

This commit is contained in:
Michael Lipp 2025-02-23 12:00:27 +01:00
parent 5b8b47f95c
commit 558f4d96c9

View file

@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<html> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1"> <meta http-equiv="X-UA-Compatible" content="chrome=1">
@ -11,10 +11,31 @@
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--> <![endif]-->
<link href="../pagefind/pagefind-ui.css" rel="stylesheet">
<script src="../pagefind/pagefind-ui.js"></script>
<script>
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#search", showSubResults: true,
// See https://github.com/CloudCannon/pagefind/issues/530
processResult: function (result) {
if (result?.meta?.image) {
let resultBase = new URL(result.url, window.location);
let remappedImage = new URL(result.meta.image, resultBase);
if (remappedImage.hostname !== window.location.hostname) {
result.meta.image = remappedImage.toString();
} else {
result.meta.image = remappedImage.pathname;
}
}
}
});
});
</script>
{% seo %} {% seo %}
</head> </head>
<body> <body>
<div class="wrapper"> <div class="wrapper">
<div id="search"></div>
<header> <header>
<div> <div>
<div style="float: left;"> <div style="float: left;">
@ -68,4 +89,4 @@
{% include matomo.html %} {% include matomo.html %}
</body> </body>
</html> </html lang="en">