Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/souporserious/renoun

Documentation that matches the quality of your product.
https://github.com/souporserious/renoun

Last synced: about 9 hours ago
JSON representation

Documentation that matches the quality of your product.

Awesome Lists containing this project

README

        





renoun


Your Technical Content Toolkit



Meticulously crafted React components and utilities to
help you create engaging content and documentation.


## Features

- πŸ“ Quickly start authoring technincal content
- πŸ“Š Query file and directory metadata
- πŸ›Ÿ Validate module exports
- πŸ“˜ Display API references
- 🌈 Accurately highlight code blocks
- βœ… Type-check code blocks
- πŸ–ΌοΈ Render source code examples

## Getting Started

```bash
npm install renoun
```

After installing the package, you can follow the [getting started guide](https://www.renoun.dev/docs/getting-started) or start creating content using your [favorite framework](https://www.renoun.dev/guides).

### Collections

Collections are a way to organize and query file-system data in renoun. They are a powerful tool that allows you to define a schema for file exports and query those exports using a simple API.

To get started with collections, instantiate the [`Collection`](https://www.renoun.dev/collections#collection) class to create a collection of files and directories from the file system. We can use the `getSource` method to query a specific file or directory:

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

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

export default async function Page({
params,
}: {
params: Promise<{ slug: string }>
}) {
const post = await posts.getSource((await params).slug)

if (!post) {
return

Post not found

}

const Content = await post.getExport('default').getValue()

return
}
```

Next, we can generate an index page of links to all posts using the `getSources` method:

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

const posts = new Collection<{ frontmatter: { title: string } }>({
filePattern: 'posts/*.mdx',
})

export default async function Page() {
const allPosts = await posts.getSources({ depth: 1 })

return (
<>

Blog



    {allPosts.map(async (post) => {
    const path = post.getPath()
    const frontmatter = await post.getExport('frontmatter').getValue()

    return (


  • {frontmatter.title}

  • )
    })}

>
)
}
```

We added module export types to the `Collection` to provide better intellisense, for example, when enabling [frontmatter](https://www.renoun.dev/guides/mdx#remark-frontmatter) from `renoun/mdx`. We can also provide [schema validation](https://www.renoun.dev/docs/getting-started#validating-exports) to ensure that modules export the correct shape.

Collections are not limited to MDX files and can be used with _any file type_. By organizing content and source code into structured collections, we can easily generate static pages and manage complex routing and navigations. For a more in-depth look at collections, visit the [collections](https://www.renoun.dev/collections) guide.

### Components

Quickly build interactive and engaging content and documentation with renoun’s powerful set of React components.

#### Syntax Highlighting

Use the [`CodeBlock`](https://www.renoun.dev/components/code-block) component to render syntax-highlighted code blocks:

```tsx
import { CodeBlock } from 'renoun/components'

export default function Page() {
return Hello, world!`} />
}
```

Or take full control of the highlighting process with the `Tokens` component:

```tsx
import { CodeBlock, Tokens } from 'renoun/components'

export default function Page() {
return (
Hello, world!`}>





)
}
```

#### API References

Quickly document your APIs with renoun’s [`APIReference`](https://www.renoun.dev/components/api-reference) component:

```tsx
import { APIReference } from 'renoun/components'

export default function Page() {
return
}
```

API references can also be resolved from a `Collection` source. This can be from a file that will include references for all exports:

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

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

export default async function Page({
params,
}: {
params: Promise<{ slug: string }>
}) {
const component = await components.getSource((await params).slug)

if (!component) {
return

Component not found

}

return
}
```

Or from a specific export within a file:

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

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

export default async function Page({
params,
}: {
params: Promise<{ slug: string }>
}) {
const component = await components.getSource((await params).slug)

if (!component) {
return

Component not found

}

const componentExports = component.getExports()

return componentExports.map((source) => (

{source.getName()}




))
}
```

---

The renoun toolkit offers many different components to help facilitate writing technical content. Visit the [components](https://www.renoun.dev/components) page to learn more.

## License

[AGPLv3](/LICENSE.md) Β© [souporserious](https://souporserious.com/)