veslx 0.1.36 → 0.1.38
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/bin/lib/build.ts +0 -12
- package/bin/lib/export.ts +0 -12
- package/bin/lib/serve.ts +0 -13
- package/dist/client/components/footer.js +21 -0
- package/dist/client/components/footer.js.map +1 -0
- package/dist/client/components/mdx-components.js +2 -0
- package/dist/client/components/mdx-components.js.map +1 -1
- package/dist/client/components/parameter-table.js +14 -7
- package/dist/client/components/parameter-table.js.map +1 -1
- package/dist/client/components/post-list.js +7 -1
- package/dist/client/components/post-list.js.map +1 -1
- package/dist/client/hooks/use-mdx-content.js +29 -3
- package/dist/client/hooks/use-mdx-content.js.map +1 -1
- package/dist/client/lib/parameter-utils.js +1 -1
- package/dist/client/lib/parameter-utils.js.map +1 -1
- package/dist/client/package.json.js +9 -0
- package/dist/client/package.json.js.map +1 -0
- package/dist/client/pages/home.js +3 -1
- package/dist/client/pages/home.js.map +1 -1
- package/dist/client/pages/index-post.js +3 -1
- package/dist/client/pages/index-post.js.map +1 -1
- package/dist/client/pages/post.js +3 -1
- package/dist/client/pages/post.js.map +1 -1
- package/package.json +1 -1
- package/plugin/src/plugin.ts +67 -39
- package/src/components/footer.tsx +18 -0
- package/src/components/mdx-components.tsx +3 -0
- package/src/components/parameter-table.tsx +33 -25
- package/src/components/post-list.tsx +14 -1
- package/src/hooks/use-mdx-content.ts +54 -14
- package/src/lib/parameter-utils.ts +1 -1
- package/src/pages/home.tsx +2 -0
- package/src/pages/index-post.tsx +5 -2
- package/src/pages/post.tsx +3 -1
|
@@ -33,10 +33,10 @@ function findMdxModule(modules: ModuleMap, path: string): ModuleLoader | null {
|
|
|
33
33
|
const matchingKey = keys.find(key => {
|
|
34
34
|
// Strategy 1: Key ends with /path (e.g., @content/docs/foo.mdx matches docs/foo.mdx)
|
|
35
35
|
if (key.endsWith(`/${normalizedPath}`)) return true
|
|
36
|
-
// Strategy 2: Key equals
|
|
37
|
-
if (key === `@content/${normalizedPath}`) return true
|
|
38
|
-
// Strategy 3: Key equals /@content/path (with leading slash)
|
|
36
|
+
// Strategy 2: Key equals /@content/path (Vite alias resolution)
|
|
39
37
|
if (key === `/@content/${normalizedPath}`) return true
|
|
38
|
+
// Strategy 3: Key equals @content/path (alias form)
|
|
39
|
+
if (key === `@content/${normalizedPath}`) return true
|
|
40
40
|
// Strategy 4: Key equals path directly
|
|
41
41
|
if (key === normalizedPath) return true
|
|
42
42
|
// Strategy 5: Key equals /path (with leading slash)
|
|
@@ -63,6 +63,7 @@ function findMdxModule(modules: ModuleMap, path: string): ModuleLoader | null {
|
|
|
63
63
|
for (const candidate of candidates) {
|
|
64
64
|
const matchingKey = keys.find(key => {
|
|
65
65
|
if (key.endsWith(`/${candidate}`)) return true
|
|
66
|
+
if (key === `/@content/${candidate}`) return true
|
|
66
67
|
if (key === `@content/${candidate}`) return true
|
|
67
68
|
if (key === candidate) return true
|
|
68
69
|
return false
|
|
@@ -136,10 +137,10 @@ function findSlidesModule(modules: ModuleMap, path: string): ModuleLoader | null
|
|
|
136
137
|
const matchingKey = keys.find(key => {
|
|
137
138
|
// Strategy 1: Key ends with /path (e.g., @content/docs/foo.slides.mdx matches docs/foo.slides.mdx)
|
|
138
139
|
if (key.endsWith(`/${normalizedPath}`)) return true
|
|
139
|
-
// Strategy 2: Key equals
|
|
140
|
-
if (key === `@content/${normalizedPath}`) return true
|
|
141
|
-
// Strategy 3: Key equals /@content/path (with leading slash)
|
|
140
|
+
// Strategy 2: Key equals /@content/path (Vite alias resolution)
|
|
142
141
|
if (key === `/@content/${normalizedPath}`) return true
|
|
142
|
+
// Strategy 3: Key equals @content/path (alias form)
|
|
143
|
+
if (key === `@content/${normalizedPath}`) return true
|
|
143
144
|
// Strategy 4: Key equals path directly
|
|
144
145
|
if (key === normalizedPath) return true
|
|
145
146
|
// Strategy 5: Key equals /path (with leading slash)
|
|
@@ -163,6 +164,7 @@ function findSlidesModule(modules: ModuleMap, path: string): ModuleLoader | null
|
|
|
163
164
|
for (const candidate of candidates) {
|
|
164
165
|
const matchingKey = keys.find(key => {
|
|
165
166
|
if (key.endsWith(`/${candidate}`)) return true
|
|
167
|
+
if (key === `/@content/${candidate}`) return true
|
|
166
168
|
if (key === `@content/${candidate}`) return true
|
|
167
169
|
if (key === candidate) return true
|
|
168
170
|
return false
|
|
@@ -222,23 +224,60 @@ export function useMDXSlides(path: string) {
|
|
|
222
224
|
}
|
|
223
225
|
|
|
224
226
|
/**
|
|
225
|
-
* Find
|
|
227
|
+
* Find index.mdx, index.md, README.mdx, or README.md in a directory.
|
|
228
|
+
* Checks index files first, then README files.
|
|
226
229
|
*/
|
|
227
230
|
function findIndexModule(modules: ModuleMap, path: string): ModuleLoader | null {
|
|
228
231
|
const keys = Object.keys(modules)
|
|
229
232
|
|
|
230
233
|
// Normalize path - remove leading slash, handle root
|
|
231
234
|
const normalizedPath = path.replace(/^\//, '') || '.'
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
const isRoot = normalizedPath === '.' || normalizedPath === ''
|
|
236
|
+
|
|
237
|
+
// Debug: log keys and path
|
|
238
|
+
console.log('[findIndexModule] path:', path, 'normalizedPath:', normalizedPath, 'isRoot:', isRoot)
|
|
239
|
+
console.log('[findIndexModule] ALL keys:', keys)
|
|
240
|
+
|
|
241
|
+
// Look for index files first, then README files
|
|
242
|
+
const candidates = isRoot
|
|
243
|
+
? ['index.mdx', 'index.md', 'README.mdx', 'README.md']
|
|
244
|
+
: [
|
|
245
|
+
`${normalizedPath}/index.mdx`,
|
|
246
|
+
`${normalizedPath}/index.md`,
|
|
247
|
+
`${normalizedPath}/README.mdx`,
|
|
248
|
+
`${normalizedPath}/README.md`,
|
|
249
|
+
]
|
|
237
250
|
|
|
238
251
|
for (const candidate of candidates) {
|
|
239
252
|
const matchingKey = keys.find(key => {
|
|
253
|
+
// For root-level files, match keys that end with /candidate but DON'T have additional path segments
|
|
254
|
+
// e.g., for README.mdx: match "/../content/README.mdx" but not "/../content/subdir/README.mdx"
|
|
255
|
+
if (isRoot) {
|
|
256
|
+
// Key must end with /candidate and have no additional path segments before the filename
|
|
257
|
+
// Extract the filename from the key and compare
|
|
258
|
+
const keyFilename = key.split('/').pop()
|
|
259
|
+
if (keyFilename === candidate) {
|
|
260
|
+
// Make sure it's in the root of content dir, not a subdirectory
|
|
261
|
+
// Count path segments after the content directory marker
|
|
262
|
+
// Keys look like: /../pinglab/content/README.mdx or @content/README.mdx
|
|
263
|
+
const parts = key.split('/')
|
|
264
|
+
const contentIdx = parts.findIndex(p => p === 'content' || p === '@content')
|
|
265
|
+
if (contentIdx !== -1) {
|
|
266
|
+
// If there's only one segment after "content", it's a root file
|
|
267
|
+
const afterContent = parts.slice(contentIdx + 1)
|
|
268
|
+
if (afterContent.length === 1) return true
|
|
269
|
+
}
|
|
270
|
+
// Also try @content prefix matching
|
|
271
|
+
if (key === `/@content/${candidate}`) return true
|
|
272
|
+
if (key === `@content/${candidate}`) return true
|
|
273
|
+
}
|
|
274
|
+
return false
|
|
275
|
+
}
|
|
276
|
+
// For subdirectories, allow endsWith matching
|
|
240
277
|
if (key.endsWith(`/${candidate}`)) return true
|
|
278
|
+
if (key === `/@content/${candidate}`) return true
|
|
241
279
|
if (key === `@content/${candidate}`) return true
|
|
280
|
+
if (key === `/content/${candidate}`) return true
|
|
242
281
|
if (key === candidate) return true
|
|
243
282
|
return false
|
|
244
283
|
})
|
|
@@ -251,8 +290,9 @@ function findIndexModule(modules: ModuleMap, path: string): ModuleLoader | null
|
|
|
251
290
|
}
|
|
252
291
|
|
|
253
292
|
/**
|
|
254
|
-
* Hook for loading index.mdx/index.md
|
|
255
|
-
*
|
|
293
|
+
* Hook for loading index.mdx/index.md or README.mdx/README.md content.
|
|
294
|
+
* Checks for index files first, then README files.
|
|
295
|
+
* Returns notFound: true if no matching file exists (instead of throwing an error).
|
|
256
296
|
*/
|
|
257
297
|
export function useIndexContent(path: string) {
|
|
258
298
|
const [Content, setContent] = useState<MDXModule['default'] | null>(null)
|
|
@@ -86,7 +86,7 @@ export function formatNumber(value: number): string {
|
|
|
86
86
|
if (Math.abs(value) < 0.0001 && value !== 0) return value.toExponential(1);
|
|
87
87
|
if (Math.abs(value) >= 10000) return value.toExponential(1);
|
|
88
88
|
if (Number.isInteger(value)) return value.toString();
|
|
89
|
-
return value.toFixed(
|
|
89
|
+
return value.toFixed(3);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export function formatValue(value: ParameterValue): string {
|
package/src/pages/home.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useParams } from "react-router-dom"
|
|
2
2
|
import { PostList } from "@/components/post-list";
|
|
3
3
|
import { Header } from "@/components/header";
|
|
4
|
+
import { Footer } from "@/components/footer";
|
|
4
5
|
import veslxConfig from "virtual:veslx-config";
|
|
5
6
|
|
|
6
7
|
export function Home() {
|
|
@@ -44,6 +45,7 @@ export function Home() {
|
|
|
44
45
|
</div>
|
|
45
46
|
</div>
|
|
46
47
|
</main>
|
|
48
|
+
<Footer />
|
|
47
49
|
</main>
|
|
48
50
|
</div>
|
|
49
51
|
)
|
package/src/pages/index-post.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { useParams } from "react-router-dom";
|
|
|
3
3
|
import { isSimulationRunning } from "../../plugin/src/client";
|
|
4
4
|
import Loading from "@/components/loading";
|
|
5
5
|
import { Header } from "@/components/header";
|
|
6
|
+
import { Footer } from "@/components/footer";
|
|
6
7
|
import { useIndexContent } from "@/hooks/use-mdx-content";
|
|
7
8
|
import { mdxComponents } from "@/components/mdx-components";
|
|
8
9
|
import { FrontmatterProvider } from "@/lib/frontmatter-context";
|
|
@@ -12,8 +13,9 @@ interface IndexPostProps {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
|
-
* Attempts to render an index.mdx or
|
|
16
|
-
*
|
|
16
|
+
* Attempts to render an index.mdx, index.md, README.mdx, or README.md file for a directory.
|
|
17
|
+
* Checks for index files first, then README files.
|
|
18
|
+
* Falls back to the provided component if no matching file exists.
|
|
17
19
|
*/
|
|
18
20
|
export function IndexPost({ fallback }: IndexPostProps) {
|
|
19
21
|
const { "*": rawPath = "." } = useParams();
|
|
@@ -53,6 +55,7 @@ export function IndexPost({ fallback }: IndexPostProps) {
|
|
|
53
55
|
</article>
|
|
54
56
|
</FrontmatterProvider>
|
|
55
57
|
)}
|
|
58
|
+
<Footer />
|
|
56
59
|
</main>
|
|
57
60
|
</div>
|
|
58
61
|
)
|
package/src/pages/post.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { findSlides, isSimulationRunning, useDirectory } from "../../plugin/src/
|
|
|
3
3
|
import Loading from "@/components/loading";
|
|
4
4
|
import { FileEntry } from "plugin/src/lib";
|
|
5
5
|
import { Header } from "@/components/header";
|
|
6
|
+
import { Footer } from "@/components/footer";
|
|
6
7
|
import { useMDXContent } from "@/hooks/use-mdx-content";
|
|
7
8
|
import { mdxComponents } from "@/components/mdx-components";
|
|
8
9
|
import { FrontmatterProvider } from "@/lib/frontmatter-context";
|
|
@@ -54,11 +55,12 @@ export function Post() {
|
|
|
54
55
|
|
|
55
56
|
{Content && (
|
|
56
57
|
<FrontmatterProvider frontmatter={frontmatter}>
|
|
57
|
-
<article className="mt-12 mb-
|
|
58
|
+
<article className="mt-12 mb-32 mx-auto px-[var(--page-padding)] max-w-[var(--content-width)] animate-fade-in">
|
|
58
59
|
<Content components={mdxComponents} />
|
|
59
60
|
</article>
|
|
60
61
|
</FrontmatterProvider>
|
|
61
62
|
)}
|
|
63
|
+
<Footer />
|
|
62
64
|
</main>
|
|
63
65
|
</div>
|
|
64
66
|
)
|