prev-cli 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -981,7 +981,7 @@ Usage:
981
981
  prev [options] Start development server
982
982
  prev build [options] Build for production
983
983
  prev preview [options] Preview production build
984
- prev create [name] Create example preview (default: "example")
984
+ prev create [name] Create preview in previews/<name>/ (default: "example")
985
985
  prev clean [options] Remove old cache directories
986
986
 
987
987
  Options:
@@ -992,13 +992,13 @@ Options:
992
992
  -h, --help Show this help message
993
993
 
994
994
  Previews:
995
- Create interactive previews in your docs by adding React components
996
- to the previews/ directory:
995
+ Previews must be in the previews/ directory at your project root.
996
+ Each preview is a subfolder with React components:
997
997
 
998
- previews/
999
- my-demo/
1000
- App.tsx # React component (entry)
1001
- styles.css # Optional CSS
998
+ previews/ # Required location
999
+ my-demo/ # Preview name (used in <Preview src="...">)
1000
+ App.tsx # React component (entry point)
1001
+ styles.css # Optional CSS
1002
1002
 
1003
1003
  Then embed in MDX:
1004
1004
  import { Preview } from '@prev/theme'
@@ -1021,6 +1021,8 @@ Previews:
1021
1021
  Previews are bundled via esbuild-wasm in dev, and pre-compiled
1022
1022
  to standalone HTML files in production builds.
1023
1023
 
1024
+ Browse all previews at /previews (Storybook-like catalog).
1025
+
1024
1026
  Examples:
1025
1027
  prev Start dev server on random port
1026
1028
  prev -p 3000 Start dev server on port 3000
@@ -1161,17 +1163,18 @@ export default function App() {
1161
1163
  writeFileSync3(path7.join(previewDir, "App.tsx"), appTsx);
1162
1164
  writeFileSync3(path7.join(previewDir, "styles.css"), stylesCss);
1163
1165
  console.log(`
1164
- ✨ Created preview: ${name}
1166
+ ✨ Created preview: previews/${name}/
1165
1167
 
1166
1168
  Files:
1167
- previews/${name}/App.tsx React component
1168
- previews/${name}/styles.css Custom styles
1169
+ previews/${name}/App.tsx React component (entry point)
1170
+ previews/${name}/styles.css Custom animations
1169
1171
 
1170
- Usage in MDX:
1172
+ Embed in your MDX:
1171
1173
  import { Preview } from '@prev/theme'
1172
1174
  <Preview src="${name}" />
1173
1175
 
1174
- Run 'prev' to start the dev server and see it in action.
1176
+ Start dev server:
1177
+ prev
1175
1178
  `);
1176
1179
  }
1177
1180
  async function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prev-cli",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Transform MDX directories into beautiful documentation websites",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -9,6 +9,8 @@ import {
9
9
  } from '@tanstack/react-router'
10
10
  import { MDXProvider } from '@mdx-js/react'
11
11
  import { pages, sidebar } from 'virtual:prev-pages'
12
+ import { previews } from 'virtual:prev-previews'
13
+ import { Preview } from './Preview'
12
14
  import { useDiagrams } from './diagrams'
13
15
  import { Layout } from './Layout'
14
16
  import { MetadataBlock } from './MetadataBlock'
@@ -83,6 +85,92 @@ function PageWrapper({ Component, meta }: { Component: React.ComponentType; meta
83
85
  )
84
86
  }
85
87
 
88
+ // Previews catalog - Storybook-like gallery
89
+ function PreviewsCatalog() {
90
+ if (!previews || previews.length === 0) {
91
+ return (
92
+ <div style={{ padding: '40px 20px', textAlign: 'center' }}>
93
+ <h1 style={{ fontSize: '24px', fontWeight: 'bold', marginBottom: '16px' }}>
94
+ No Previews Found
95
+ </h1>
96
+ <p style={{ color: '#666', marginBottom: '24px' }}>
97
+ Create your first preview with:
98
+ </p>
99
+ <code style={{
100
+ display: 'inline-block',
101
+ padding: '12px 20px',
102
+ backgroundColor: '#f4f4f5',
103
+ borderRadius: '8px',
104
+ fontFamily: 'monospace',
105
+ }}>
106
+ prev create my-demo
107
+ </code>
108
+ </div>
109
+ )
110
+ }
111
+
112
+ return (
113
+ <div style={{ padding: '20px' }}>
114
+ <div style={{ marginBottom: '32px' }}>
115
+ <h1 style={{ fontSize: '28px', fontWeight: 'bold', marginBottom: '8px' }}>
116
+ Previews
117
+ </h1>
118
+ <p style={{ color: '#666' }}>
119
+ {previews.length} component preview{previews.length !== 1 ? 's' : ''} available
120
+ </p>
121
+ </div>
122
+
123
+ <div style={{
124
+ display: 'grid',
125
+ gridTemplateColumns: 'repeat(auto-fill, minmax(400px, 1fr))',
126
+ gap: '24px',
127
+ }}>
128
+ {previews.map((preview: { name: string; route: string }) => (
129
+ <div key={preview.name} style={{
130
+ border: '1px solid #e4e4e7',
131
+ borderRadius: '12px',
132
+ overflow: 'hidden',
133
+ backgroundColor: '#fff',
134
+ }}>
135
+ <div style={{
136
+ padding: '12px 16px',
137
+ borderBottom: '1px solid #e4e4e7',
138
+ backgroundColor: '#fafafa',
139
+ }}>
140
+ <h2 style={{ fontSize: '16px', fontWeight: 600, margin: 0 }}>
141
+ {preview.name}
142
+ </h2>
143
+ <code style={{
144
+ fontSize: '12px',
145
+ color: '#666',
146
+ fontFamily: 'monospace',
147
+ }}>
148
+ previews/{preview.name}/
149
+ </code>
150
+ </div>
151
+ <Preview src={preview.name} height={300} />
152
+ </div>
153
+ ))}
154
+ </div>
155
+
156
+ <div style={{
157
+ marginTop: '40px',
158
+ padding: '16px',
159
+ backgroundColor: '#f0f9ff',
160
+ border: '1px solid #bae6fd',
161
+ borderRadius: '8px',
162
+ }}>
163
+ <p style={{ margin: 0, fontSize: '14px', color: '#0369a1' }}>
164
+ <strong>Tip:</strong> Embed any preview in your MDX docs with{' '}
165
+ <code style={{ backgroundColor: '#e0f2fe', padding: '2px 6px', borderRadius: '4px' }}>
166
+ {'<Preview src="name" />'}
167
+ </code>
168
+ </p>
169
+ </div>
170
+ </div>
171
+ )
172
+ }
173
+
86
174
  // Root layout with custom lightweight Layout
87
175
  function RootLayout() {
88
176
  const pageTree = convertToPageTree(sidebar)
@@ -101,6 +189,13 @@ const rootRoute = createRootRoute({
101
189
  component: RootLayout,
102
190
  })
103
191
 
192
+ // Previews catalog route
193
+ const previewsRoute = createRoute({
194
+ getParentRoute: () => rootRoute,
195
+ path: '/previews',
196
+ component: PreviewsCatalog,
197
+ })
198
+
104
199
  // Create routes from pages
105
200
  const pageRoutes = pages.map((page: { route: string; file: string; title?: string; description?: string; frontmatter?: Record<string, unknown> }) => {
106
201
  const Component = getPageComponent(page.file)
@@ -117,7 +212,7 @@ const pageRoutes = pages.map((page: { route: string; file: string; title?: strin
117
212
  })
118
213
 
119
214
  // Create router
120
- const routeTree = rootRoute.addChildren(pageRoutes)
215
+ const routeTree = rootRoute.addChildren([previewsRoute, ...pageRoutes])
121
216
  const router = createRouter({ routeTree })
122
217
 
123
218
  // Mount app - RouterProvider must be outermost so TanStack Router context is available