Multiple index bundles? #485
Replies: 3 comments
-
Hey @MartinMalinda 👋
To fully separate the indexes from each other, yes this would be required.
I think so! Fundamentally the same action, but performed via the NodeJS API. Psuedo-coding something that might work: import * as pagefind from "pagefind";
const books = [
{ directory: "content/books/book-1", "id": "book-1" },
/* ... more books ... */
];
for (const book of books) {
const { index } = await pagefind.createIndex();
await index.addDirectory({
path: book.directory
});
await index.writeFiles({
outputPath: `public/pagefind/${book.id}`
});
} That would output a fully independent To reduce the duplication of the assets, you could instead use Hopefully that makes sense! Let me know if you think that might work for you 🙂 |
Beta Was this translation helpful? Give feedback.
-
At the moment I'm using https://github.com/shishkin/astro-pagefind so I'll need to "eject" from that and roll my own solution. Because of that I can't test it real quick but this looks very realistic to me. I'll see how I can integrate pagefind to Astro in a custom way. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
-
Grand! I'll convert this Issue into a Discussion so we can keep tabs on how you go 🙂 |
Beta Was this translation helpful? Give feedback.
-
I'm testing filters and while they are great, I'm not sure if they can fix my usecase.
My site can potentially grow very big. I'm thinking about publishing whole books on my site. Or very long stories. Each book / story page is a separate web page.
I'd like to provide a search, but scope it only to just opened story / book. Most likely, people don't want to search in multiple books, they wan't to search only in the book they are just reading.
Since I basically never want to search globally, are there any possible optimizations for this usecase during buildtime?
Filters don't seem ideal for me, unless I'm misunderstanding them - it seems like the search happens as usual, and the filter takes an effect in the last moment, after different index files are already loaded. For me, the ideal solution would be to only load specific index files relevant to the opened book.
Does this make sense?
Would I need to run
pagefind
separately for each book somehow, each time with different files? Or is there a more elegant solution?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions