mirror of
https://github.com/starshardstudio/peafowl.git
synced 2024-11-29 00:14:17 +00:00
22 lines
No EOL
673 B
TypeScript
22 lines
No EOL
673 B
TypeScript
import {Page} from "lume/core/file.ts"
|
|
import Site from "lume/core/site.ts";
|
|
|
|
export type FileDataOptions = {
|
|
query: string,
|
|
urlizer: (data: Lume.Data) => string,
|
|
contentizer: (data: Lume.Data) => string,
|
|
}
|
|
|
|
export default function fileData({query, urlizer, contentizer}: FileDataOptions) {
|
|
return (site: Site) => {
|
|
site.addEventListener("beforeSave", () => {
|
|
const datas: Lume.Data[] = site.search.pages(query)
|
|
for(const data of datas) {
|
|
site.pages.push(Page.create({
|
|
url: urlizer(data),
|
|
content: contentizer(data),
|
|
}))
|
|
}
|
|
})
|
|
}
|
|
} |