# Preview in data models

**URL:** <https://forum.builder.io/t/preview-in-data-models/2022>\
**Category:** General\
**Created:** [April 11, 2022, 8:26pm UTC](https://forum.builder.io/t/preview-in-data-models/2022 "2022-04-11T20:26:44Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![TimG](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/timg/32/714_2.png) [@TimG](https://forum.builder.io/u/TimG)\
**Post date:** [April 13, 2022, 6:45pm UTC](https://forum.builder.io/t/preview-in-data-models/2022/8 "2022-04-13T18:45:57Z")

</div>

I see, ok then yes that should be pretty straight forward!

NextJS should be able to handle all the routing, so you shouldn’t need to worry about the 100 various entries. Are you using directory and bracket notation for NextJS? Your blog page is at directory of something like `app/blog/[slug].js` ?

Your code would then look something like this:

```auto
builder.init(BUILDER_API_KEY)

export async function getStaticProps({params}){
  
  const blogData =
    (await builder
      .get('blog-model', {
        query: {
          'data.slug': params?.slug,
        },
      })
      .toPromise()) || null

  return {
    props: {
      blogData
    }
  }
}
...

export default function BlogPost({blogData}) {
  ...
  return (
    <BuilderContent content={blogData} model="blog-model" options={{ includeRefs: true }}>
      {(data, loading, content) => {
          <Title>{blog.data.title}</Title> 
          ...
      }
    </>
  )
}

```

So that you are dynamically showing and displaying the page based on the slug and you have the ability to view your preview within Builder. Just make sure that you also set the editing URL in the data model entry to be the path of where these blogs will live… [Blog - YourSite.com](http://www.yourSite.com/blog/)

You can see more about adding dynamic URLs as well here: [Using Advanced Editing URL Logic to set up dynamic preview URLs](https://forum.builder.io/t/using-advanced-editing-url-logic-to-set-up-dynamic-preview-urls/1930)

---

_[View the full topic](https://forum.builder.io/t/preview-in-data-models/2022)._
