prev-cli 0.13.1 → 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
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prev-cli",
3
- "version": "0.13.1",
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