mirror of
https://github.com/nix-community/noogle.git
synced 2024-11-29 23:02:22 +03:00
fixup
This commit is contained in:
parent
0e50792a1d
commit
88cb992bab
@ -55,16 +55,23 @@ in
|
||||
|
||||
# nextjs writes in node_mdules
|
||||
built = {
|
||||
override.copyTree = true;
|
||||
override = {
|
||||
|
||||
# nextjs chaches some stuff in $HOME
|
||||
override.preBuild = ''
|
||||
export HOME=./home
|
||||
copyTree = true;
|
||||
|
||||
${hooks.prepare}
|
||||
# nextjs chaches some stuff in $HOME
|
||||
preBuild = ''
|
||||
export HOME=./home
|
||||
|
||||
${hooks.prepare}
|
||||
|
||||
ls -la src/models/data
|
||||
'';
|
||||
ls -la src/models/data
|
||||
'';
|
||||
postBuild = ''
|
||||
npx pagefind --site ./out
|
||||
ls -la out
|
||||
'';
|
||||
};
|
||||
|
||||
tree =
|
||||
let
|
||||
|
@ -91,8 +91,6 @@ export default async function Page(props: { params: { path: string[] } }) {
|
||||
meta?.signature || (item && findType(item)) || ""
|
||||
);
|
||||
|
||||
console.log(meta);
|
||||
|
||||
const position =
|
||||
meta?.content_meta?.position ||
|
||||
meta?.attr_position ||
|
||||
@ -171,7 +169,7 @@ export default async function Page(props: { params: { path: string[] } }) {
|
||||
{!position && (
|
||||
<div data-pagefind-ignore="all">
|
||||
<Typography variant="h5" sx={{ pt: 2 }}>
|
||||
Noogle's tip
|
||||
{"Noogle's tip"}
|
||||
</Typography>
|
||||
<Typography variant="body1" gutterBottom sx={{ py: 2 }}>
|
||||
<p>
|
||||
|
@ -55,7 +55,7 @@ export function PagefindResults() {
|
||||
const { search } = usePagefindSearch();
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
console.log({ search });
|
||||
console.log({ search, term, filters: { from, to } });
|
||||
if (search) {
|
||||
let raw = await search(term, { filters: { from, to } });
|
||||
setSearchResults(raw?.results || []);
|
||||
|
@ -77,7 +77,6 @@ export const Filter = (props: FilterProps) => {
|
||||
try {
|
||||
const f = await pagefind.filters();
|
||||
setFilters(f);
|
||||
console.log({ f });
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
@ -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>;
|
||||
}
|
Loading…
Reference in New Issue
Block a user