Releases: souporserious/renoun
@omnidoc/[email protected]
Patch Changes
- 825824f: Exports
Headings
type.
[email protected]
Minor Changes
- c017f16: Adds
@omnidoc/mdx-plugins
package that includes pre-configured and customremark
andrehype
plugins. - a2f85cb: Adds
filter
option tocreateCollection
for filtering by specific file system sources.
Patch Changes
- 8267207: Adds better error handling when trying to update the project based on a file system change.
@omnidoc/[email protected]
Minor Changes
- c017f16: Adds
@omnidoc/mdx-plugins
package that includes pre-configured and customremark
andrehype
plugins.
[email protected]
Patch Changes
- 622c1c4: Use newer version of pnpm to fix catalog on publish.
[email protected]
Minor Changes
- 4c29cdc: Removes
getTitle
method for collection source. - 9b4fe41: Adds
getTags
method to collection export source that returns the relative JS Doc tags if they exist.
Patch Changes
- ac6ce1c: Always clean up sub-process in close event when using cli.
- 365a2c3: The
getText
method for a collection export source now includes the full context of everything used within the export. - 1b6d65a: Adds better title parsing for file system and export source names.
- 43e379c: Adds
.git
to default ignored list for projects. - 1a4888b: Removes the
sourcePath
prop from theCodeBlock
component which was previously only used with the MDX plugins and Webpack loader. - 0b00c1a: Fixes
getEditPath
not trimming the working directory in production.
[email protected]
[email protected]
Major Changes
- eb8d77e: Renames the package from
mdxts
toomnidoc
.
[email protected]
Patch Changes
- 39be366: Fixes
MDXContent
component causing_jsx is not a function
during development. - 5504a76: Replaces
@manypkg/find-root
with simplified utility for getting the root directory. - b7b664c: Adds
allowErrors
prop toCodeInline
. - 31e00c5: Trims empty export from copy value.
- 08d47ec: Fix imports in
CodeBlock
to capture correct types.
[email protected]
Major Changes
-
98c68a3: Removes
mdxts/next
package export. This is an effort to simplify the core package and reduce the number of dependencies. This functionality will be available in a separate package in the future.Breaking Changes
If using Next.js, this is a breaking change for users who are importing
mdxts/next
directly. The following configuration can be used to enable MDX support and silence warnings from thets-morph
dependency:import createMDXPlugin from '@next/mdx' import remarkFrontmatter from 'remark-frontmatter' import remarkMdxFrontmatter from 'remark-mdx-frontmatter' import webpack from 'webpack' const withMDX = createMDXPlugin({ extension: /\.mdx?$/, options: { remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter], }, }) export default withMDX({ pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'], webpack(config) { config.plugins.push( new webpack.ContextReplacementPlugin( /\/(@ts-morph\/common)\//, (data) => { for (const dependency of data.dependencies) { delete dependency.critical } return data } ) ) return config }, })
Then add or update the
mdx-components.tsx
file in the root of the project to set up the code components:import { MDXComponents } from 'mdx/types' import { CodeBlock, CodeInline } from 'mdxts/components' export function useMDXComponents() { return { code: (props) => { return ( <CodeInline value={props.children as string} language="typescript" /> ) }, pre: (props) => { const { value, language } = CodeBlock.parsePreProps(props) return <CodeBlock allowErrors value={value} language={language} /> }, } satisfies MDXComponents }
-
98c68a3: Removes
createSource
in favor of usingcreateCollection
frommdxts/collections
.Breaking Changes
Use
createCollection
to generate sources:import { createCollection, type FileSystemSource } from 'mdxts/collections' type ComponentSchema = Record<string, React.ComponentType> export type ComponentSource = FileSystemSource<ComponentSchema> export const ComponentsCollection = createCollection<ComponentSchema>( 'src/components/**/*.{ts,tsx}', { baseDirectory: 'components', basePath: 'components', tsConfigFilePath: '../../packages/mdxts/tsconfig.json', } )
-
98c68a3: Removes
Navigation
component in favor of usingcreateCollection
directly.Breaking Changes
Use
createCollection
to generate navigations:List Navigation
Use
getSources
to render a list of the immediate sources in the collection:export default async function Page() { return ( <> <h1>All Posts</h1> <ul> {PostsCollection.getSources().map((source) => ( <Post key={source.getPath()} source={source} /> ))} </ul> </> ) }
Tree Navigation
Similar to list navigation, we can use
getSources
recursively to render a tree of links:import { PostsCollection } from '@/collections' export default async function Layout() { return ( <nav> <ul> <TreeNavigation Source={PostsCollection} /> </ul> </nav> ) } async function TreeNavigation({ source }: { source: PostSource }) { const sources = source.getSources({ depth: 1 }) const path = source.getPath() const depth = source.getDepth() const frontmatter = await source.getNamedExport('frontmatter').getValue() if (sources.length === 0) { return ( <li style={{ paddingLeft: `${depth}rem` }}> <Link href={path} style={{ color: 'white' }}> {frontmatter.title} </Link> </li> ) } const childrenSources = sources.map((childSource) => ( <TreeNavigation key={childSource.getPath()} source={childSource} /> )) if (depth > 0) { return ( <li style={{ paddingLeft: `${depth}rem` }}> <Link href={path} style={{ color: 'white' }}> {frontmatter.title} </Link> <ul>{childrenSources}</ul> </li> ) } return <ul>{childrenSources}</ul> }
Sibling Navigation
Use
getSiblings
to get the previous and next sources in the collection:export default async function Page({ params }) { const postSource = Posts.getSource(params.slug) if (!postSource) notFound() const Post = await postSource.getDefaultExport().getValue() const frontmatter = await postSource .getNamedExport('frontmatter') .getValue() const [previous, next] = postSource.getSiblings() return ( <> <h1>{frontmatter.title}</h1> <p>{frontmatter.description}</p> <Post /> {previous ? <Sibling source={previous} direction="previous" /> : null} {next ? <Sibling source={next} direction="next" /> : null} </> ) } function Sibling({ source, direction, }: { source: ReturnType<typeof Posts.getSource> direction: 'previous' | 'next' }) { const frontmatter = await source.getNamedExport('frontmatter').getValue() return ( <a href={source.getPath()}> <span>{direction === 'previous' ? 'Previous' : 'Next'}</span> {frontmatter.title} </a> ) }
Minor Changes
-
98c68a3: Adds remaining configuration options from
next/plugin
to JSON config. -
98c68a3: Adds
getSiblings
method to collection export source. -
98c68a3: Adds
getType
method to collection export source for retrieving type metadata for an export. -
98c68a3: Adds
APIReference
component. This replaces the previousExportedTypes
component and is used to document the API of module exports using collections:import { APIReference } from 'mdxts/components' import { createCollection } from 'mdxts/collections' const ComponentsCollection = createCollection('components/**/*.{ts,tsx}', { baseDirectory: 'components', basePath: 'components', }) export default function Component({ params }) { return ComponentsCollection.getSource(params.slug) .getExports() .map((exportSource) => ( <APIReference key={exportSource.name} source={exportSource} /> )) }
-
98c68a3:
CodeBlock
now tries to parseworkingDirectory
as aURL
and gets the pathname directory. This allows usingimport.meta.url
directly in theworkingDirectory
prop:<CodeBlock source="./counter/useCounter.ts" workingDirectory={import.meta.url} />
-
98c68a3: Adds
getMainExport
for file system source andisMainExport
for export source.
Patch Changes
- 98c68a3: Fixes collection file system source name parsing not accounting for filename segments.
- 98c68a3: Fixes missing bottom padding in
CodeInline
. - 98c68a3: Fixes syncing project files during development.
- 98c68a3: Fixes import map generation race condition causing imports to not be found during production builds.
- 98c68a3: Fixes export source
getPath
to construct the url path from the file system. - 98c68a3: Defaults collection
getSource
to returnindex
source if it exists. - 98c68a3: Fixes file patterns based on relative tsconfig directory.
- 98c68a3: Fixes duplicate sources returned from collection
getSources
and file system sourcegetSiblings
.
[email protected]
Minor Changes
-
3378b26: Adds support for defining schemas for collections:
import { createCollection, type MDXContent } from 'mdxts/collections' import { z } from 'zod' const frontmatterSchema = z.object({ title: z.string(), date: z.coerce.date(), summary: z.string().optional(), tags: z.array(z.string()).optional(), }) export const PostsCollection = createCollection<{ default: MDXContent frontmatter: z.infer<typeof frontmatterSchema> }>('posts/*.mdx', { baseDirectory: 'posts', schema: { frontmatter: frontmatterSchema.parse, }, })
-
53bfeb8: Moves all
CodeBlock
components to userestyle
and exposes acss
prop for each component to allow overriding styles.
Patch Changes
- 361b420: Improves error messaging when working with collection utilities.
- 3207ce0: Adds export for
frontmatter
from MDX files when usingmdx-plugins
. - 598bd9c: Fixes
getEditPath
for export source in local development. - 38b7b4b: Fixes caching implementation for shiki highlighter.
- e401fe0: Updates collection import map during development when adding, removing, or editing collections.
- 400384a: Inherit background color in code element in
CodeBlock
to prevent global styles leaking in.