BuilderIO / builder

Visual Development for React, Vue, Svelte, Qwik, and more
https://builder.io
MIT License
7.51k stars 939 forks source link

Is it possible to have dynamically created pages? #3012

Closed Nedimko123 closed 6 months ago

Nedimko123 commented 8 months ago

Is is possible to have dynamically created pages with Builder.io where each page might have custom content blocks in-between.

So what we would want is to have page dynamically created thourgh the data model but have the ability to add blocks in builder.io?

Obviously in this example we can load the data dynamically and bind them to components, but is it possible to have editable content blocks?

import { component$, Resource, useResource$ } from '@builder.io/qwik'
import { DocumentHead, routeLoader$, useLocation } from '@builder.io/qwik-city'
import { getContent, RenderContent, getBuilderSearchParams } from '@builder.io/sdk-qwik'
import { isFullString } from 'is-what'
import { apiKey, CUSTOM_COMPONENTS } from 'qwik-ui'
import { fetchOneEntry } from '@builder.io/sdk-qwik'

// Define a route loader to load authentication parameters from the query string.
const useLoadSalesData = routeLoader$(async (requestEv) => {
    const slug = requestEv.params['slug']
    const response = await fetchOneEntry({ apiKey: apiKey, model: 'sales-rep' })
    if (isFullString(slug) && response) {
        const data = response.data
        if (slug.toLowerCase() !== data?.slug.toLowerCase()) {
            throw requestEv.redirect(302, '/status/error/')
        }
        console.log(data)
        return data
    } else {
        throw requestEv.redirect(302, '/status/error/')
    }
})
export default component$(() => {
    const location = useLocation()

    const salesData = useLoadSalesData()

    return (
        <>

        </>
    )
})

export const head: DocumentHead = ({ resolveValue }) => {
    const salesData = resolveValue(useLoadSalesData)
    return {
        title: `Sales - ${salesData.name}`,
    }
}
mrkoreye commented 6 months ago

Hi @Nedimko123 ,since this is not an SDK related bug, if you are still having issues can you please ask this question over at forum.builder.io? Thank you!