### Add Markdown/MDX Content Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/installation.mdx Demonstrates adding Markdown/MDX content to `src/app/page.mdx`. This example includes basic Markdown, a link, and custom components like `Frame`, `Image`, and `Caption` provided by Prose UI or MDX setup. ```mdx # Hello, world! The Viking landers, part of NASA's [Viking program](https://en.wikipedia.org/wiki/Viking_program), were the first U.S. missions to successfully land on Mars and transmit images and scientific data back to Earth in 1976. Viking lander Viking lander ``` -------------------------------- ### Install Prose UI and MDX Dependencies Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/installation.mdx Installs core Prose UI, Next.js integration, MDX tools, and TypeScript types. This command uses pnpm, but any package manager can be used. It ensures all necessary packages for MDX rendering and Prose UI styling are available. ```bash pnpm add @prose-ui/core @prose-ui/next @next/mdx @mdx-js/loader @mdx-js/react @types/mdx ``` -------------------------------- ### Configuring Remark Plugins with Options (TypeScript) Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/how-it-works.mdx Provides an example of using the remarkPlugins function with an options object to configure features like image optimization. The function returns an array of plugins for MDX setup. ```typescript const plugins = remarkPlugins({ image: { imageDir: './public', }, }) ``` -------------------------------- ### Create New Next.js Project Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/installation.mdx Initializes a new Next.js project. This command prompts the user for project configuration. Ensure Webpack is used if `@next/mdx` is planned, as Turbopack is the default in newer Next.js versions. ```bash npx create-next-app@latest ``` -------------------------------- ### Install Prose UI - JavaScript Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/demo/index.mdx This JavaScript code snippet demonstrates how to install and use Prose UI, showing variable declaration and string interpolation. It is useful for front-end development. ```javascript const moons = 95 const text = `Jupiter has ${moons} moons, and Europa may harbor life in its hidden ocean.` console.log(text) ``` -------------------------------- ### Import Prose UI CSS Styles Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/installation.mdx Imports Prose UI's core CSS and KaTeX (for math formulas) into `src/app/globals.css`. This step ensures that Prose UI's visual styles and typography are applied throughout the application. ```css @import "@prose-ui/next/prose-ui.css"; @import "@prose-ui/next/katex.min.css"; ``` -------------------------------- ### Configure MDX Components with Prose UI Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/installation.mdx Sets up the `mdx-components.tsx` file to override default MDX components with Prose UI's components. This ensures Prose UI's styling and functionality are applied to MDX content. ```tsx import { mdxComponents } from "@prose-ui/next"; import type { MDXComponents } from "mdx/types"; export function useMDXComponents(components: MDXComponents): MDXComponents { return { ...components, ...mdxComponents, }; } ``` -------------------------------- ### Inline Math Example Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/components/math.mdx Demonstrates how to use single dollar signs ($...$) for inline math formulas within a paragraph. This allows mathematical expressions to be seamlessly integrated into text. ```mdx The quadratic formula is $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$ for solving equations. ``` -------------------------------- ### Using Frame and Image Components in Prose UI Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/demo/images.mdx Demonstrates how to use the Frame and Image components from Prose UI to display an image with a caption. This setup leverages Next.js image optimization provided by Prose UI. ```jsx Planet Jupiter Juno Captures Jupiter. Credits: NASA/JPL-Caltech/SwRI/MSSS, Thomas Thomopoulos © CC BY ``` -------------------------------- ### Configure Next.js for MDX Rendering Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/installation.mdx Modifies `next.config.ts` to enable MDX rendering with Prose UI's remark plugins. This configuration ensures Next.js processes `.md` and `.mdx` files and applies the specified remark plugins for content transformation. ```typescript import createMDX from "@next/mdx"; import { remarkPlugins } from "@prose-ui/core"; /** @type {import('next').NextConfig} */ const nextConfig = { pageExtensions: ["js", "jsx", "md", "mdx", "ts", "tsx"], }; const withMDX = createMDX({ options: { remarkPlugins: remarkPlugins(), }, }); export default withMDX(nextConfig); ``` -------------------------------- ### Adjust Application Layout for Prose UI Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/installation.mdx Updates `app/layout.tsx` to apply Prose UI's base styling and font variables. It wraps the application content within a `body` tag with the `prose-ui` class and ensures correct font application. ```html
{children}
``` -------------------------------- ### Block Math Example Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/components/math.mdx Illustrates the use of double dollar signs ($$...$$) for block math formulas. These are rendered as standalone, centered equations, ideal for complex mathematical expressions. ```mdx $$ \int_{a}^{b} f(x) \, dx = F(b) - F(a) $$ ``` -------------------------------- ### Center Image and Add Caption using Frame and Image Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/components/overview.mdx This example demonstrates how to use the Frame and Image React components from Prose UI to center an image and provide it with a caption. It requires the Frame, Image, and Caption components to be imported and available in the scope. ```jsx Abstract art Center aligned image ``` -------------------------------- ### Render Math with remarkInlineMath and remarkBlockMath | Prose UI Source: https://context7.com/vrepsys/prose-ui/llms.txt This snippet demonstrates the `remarkInlineMath` and `remarkBlockMath` plugins for rendering LaTeX math expressions within markdown. These plugins transform math syntax into React components for display using KaTeX. The setup requires `unified`, `remark-parse`, and `remark-math`. ```typescript import { unified } from 'unified' import remarkParse from 'remark-parse' import remarkMath from 'remark-math' import remarkInlineMath from '@prose-ui/core/remark-inline-math' import remarkBlockMath from '@prose-ui/core/remark-block-math' const processor = unified() .use(remarkParse) .use(remarkMath) .use(remarkInlineMath) .use(remarkBlockMath) // Inline math: $E = mc^2$ // Output: E = mc^2 // Block math: // $$ // \int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi} // $$ // Output: {'\\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi}'} const result = await processor.process('The formula $E = mc^2$ shows energy-mass equivalence.') ``` -------------------------------- ### Convert Links with remarkLink Plugin | Prose UI Source: https://context7.com/vrepsys/prose-ui/llms.txt This example shows how to use the `remarkLink` plugin from `@prose-ui/core/remark-link` to transform markdown links into Next.js `Link` components. It facilitates internal navigation and supports optional URL mapping for dynamic link generation. It requires `unified` and `remark-parse`. ```typescript import { unified } from 'unified' import remarkParse from 'remark-parse' import remarkLink from '@prose-ui/core/remark-link' const processor = unified() .use(remarkParse) .use(remarkLink, { mapUrl: (url) => { // Add version prefix to documentation links if (url.startsWith('/docs/')) { return `/v2${url}` } return url } }) // Input: [Getting Started](/docs/introduction) // Output: Getting Started const result = await processor.process('[API Reference](/docs/api)') ``` -------------------------------- ### Override Callout Component Styles Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/styling.mdx This CSS snippet illustrates how to customize the visual appearance of the callout component in Prose UI. It allows modification of text color, font size, font weight, and line height. ```css :root { --p-callout-color-text: hsl(var(--p-color-text-low)); --p-callout-font-size: '1rem'; --p-callout-font-weight: 400; --p-callout-font-height: '1.5rem'; } ``` -------------------------------- ### Override Accent Colors for Light and Dark Modes Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/styling.mdx This CSS snippet shows how to override the accent color variables for both light and dark modes in Prose UI. It sets the high, default, and low accent color shades using HSL values. ```css :root { --p-color-accent-high: 0, 0%, 0%; --p-color-accent: 0, 0%, 10%; --p-color-accent-low: 0, 0%, 70%; } :root:is(.dark) { --p-color-accent-high: 180, 0%, 100%; --p-color-accent: 180, 0%, 90%; --p-color-accent-low: 180, 0%, 30%; } ``` -------------------------------- ### Render GFM Tables with Frame Component in Prose UI Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/demo/tables.mdx This example demonstrates how to embed a GFM (GitHub Flavored Markdown) table within the Prose UI Frame component. The Frame component allows for adding captions and controlling the alignment of the table content. No specific external dependencies are required beyond the Prose UI library itself. ```jsx import { Frame, Caption } from '@prose-ui/core'; function MyTableComponent() { return ( | Rocket | Height | Payload to LEO | Stages | Manufacturer | |:----------------------|:--------:|:--------------:|:------:|:---------------------------------| | SpaceX Starship | 120 m | 150 t | 2 | SpaceX | | NASA SLS Block 1 | 98 m | 95 t | 2 | NASA (Boeing as prime contractor)| | Blue Origin New Glenn | 98 m | 45 t | 2 | Blue Origin | A comparison of three modern super-heavy-lift launch vehicles ); } ``` -------------------------------- ### Override Fonts with Geist Font Family Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/styling.mdx This CSS snippet demonstrates how to override the default font families in Prose UI to use Vercel's Geist font family. It targets core font variables for general text, headings, and monospace fonts. ```css :root { --p-font-family: var(--font-geist-sans); --p-font-family-heading: var(--font-geist-sans); --p-font-family-mono: var(--font-geist-mono); } ``` -------------------------------- ### Importing Individual Prose UI Components (JavaScript) Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/how-it-works.mdx Demonstrates importing individual React components like Callout, CodeBlock, Frame, Heading, Image, Link, InlineMath, and BlockMath from the '@prose-ui/next' package for direct use outside of MDX. ```javascript import { Callout, CodeBlock, Frame, Heading, Image, Link, InlineMath, BlockMath, } from "@prose-ui/next" ``` -------------------------------- ### Basic Table using GFM Syntax Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/components/table.mdx Demonstrates how to create a basic table using GitHub Flavored Markdown (GFM) syntax. This is the fundamental way to represent tabular data within Prose UI. No external dependencies are required for this basic usage. ```md | Rocket | Height | Payload to LEO | Stages | |:---------------------|:--------:|:--------------:|:------:| | SpaceX Starship | 120 m | 150 t | 2 | | NASA SLS Block 1 | 98 m | 95 t | 2 | | Blue Origin New Glenn| 98 m | 45 t | 2 | ``` -------------------------------- ### Displaying Tip Callout with Prose UI Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/demo/callouts.mdx Shows how to implement the 'tip' variant of the Callout component from Prose UI. This component is recommended for presenting quick tips, best practices, or suggestions to users. It utilizes 'variant' and 'title' props for configuration. ```javascript Great for quick tips, best practices, or suggestions. ``` -------------------------------- ### Importing Prose UI CSS Styles (CSS) Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/how-it-works.mdx Shows how to import the main Prose UI stylesheet and KaTeX stylesheet into your Next.js 'globals.css' file. The KaTeX import is only needed for math formula rendering. ```css @import '@prose-ui/next/prose-ui.css'; @import '@prose-ui/next/katex.min.css'; ``` -------------------------------- ### Display Local Image with Markdown Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/components/image.mdx Renders a local image using standard Markdown syntax. Assumes images are in the `public` folder by default. No resizing or alignment options are available with this basic syntax. ```markdown ![Abstract art](/img/demo-image.png) ``` -------------------------------- ### JSX: Tip Callout Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/components/callout.mdx Renders a 'tip' variant of the Callout component, offering helpful advice or recommendations to users. It provides useful suggestions or shortcuts to enhance their experience. Requires 'variant' and 'title' props. ```jsx The tip callout is used to offer helpful advice or recommendations. It provides users with useful suggestions or shortcuts that can enhance their experience. ``` -------------------------------- ### Importing MDX Components from Prose UI (JavaScript) Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/how-it-works.mdx This snippet shows how to import the mdxComponents array from the '@prose-ui/next' package, which contains React server components for rendering various Markdown elements. ```javascript import { mdxComponents } from "@prose-ui/next" ``` -------------------------------- ### Configure remarkPlugins for MDX Transformation | Prose UI Source: https://context7.com/vrepsys/prose-ui/llms.txt This snippet shows how to use the `remarkPlugins` function from `@prose-ui/core` to configure remark plugins for MDX compilation. It demonstrates basic usage with default options and advanced usage with custom configurations for link URL mapping, image processing, and math rendering. ```typescript import { remarkPlugins } from '@prose-ui/core' import { compile } from '@mdx-js/mdx' // Basic usage with default options const mdxContent = await compile(markdownSource, { remarkPlugins: remarkPlugins(), }) // Advanced usage with custom configuration const mdxContent = await compile(markdownSource, { remarkPlugins: remarkPlugins({ link: { mapUrl: (url) => url.startsWith('/docs') ? `/v2${url}` : url }, image: { imageDir: './public', basePath: '/static' }, math: { singleDollarTextMath: false } }), }) ``` -------------------------------- ### Importing Remark Plugins from Prose UI (TypeScript) Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/how-it-works.mdx Illustrates importing the remarkPlugins function from the '@prose-ui/core' package. This function generates remark plugins for enhanced Markdown processing. ```typescript import { remarkPlugins } from '@prose-ui/core' ``` -------------------------------- ### CodeBlock Component for Syntax Highlighting Source: https://context7.com/vrepsys/prose-ui/llms.txt Renders syntax-highlighted code blocks using Shiki, supporting customizable themes and line numbers. It can be used directly as a component or utilized via the `codeToHtml` function for custom rendering. ```typescript import { CodeBlock, codeToHtml } from '@prose-ui/next' // Direct component usage export default function Example() { return ( {`async function fetchUser(id: string) { const response = await fetch(`/api/users/${id}`) if (!response.ok) { throw new Error('Failed to fetch user') } return response.json() }`} ) } // Custom syntax highlighting with codeToHtml export async function CustomHighlight() { const code = 'const greeting = "Hello, World!"' const html = await codeToHtml({ code, language: 'javascript' }) return
} ``` -------------------------------- ### Import KaTeX CSS Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/components/math.mdx This CSS import is required for Prose UI to render KaTeX math formulas correctly. It should be included in your global CSS file (e.g., globals.css). ```css @import "@prose-ui/next/katex.min.css"; ``` -------------------------------- ### Displaying Info Callout with Prose UI Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/demo/callouts.mdx Demonstrates how to use the 'info' variant of the Callout component from Prose UI. This component is suitable for displaying general information or helpful insights to the user. It takes a 'variant' and 'title' prop, with the content placed within the component's children. ```javascript Use for general information or helpful insights. ``` -------------------------------- ### Process Images with remarkImage Plugin | Prose UI Source: https://context7.com/vrepsys/prose-ui/llms.txt Demonstrates the use of the `remarkImage` plugin from `@prose-ui/core/remark-image` to automatically process markdown images. This plugin extracts image dimensions and generates blur placeholders, optimizing them for Next.js Image component. It requires `unified` and `remark-parse`. ```typescript import { unified } from 'unified' import remarkParse from 'remark-parse' import remarkImage from '@prose-ui/core/remark-image' // Process markdown with automatic image optimization const processor = unified() .use(remarkParse) .use(remarkImage, { imageDir: './public', basePath: '/assets' }) // Input markdown: ![Screenshot](/images/hero.png) // Output JSX: Screenshot const result = await processor.process(markdownSource) ``` -------------------------------- ### Image Component for Next.js Optimization Source: https://context7.com/vrepsys/prose-ui/llms.txt A wrapper around Next.js's Image component, providing automatic optimization, blur placeholders, and responsive sizing. It supports automatic dimension injection and can be linked to external URLs. ```typescript import { Image } from '@prose-ui/next' // Basic usage with automatic dimensions (injected by remark-image) export function Gallery() { return ( Mountain landscape ) } // Without dimensions falls back to standard img tag export function SimpleFigure() { return (
Company logo
Our brand
) } // With link wrapper export function LinkedImage() { return ( Preview ) } ``` -------------------------------- ### JSX: Info Callout Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/components/callout.mdx Renders an 'info' variant of the Callout component, designed to attract more attention than a note for highlighting important information users should be aware of. Requires 'variant' and 'title' props. ```jsx The info callout is a blue callout designed to capture more attention from the user than a simple note. It highlights important information that users should be aware of. ``` -------------------------------- ### Align Image and Add Caption with Frame and Caption Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/docs/components/image.mdx Demonstrates using the `Frame` and `Caption` components to control image alignment (left, center, right) and add descriptive text. Requires importing `Frame` and `Caption` components. ```jsx Abstract art Left aligned image Abstract art Center aligned image Abstract art Right aligned image ``` -------------------------------- ### Displaying Warning Callout with Prose UI Source: https://github.com/vrepsys/prose-ui/blob/main/apps/website/content/demo/callouts.mdx Explains the implementation of the 'warning' variant of the Callout component in Prose UI. This variant is specifically designed to caution users about potential issues or risks. It requires 'variant' and 'title' props to be set. ```javascript Use to caution users about potential issues. ``` -------------------------------- ### MDX Components for Next.js Source: https://context7.com/vrepsys/prose-ui/llms.txt Provides pre-configured MDX components for rendering markdown content within Next.js applications using the App Router and React Server Components (RSC). It allows for extending default components with custom ones. ```typescript import { mdxComponents } from '@prose-ui/next' import { MDXRemote } from 'next-mdx-remote/rsc' // Use in Next.js App Router with RSC export default async function BlogPost({ source }) { return (
) } // Extend with custom components const customComponents = { ...mdxComponents, Video: ({ src }) =>