This commit is contained in:
Johannes Kirschbauer 2023-12-28 13:11:05 +01:00 committed by Johannes Kirschbauer
parent 0e50792a1d
commit 88cb992bab
5 changed files with 16 additions and 86 deletions

View File

@ -55,16 +55,23 @@ in
# nextjs writes in node_mdules # nextjs writes in node_mdules
built = { built = {
override.copyTree = true; override = {
# nextjs chaches some stuff in $HOME copyTree = true;
override.preBuild = ''
export HOME=./home
${hooks.prepare} # nextjs chaches some stuff in $HOME
preBuild = ''
export HOME=./home
ls -la src/models/data ${hooks.prepare}
'';
ls -la src/models/data
'';
postBuild = ''
npx pagefind --site ./out
ls -la out
'';
};
tree = tree =
let let

View File

@ -91,8 +91,6 @@ export default async function Page(props: { params: { path: string[] } }) {
meta?.signature || (item && findType(item)) || "" meta?.signature || (item && findType(item)) || ""
); );
console.log(meta);
const position = const position =
meta?.content_meta?.position || meta?.content_meta?.position ||
meta?.attr_position || meta?.attr_position ||
@ -171,7 +169,7 @@ export default async function Page(props: { params: { path: string[] } }) {
{!position && ( {!position && (
<div data-pagefind-ignore="all"> <div data-pagefind-ignore="all">
<Typography variant="h5" sx={{ pt: 2 }}> <Typography variant="h5" sx={{ pt: 2 }}>
Noogle's tip {"Noogle's tip"}
</Typography> </Typography>
<Typography variant="body1" gutterBottom sx={{ py: 2 }}> <Typography variant="body1" gutterBottom sx={{ py: 2 }}>
<p> <p>

View File

@ -55,7 +55,7 @@ export function PagefindResults() {
const { search } = usePagefindSearch(); const { search } = usePagefindSearch();
useEffect(() => { useEffect(() => {
const init = async () => { const init = async () => {
console.log({ search }); console.log({ search, term, filters: { from, to } });
if (search) { if (search) {
let raw = await search(term, { filters: { from, to } }); let raw = await search(term, { filters: { from, to } });
setSearchResults(raw?.results || []); setSearchResults(raw?.results || []);

View File

@ -77,7 +77,6 @@ export const Filter = (props: FilterProps) => {
try { try {
const f = await pagefind.filters(); const f = await pagefind.filters();
setFilters(f); setFilters(f);
console.log({ f });
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }

View File

@ -1,74 +0,0 @@
"use client";
import React, { useState } from "react";
export default function SearchPage() {
const [query, setQuery] = React.useState("");
const [results, setResults] = React.useState([]);
React.useEffect(() => {
async function loadPagefind() {
// @ts-ignore
if (typeof window.pagefind === "undefined") {
try {
// @ts-ignore
window.pagefind = await import(
// @ts-expect-error pagefind.js generated after build
/* webpackIgnore: true */ "/pagefind/pagefind.js"
);
// @ts-ignore
console.log("setup:", window?.pagefind);
} catch (e) {
// @ts-ignore
window.pagefind = { search: () => ({ results: [] }) };
}
}
}
loadPagefind();
}, []);
async function handleSearch() {
// @ts-ignore
console.log("searching", window?.pagefind);
// @ts-ignore
if (window.pagefind) {
// @ts-ignore
const search = await window.pagefind.search(query);
setResults(search.results);
}
}
return (
<div>
<input
type="text"
placeholder="Search..."
value={query}
onChange={(e) => setQuery(e.target.value)}
onInput={handleSearch}
/>
<div id="results">
{results.map((result, index) => (
// @ts-ignore
<Result key={result.id} result={result} />
))}
</div>
</div>
);
}
function Result({ result }: any) {
const [data, setData] = useState(null);
React.useEffect(() => {
async function fetchData() {
const data = await result.data();
setData(data);
}
fetchData();
}, [result]);
if (!data) return null;
// @ts-ignore
return <div>{`${data.url}`}</div>;
}