Skip to content

Commit

Permalink
fixed content provider path
Browse files Browse the repository at this point in the history
  • Loading branch information
LiveDuo committed Nov 5, 2023
1 parent ed8e841 commit 0ad6672
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions lib/client/vanilla/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,30 +351,25 @@ function Editor({ standaloneServer = false }) {
)
}

// TODO fix path check
const ContentProvider = ({ data, standaloneServer }) => {
const templateData = data?.find(({ name }) => name === '/')
if (templateData)
const [templateData, setTemplateData] = useState()

useEffect(() => {
const _templateData = data?.find(({ name }) => name === location.pathname)
setTemplateData(_templateData.content)
}, [])

if (data)
return (
<>
<div id="page" dangerouslySetInnerHTML={{ __html: templateData.content }} />
<div id="page" dangerouslySetInnerHTML={{ __html: templateData }} />
<PoweredBy />
</>
)
else return <Editor standaloneServer={standaloneServer} />
}

export { ContentProvider }

// TODO fix path check
const ContentProviderReact = ({ data }) => {
const templateData = data?.find(({ name }) => name === '/')
if (templateData)
return (
<>
<div id="page" dangerouslySetInnerHTML={{ __html: templateData.content }} />
<PoweredBy />
</>
)
else return <Editor standaloneServer={true} />
}
const ContentProviderReact = (props) => <ContentProvider {...props} standaloneServer={true} />
export { ContentProviderReact }

0 comments on commit 0ad6672

Please sign in to comment.