generated from cms/tibi-docs
zwischenstand
This commit is contained in:
16
frontend/src/lib/functions/fetch/loadContentAndSetStores.ts
Normal file
16
frontend/src/lib/functions/fetch/loadContentAndSetStores.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { api } from "../../../api"
|
||||
import { pages, content, rerender } from "../../store"
|
||||
export async function loadContentAndSetStores(): Promise<null> {
|
||||
const contentRes = await api<Content[]>("content", {})
|
||||
const contentStore: { [id: string]: Content } = {}
|
||||
const pagesStore: { [path: string]: Content } = {}
|
||||
contentRes.data.forEach((e: Content) => {
|
||||
contentStore[e.id] = e
|
||||
if (e.type === "page") {
|
||||
pagesStore[e.path] = e
|
||||
}
|
||||
})
|
||||
content.set(contentStore)
|
||||
pages.set(pagesStore)
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user