Created NotionPages store

This commit is contained in:
Julien Nahum
2024-01-02 17:06:55 +01:00
parent d1d8e62abb
commit b3740dc1c3
5 changed files with 66 additions and 52 deletions

27
client/stores/notion_pages.js vendored Normal file
View File

@@ -0,0 +1,27 @@
import {defineStore} from 'pinia'
import {useContentStore} from "~/composables/stores/useContentStore.js";
export const useNotionPagesStore = defineStore('notion_pages', () => {
const contentStore = useContentStore()
const load = (pageId) => {
contentStore.startLoading()
const apiUrl = useAppConfig().notion.worker
return useOpnApi(`${apiUrl}/page/${pageId}`)
.then(({data})=> {
const val = data.value
val['id'] = pageId
contentStore.save(val)
})
.finally(() => {
contentStore.stopLoading()
})
}
return {
...contentStore,
load
}
})