Skip to content

Commit

Permalink
update remaining collection docs
Browse files Browse the repository at this point in the history
  • Loading branch information
souporserious committed Oct 10, 2024
1 parent 792273e commit 965417d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
10 changes: 5 additions & 5 deletions apps/site/docs/02.getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ Prepending the renoun CLI ensures that the renoun process starts before your fra
The `collection` utility is a core concept in renoun. This allows you to query a collection of files from the file system. For example, to create a list of blog posts or documentation pages we can query all the MDX files in a directory:

```tsx
import { collection } from 'renoun/collections'
import { Collection } from 'renoun/collections'

const posts = collection({
const posts = new Collection({
filePattern: 'posts/*.mdx',
})
```
Expand Down Expand Up @@ -87,10 +87,10 @@ generated at the collection's call site for each targeted extension during the d
process. These imports are necessary to load the targeted files from
the file system.

```ts
import { collection } from 'renoun/collections'
```ts highlightedLines="5"
import { Collection } from 'renoun/collections'

const posts = collection(
const posts = new Collection(
{ filePattern: 'posts/*.mdx' },
(slug) => import(`./posts/${slug}.mdx`)
)
Expand Down
12 changes: 6 additions & 6 deletions packages/renoun/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ Collections are a way to organize and query file-system data in renoun. They are
Use the `collection` utility to render a collection of files from the file system:

```tsx
import { collection } from 'renoun/collections'
import { Collection } from 'renoun/collections'

const posts = collection({ filePattern: 'posts/*.mdx' })
const posts = new Collection({ filePattern: 'posts/*.mdx' })

export default async function Page({ params }) {
const Content = await posts
Expand Down Expand Up @@ -73,15 +73,15 @@ export default function Page() {
Use the `APIReference` component to render API references from `collection` sources:

```tsx
import { collection } from 'renoun/collections'
import { Collection } from 'renoun/collections'
import { APIReference } from 'renoun/components'

const components = collection({ filePattern: 'components/*.tsx' })
const components = new Collection({ filePattern: 'components/*.tsx' })

export default async function Page({ params }) {
const Component = await components.getSource(params.slug)!
const component = await components.getSource(params.slug)!

return <APIReference component={Component} />
return <APIReference source={component} />
}
```

Expand Down
3 changes: 1 addition & 2 deletions packages/renoun/src/collections/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import { PostsCollection } from '../../../collections'
import { notFound } from 'next/navigation'

export default async function Page({ params }: { params: { slug: string } }) {
const source = await PostsCollection.getSource(params.slug)
const source = PostsCollection.getSource(params.slug)

if (!source) notFound()

Expand Down Expand Up @@ -117,7 +117,6 @@ When retrieving a source and querying for siblings, composite collections will a
const source = AllCollections.getSource(
'posts/how-to-build-a-button-component'
)!

const [previousSource, nextSource] = await source.getSiblings()
```

Expand Down

0 comments on commit 965417d

Please sign in to comment.