Skip to content

Commit

Permalink
fix(publish): include cms data in path generation
Browse files Browse the repository at this point in the history
  • Loading branch information
schettn authored Sep 14, 2021
1 parent de5f4b2 commit 6ca1cf8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/jaen-pages/jaen-register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PublishButton from './src/containers/ui/hotbar/PublishButton'
import FilesTab from './src/containers/ui/tabs/FilesTab'
import PagesTab from './src/containers/ui/tabs/PagesTab'
import SettingsTab from './src/containers/ui/tabs/SettingsTab'
import {storageGet, usePages, useSiteMetadata} from './src/contexts/cms'
import {upload} from './src/ipfs'
import {store} from './src/store'
import {JaenPagesEntity, JaenPagesPublish} from './src/types'
Expand Down Expand Up @@ -37,18 +38,22 @@ export default {
},
registerCallbacks: {
onPublish: async () => {
const {allSitePage} = storageGet()

const allNodes = allSitePage.nodes

const state = store.getState()

const createdAt = new Date().toISOString()

const newPages: {[id: string]: JaenPagesEntity} = {}

// upload nodes to ipfs
const nodes = state.site.allSitePage?.nodes
const nodes = state.site.allSitePage.nodes

if (nodes) {
for (const [id, node] of Object.entries(nodes)) {
const path = resolvePath(id, nodes as any)
const path = resolvePath(id, allNodes as any)
const paylaod = JSON.stringify({...node, path})

const url = await upload(paylaod)
Expand All @@ -58,16 +63,16 @@ export default {

const siteMetadataPayload = JSON.stringify(state.site.siteMetadata)

const siteMetadata = siteMetadataPayload
const newSiteMetadata = siteMetadataPayload
? await upload(siteMetadataPayload)
: undefined

const publishData: JaenPagesPublish = {
site: siteMetadata
site: newSiteMetadata
? {
context: {
createdAt,
fileUrl: siteMetadata
fileUrl: newSiteMetadata
}
}
: undefined,
Expand Down

0 comments on commit 6ca1cf8

Please sign in to comment.