veslx 0.1.14 → 0.1.15
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/README.md +262 -55
- package/bin/lib/build.ts +65 -13
- package/bin/lib/import-config.ts +10 -9
- package/bin/lib/init.ts +21 -22
- package/bin/lib/serve.ts +66 -12
- package/bin/veslx.ts +2 -2
- package/dist/client/App.js +3 -9
- package/dist/client/App.js.map +1 -1
- package/dist/client/components/front-matter.js +11 -25
- package/dist/client/components/front-matter.js.map +1 -1
- package/dist/client/components/gallery/components/figure-caption.js +6 -4
- package/dist/client/components/gallery/components/figure-caption.js.map +1 -1
- package/dist/client/components/gallery/components/figure-header.js +3 -3
- package/dist/client/components/gallery/components/figure-header.js.map +1 -1
- package/dist/client/components/gallery/components/lightbox.js +13 -13
- package/dist/client/components/gallery/components/lightbox.js.map +1 -1
- package/dist/client/components/gallery/components/loading-image.js +11 -10
- package/dist/client/components/gallery/components/loading-image.js.map +1 -1
- package/dist/client/components/gallery/hooks/use-gallery-images.js +31 -7
- package/dist/client/components/gallery/hooks/use-gallery-images.js.map +1 -1
- package/dist/client/components/gallery/index.js +22 -15
- package/dist/client/components/gallery/index.js.map +1 -1
- package/dist/client/components/header.js +5 -3
- package/dist/client/components/header.js.map +1 -1
- package/dist/client/components/mdx-components.js +42 -8
- package/dist/client/components/mdx-components.js.map +1 -1
- package/dist/client/components/post-list.js +97 -90
- package/dist/client/components/post-list.js.map +1 -1
- package/dist/client/components/running-bar.js +1 -1
- package/dist/client/components/running-bar.js.map +1 -1
- package/dist/client/components/slide.js +18 -0
- package/dist/client/components/slide.js.map +1 -0
- package/dist/client/components/slides-renderer.js +7 -71
- package/dist/client/components/slides-renderer.js.map +1 -1
- package/dist/client/hooks/use-mdx-content.js +55 -9
- package/dist/client/hooks/use-mdx-content.js.map +1 -1
- package/dist/client/main.js +1 -0
- package/dist/client/main.js.map +1 -1
- package/dist/client/pages/content-router.js +19 -0
- package/dist/client/pages/content-router.js.map +1 -0
- package/dist/client/pages/home.js +11 -7
- package/dist/client/pages/home.js.map +1 -1
- package/dist/client/pages/post.js +8 -20
- package/dist/client/pages/post.js.map +1 -1
- package/dist/client/pages/slides.js +62 -86
- package/dist/client/pages/slides.js.map +1 -1
- package/dist/client/plugin/src/client.js +58 -96
- package/dist/client/plugin/src/client.js.map +1 -1
- package/dist/client/plugin/src/directory-tree.js +111 -0
- package/dist/client/plugin/src/directory-tree.js.map +1 -0
- package/index.html +1 -1
- package/package.json +27 -15
- package/plugin/src/client.tsx +64 -116
- package/plugin/src/directory-tree.ts +171 -0
- package/plugin/src/lib.ts +6 -249
- package/plugin/src/plugin.ts +93 -50
- package/plugin/src/remark-slides.ts +100 -0
- package/plugin/src/types.ts +22 -0
- package/src/App.tsx +3 -6
- package/src/components/front-matter.tsx +14 -29
- package/src/components/gallery/components/figure-caption.tsx +15 -7
- package/src/components/gallery/components/figure-header.tsx +3 -3
- package/src/components/gallery/components/lightbox.tsx +15 -13
- package/src/components/gallery/components/loading-image.tsx +15 -12
- package/src/components/gallery/hooks/use-gallery-images.ts +51 -10
- package/src/components/gallery/index.tsx +32 -26
- package/src/components/header.tsx +14 -9
- package/src/components/mdx-components.tsx +61 -8
- package/src/components/post-list.tsx +149 -115
- package/src/components/running-bar.tsx +1 -1
- package/src/components/slide.tsx +22 -5
- package/src/components/slides-renderer.tsx +7 -115
- package/src/components/welcome.tsx +11 -14
- package/src/hooks/use-mdx-content.ts +94 -9
- package/src/index.css +159 -0
- package/src/main.tsx +1 -0
- package/src/pages/content-router.tsx +27 -0
- package/src/pages/home.tsx +16 -2
- package/src/pages/post.tsx +10 -13
- package/src/pages/slides.tsx +75 -88
- package/src/vite-env.d.ts +7 -17
- package/vite.config.ts +25 -6
|
@@ -1,7 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
import { Link, useLocation } from 'react-router-dom'
|
|
2
2
|
import Gallery from '@/components/gallery'
|
|
3
3
|
import { ParameterTable } from '@/components/parameter-table'
|
|
4
4
|
import { ParameterBadge } from '@/components/parameter-badge'
|
|
5
|
+
import { FrontMatter } from './front-matter'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Smart link component that uses React Router for internal links
|
|
9
|
+
* and regular anchor tags for external links.
|
|
10
|
+
*/
|
|
11
|
+
function SmartLink({ href, children, ...props }: React.AnchorHTMLAttributes<HTMLAnchorElement>) {
|
|
12
|
+
const location = useLocation()
|
|
13
|
+
|
|
14
|
+
// External links: absolute URLs, mailto, tel, etc.
|
|
15
|
+
const isExternal = href?.startsWith('http') || href?.startsWith('mailto:') || href?.startsWith('tel:')
|
|
16
|
+
|
|
17
|
+
// Hash-only links stay as anchors for in-page navigation
|
|
18
|
+
const isHashOnly = href?.startsWith('#')
|
|
19
|
+
|
|
20
|
+
if (isExternal || isHashOnly || !href) {
|
|
21
|
+
return (
|
|
22
|
+
<a
|
|
23
|
+
href={href}
|
|
24
|
+
className="text-primary hover:underline underline-offset-2"
|
|
25
|
+
{...(isExternal ? { target: '_blank', rel: 'noopener noreferrer' } : {})}
|
|
26
|
+
{...props}
|
|
27
|
+
>
|
|
28
|
+
{children}
|
|
29
|
+
</a>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Resolve relative paths (./foo.mdx, ../bar.mdx) against current location
|
|
34
|
+
let resolvedHref = href
|
|
35
|
+
if (href.startsWith('./') || href.startsWith('../')) {
|
|
36
|
+
// Get current directory from pathname
|
|
37
|
+
const currentPath = location.pathname
|
|
38
|
+
const currentDir = currentPath.replace(/\/[^/]+\.mdx$/, '') || currentPath.replace(/\/[^/]*$/, '') || '/'
|
|
39
|
+
|
|
40
|
+
// Simple relative path resolution
|
|
41
|
+
if (href.startsWith('./')) {
|
|
42
|
+
resolvedHref = `${currentDir}/${href.slice(2)}`.replace(/\/+/g, '/')
|
|
43
|
+
} else if (href.startsWith('../')) {
|
|
44
|
+
const parentDir = currentDir.replace(/\/[^/]+$/, '') || '/'
|
|
45
|
+
resolvedHref = `${parentDir}/${href.slice(3)}`.replace(/\/+/g, '/')
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Internal link - use React Router Link
|
|
50
|
+
return (
|
|
51
|
+
<Link
|
|
52
|
+
to={resolvedHref}
|
|
53
|
+
className="text-primary hover:underline underline-offset-2"
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
{children}
|
|
57
|
+
</Link>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
5
60
|
|
|
6
61
|
function generateId(children: unknown): string {
|
|
7
62
|
return children
|
|
@@ -13,6 +68,9 @@ function generateId(children: unknown): string {
|
|
|
13
68
|
|
|
14
69
|
// Shared MDX components - lab notebook / coder aesthetic
|
|
15
70
|
export const mdxComponents = {
|
|
71
|
+
|
|
72
|
+
FrontMatter,
|
|
73
|
+
|
|
16
74
|
Gallery,
|
|
17
75
|
|
|
18
76
|
ParameterTable,
|
|
@@ -110,13 +168,8 @@ export const mdxComponents = {
|
|
|
110
168
|
<li className="mt-1.5" {...props} />
|
|
111
169
|
),
|
|
112
170
|
|
|
113
|
-
// Links
|
|
114
|
-
a:
|
|
115
|
-
<a
|
|
116
|
-
className="text-primary hover:underline underline-offset-2"
|
|
117
|
-
{...props}
|
|
118
|
-
/>
|
|
119
|
-
),
|
|
171
|
+
// Links - uses React Router for internal navigation
|
|
172
|
+
a: SmartLink,
|
|
120
173
|
|
|
121
174
|
// Tables
|
|
122
175
|
table: (props: React.TableHTMLAttributes<HTMLTableElement>) => (
|
|
@@ -1,14 +1,64 @@
|
|
|
1
1
|
import { Link } from "react-router-dom";
|
|
2
2
|
import { cn } from "@/lib/utils";
|
|
3
|
-
import { DirectoryEntry } from "../../plugin/src/lib";
|
|
4
|
-
import { findReadme, findSlides } from "../../plugin/src/client";
|
|
3
|
+
import { DirectoryEntry, FileEntry } from "../../plugin/src/lib";
|
|
4
|
+
import { findReadme, findSlides, findMdxFiles } from "../../plugin/src/client";
|
|
5
5
|
import { formatDate } from "@/lib/format-date";
|
|
6
6
|
import { ArrowRight } from "lucide-react";
|
|
7
7
|
|
|
8
|
+
type PostEntry = {
|
|
9
|
+
type: 'folder' | 'file';
|
|
10
|
+
name: string;
|
|
11
|
+
path: string;
|
|
12
|
+
readme: FileEntry | null;
|
|
13
|
+
slides: FileEntry | null;
|
|
14
|
+
file: FileEntry | null; // For standalone MDX files
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Helper to extract numeric prefix from filename (e.g., "01-intro" → 1)
|
|
18
|
+
function extractOrder(name: string): number | null {
|
|
19
|
+
const match = name.match(/^(\d+)-/);
|
|
20
|
+
return match ? parseInt(match[1], 10) : null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Helper to strip numeric prefix for display (e.g., "01-getting-started" → "Getting Started")
|
|
24
|
+
function stripNumericPrefix(name: string): string {
|
|
25
|
+
return name
|
|
26
|
+
.replace(/^\d+-/, '')
|
|
27
|
+
.replace(/-/g, ' ')
|
|
28
|
+
.replace(/\b\w/g, c => c.toUpperCase());
|
|
29
|
+
}
|
|
30
|
+
|
|
8
31
|
export default function PostList({ directory }: { directory: DirectoryEntry }) {
|
|
9
32
|
const folders = directory.children.filter((c): c is DirectoryEntry => c.type === "directory");
|
|
33
|
+
const standaloneFiles = findMdxFiles(directory);
|
|
34
|
+
|
|
35
|
+
// Convert folders to post entries
|
|
36
|
+
const folderPosts: PostEntry[] = folders.map((folder) => {
|
|
37
|
+
const readme = findReadme(folder);
|
|
38
|
+
const slides = findSlides(folder);
|
|
39
|
+
return {
|
|
40
|
+
type: 'folder' as const,
|
|
41
|
+
name: folder.name,
|
|
42
|
+
path: folder.path,
|
|
43
|
+
readme,
|
|
44
|
+
slides,
|
|
45
|
+
file: null,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
10
48
|
|
|
11
|
-
|
|
49
|
+
// Convert standalone MDX files to post entries
|
|
50
|
+
const filePosts: PostEntry[] = standaloneFiles.map((file) => ({
|
|
51
|
+
type: 'file' as const,
|
|
52
|
+
name: file.name.replace(/\.mdx?$/, ''),
|
|
53
|
+
path: file.path,
|
|
54
|
+
readme: null,
|
|
55
|
+
slides: null,
|
|
56
|
+
file,
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
let posts: PostEntry[] = [...folderPosts, ...filePosts];
|
|
60
|
+
|
|
61
|
+
if (posts.length === 0) {
|
|
12
62
|
return (
|
|
13
63
|
<div className="py-24 text-center">
|
|
14
64
|
<p className="text-muted-foreground font-mono text-sm tracking-wide">no entries</p>
|
|
@@ -16,133 +66,117 @@ export default function PostList({ directory }: { directory: DirectoryEntry }) {
|
|
|
16
66
|
);
|
|
17
67
|
}
|
|
18
68
|
|
|
19
|
-
|
|
20
|
-
const readme = findReadme(folder);
|
|
21
|
-
const slides = findSlides(folder);
|
|
22
|
-
return {
|
|
23
|
-
...folder,
|
|
24
|
-
readme,
|
|
25
|
-
slides,
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
|
|
69
|
+
// Filter out hidden and draft posts
|
|
29
70
|
posts = posts.filter((post) => {
|
|
30
|
-
|
|
71
|
+
const frontmatter = post.readme?.frontmatter || post.file?.frontmatter;
|
|
72
|
+
return frontmatter?.visibility !== "hidden" && frontmatter?.draft !== true;
|
|
31
73
|
});
|
|
32
74
|
|
|
75
|
+
// Helper to get frontmatter from post
|
|
76
|
+
const getFrontmatter = (post: PostEntry) => {
|
|
77
|
+
return post.readme?.frontmatter || post.file?.frontmatter || post.slides?.frontmatter;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Helper to get date from post
|
|
81
|
+
const getPostDate = (post: PostEntry): Date | null => {
|
|
82
|
+
const frontmatter = getFrontmatter(post);
|
|
83
|
+
return frontmatter?.date ? new Date(frontmatter.date as string) : null;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Smart sorting: numeric prefix → date → alphabetical
|
|
33
87
|
posts = posts.sort((a, b) => {
|
|
34
|
-
|
|
35
|
-
|
|
88
|
+
const aOrder = extractOrder(a.name);
|
|
89
|
+
const bOrder = extractOrder(b.name);
|
|
90
|
+
const aDate = getPostDate(a);
|
|
91
|
+
const bDate = getPostDate(b);
|
|
36
92
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!bDate && b.slides) {
|
|
41
|
-
bDate = b.slides.frontmatter?.date ? new Date(b.slides.frontmatter.date as string) : null;
|
|
93
|
+
// Both have numeric prefix → sort by number
|
|
94
|
+
if (aOrder !== null && bOrder !== null) {
|
|
95
|
+
return aOrder - bOrder;
|
|
42
96
|
}
|
|
97
|
+
// One has prefix, one doesn't → prefixed comes first
|
|
98
|
+
if (aOrder !== null) return -1;
|
|
99
|
+
if (bOrder !== null) return 1;
|
|
43
100
|
|
|
101
|
+
// Both have dates → sort by date (newest first)
|
|
44
102
|
if (aDate && bDate) {
|
|
45
103
|
return bDate.getTime() - aDate.getTime();
|
|
46
|
-
} else if (aDate) {
|
|
47
|
-
return -1;
|
|
48
|
-
} else if (bDate) {
|
|
49
|
-
return 1;
|
|
50
|
-
} else {
|
|
51
|
-
return a.name.localeCompare(b.name);
|
|
52
104
|
}
|
|
53
|
-
|
|
105
|
+
// One has date → dated comes first
|
|
106
|
+
if (aDate) return -1;
|
|
107
|
+
if (bDate) return 1;
|
|
54
108
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
date = post.slides.frontmatter?.date ? new Date(post.slides.frontmatter.date as string) : null;
|
|
60
|
-
}
|
|
61
|
-
const monthYear = date ? `${date.getFullYear()}-${date.getMonth() + 1}` : "unknown";
|
|
62
|
-
if (!postsGroupedByMonthAndYear[monthYear]) {
|
|
63
|
-
postsGroupedByMonthAndYear[monthYear] = [];
|
|
64
|
-
}
|
|
65
|
-
postsGroupedByMonthAndYear[monthYear].push(post);
|
|
109
|
+
// Neither → alphabetical by title
|
|
110
|
+
const aTitle = (getFrontmatter(a)?.title as string) || a.name;
|
|
111
|
+
const bTitle = (getFrontmatter(b)?.title as string) || b.name;
|
|
112
|
+
return aTitle.localeCompare(bTitle);
|
|
66
113
|
});
|
|
67
114
|
|
|
68
115
|
return (
|
|
69
|
-
<div className="space-y-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
<span>{title}</span>
|
|
129
|
-
<ArrowRight className="h-3 w-3 opacity-0 -translate-x-1 group-hover:opacity-100 group-hover:translate-x-0 transition-all duration-200 text-primary" />
|
|
130
|
-
</h3>
|
|
131
|
-
|
|
132
|
-
{description && (
|
|
133
|
-
<p className="text-sm text-muted-foreground line-clamp-1 mt-0.5">
|
|
134
|
-
{description}
|
|
135
|
-
</p>
|
|
136
|
-
)}
|
|
137
|
-
</div>
|
|
138
|
-
</article>
|
|
139
|
-
</Link>
|
|
140
|
-
);
|
|
141
|
-
})}
|
|
116
|
+
<div className="space-y-1">
|
|
117
|
+
{posts.map((post) => {
|
|
118
|
+
const frontmatter = getFrontmatter(post);
|
|
119
|
+
|
|
120
|
+
// Title: explicit frontmatter > stripped numeric prefix > raw name
|
|
121
|
+
const title = (frontmatter?.title as string) || stripNumericPrefix(post.name);
|
|
122
|
+
const description = frontmatter?.description as string | undefined;
|
|
123
|
+
const date = frontmatter?.date ? new Date(frontmatter.date as string) : null;
|
|
124
|
+
|
|
125
|
+
// Determine the link path
|
|
126
|
+
let linkPath: string;
|
|
127
|
+
if (post.file) {
|
|
128
|
+
// Standalone MDX file
|
|
129
|
+
linkPath = `/${post.file.path}`;
|
|
130
|
+
} else if (post.slides && !post.readme) {
|
|
131
|
+
// Folder with only slides
|
|
132
|
+
linkPath = `/${post.slides.path}`;
|
|
133
|
+
} else if (post.readme) {
|
|
134
|
+
// Folder with readme
|
|
135
|
+
linkPath = `/${post.readme.path}`;
|
|
136
|
+
} else {
|
|
137
|
+
// Fallback to folder path
|
|
138
|
+
linkPath = `/${post.path}`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<Link
|
|
143
|
+
key={post.path}
|
|
144
|
+
to={linkPath}
|
|
145
|
+
className={cn(
|
|
146
|
+
"group block py-3 px-3 -mx-3 rounded-md",
|
|
147
|
+
"transition-colors duration-150",
|
|
148
|
+
)}
|
|
149
|
+
>
|
|
150
|
+
<article className="flex items-start gap-4">
|
|
151
|
+
{/* Date - left side, fixed width */}
|
|
152
|
+
<time
|
|
153
|
+
dateTime={date?.toISOString()}
|
|
154
|
+
className="font-mono text-xs text-muted-foreground tabular-nums w-20 flex-shrink-0 pt-0.5"
|
|
155
|
+
>
|
|
156
|
+
{date ? formatDate(date) : <span className="text-muted-foreground/30">—</span>}
|
|
157
|
+
</time>
|
|
158
|
+
|
|
159
|
+
{/* Main content */}
|
|
160
|
+
<div className="flex-1 min-w-0">
|
|
161
|
+
<h3 className={cn(
|
|
162
|
+
"text-sm font-medium text-foreground",
|
|
163
|
+
"group-hover:underline",
|
|
164
|
+
"flex items-center gap-2"
|
|
165
|
+
)}>
|
|
166
|
+
<span>{title}</span>
|
|
167
|
+
<ArrowRight className="h-3 w-3 opacity-0 -translate-x-1 group-hover:opacity-100 group-hover:translate-x-0 transition-all duration-200 text-primary" />
|
|
168
|
+
</h3>
|
|
169
|
+
|
|
170
|
+
{description && (
|
|
171
|
+
<p className="text-sm text-muted-foreground line-clamp-1 mt-0.5">
|
|
172
|
+
{description}
|
|
173
|
+
</p>
|
|
174
|
+
)}
|
|
142
175
|
</div>
|
|
143
|
-
</
|
|
144
|
-
|
|
145
|
-
|
|
176
|
+
</article>
|
|
177
|
+
</Link>
|
|
178
|
+
);
|
|
179
|
+
})}
|
|
146
180
|
</div>
|
|
147
181
|
);
|
|
148
182
|
}
|
|
@@ -8,7 +8,7 @@ export function RunningBar() {
|
|
|
8
8
|
<>
|
|
9
9
|
{isRunning && (
|
|
10
10
|
// this should stay red not another color
|
|
11
|
-
<div className="sticky top-0 z-50 px-[var(--page-padding)] py-2 bg-red-500 text-primary-foreground font-mono text-xs text-center tracking-wide">
|
|
11
|
+
<div className="running-bar sticky top-0 z-50 px-[var(--page-padding)] py-2 bg-red-500 text-primary-foreground font-mono text-xs text-center tracking-wide">
|
|
12
12
|
<span className="inline-flex items-center gap-3">
|
|
13
13
|
<span className="h-1.5 w-1.5 rounded-full bg-current animate-pulse" />
|
|
14
14
|
<span className="uppercase tracking-widest">simulation running</span>
|
package/src/components/slide.tsx
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
1
2
|
|
|
3
|
+
interface SlideProps {
|
|
4
|
+
index: number
|
|
5
|
+
children: ReactNode
|
|
6
|
+
}
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Slide component - wraps slide content for stacked scrollable display.
|
|
10
|
+
* Each slide takes full viewport height.
|
|
11
|
+
*/
|
|
12
|
+
export function Slide({ index, children }: SlideProps) {
|
|
4
13
|
return (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
14
|
+
<>
|
|
15
|
+
{index > 0 && (
|
|
16
|
+
<hr className="border-t border-border w-full" />
|
|
17
|
+
)}
|
|
18
|
+
<div
|
|
19
|
+
className="slide-section min-h-screen flex items-center justify-center py-8 sm:py-12 md:py-16 px-4"
|
|
20
|
+
data-slide-index={index}
|
|
21
|
+
>
|
|
22
|
+
<div className="slide-content prose dark:prose-invert prose-headings:tracking-tight prose-p:leading-relaxed max-w-[var(--content-width)] w-full">
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
8
25
|
</div>
|
|
9
|
-
|
|
26
|
+
</>
|
|
10
27
|
)
|
|
11
28
|
}
|
|
@@ -1,127 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
2
|
import { mdxComponents } from '@/components/mdx-components'
|
|
3
|
-
|
|
4
|
-
interface SlidesRendererProps {
|
|
5
|
-
Content: React.ComponentType<{ components?: Record<string, React.ComponentType> }> | null
|
|
6
|
-
frontmatter?: {
|
|
7
|
-
title?: string
|
|
8
|
-
description?: string
|
|
9
|
-
date?: string
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Splits MDX content into slides by <hr> elements.
|
|
15
|
-
* The MDX is compiled at build time, so imports work.
|
|
16
|
-
* Slide boundaries are marked with --- in MDX (which becomes <hr>).
|
|
17
|
-
*/
|
|
18
|
-
export function useSlidesFromMDX({ Content, frontmatter }: SlidesRendererProps) {
|
|
19
|
-
const slides = useMemo(() => {
|
|
20
|
-
// Handle null Content (loading state)
|
|
21
|
-
if (!Content) {
|
|
22
|
-
return []
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Create a custom hr component that we can detect
|
|
26
|
-
const SlideBreak = () => <hr data-slide-break="true" />
|
|
27
|
-
|
|
28
|
-
// Render the MDX with our custom hr
|
|
29
|
-
const componentsWithBreak = {
|
|
30
|
-
...mdxComponents,
|
|
31
|
-
hr: SlideBreak,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Render to get the element tree
|
|
35
|
-
const rendered = <Content components={componentsWithBreak} />
|
|
36
|
-
|
|
37
|
-
// Split children by hr elements
|
|
38
|
-
return splitByHr(rendered)
|
|
39
|
-
}, [Content])
|
|
40
|
-
|
|
41
|
-
return { slides, frontmatter }
|
|
42
|
-
}
|
|
3
|
+
import { Slide } from '@/components/slide'
|
|
43
4
|
|
|
44
5
|
/**
|
|
45
|
-
*
|
|
6
|
+
* MDX components for slides - includes the Slide component
|
|
46
7
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
function traverse(node: ReactNode) {
|
|
51
|
-
if (!node) return
|
|
52
|
-
|
|
53
|
-
if (Array.isArray(node)) {
|
|
54
|
-
node.forEach(traverse)
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (isValidElement(node)) {
|
|
59
|
-
// Check if this is our slide break marker
|
|
60
|
-
if (node.type === 'hr' || (node.props && node.props['data-slide-break'] === 'true')) {
|
|
61
|
-
// Start a new slide
|
|
62
|
-
slides.push([])
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Check if it's an hr component from mdxComponents
|
|
67
|
-
const nodeType = node.type as any
|
|
68
|
-
if (typeof nodeType === 'function' && nodeType.name === 'SlideBreak') {
|
|
69
|
-
slides.push([])
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// For fragments or elements with children, we need to check children
|
|
74
|
-
if (node.props?.children) {
|
|
75
|
-
const children = Children.toArray(node.props.children)
|
|
76
|
-
|
|
77
|
-
// Check if any child is an hr - if so, we need to split this element
|
|
78
|
-
const hasHrChild = children.some(child =>
|
|
79
|
-
isValidElement(child) && (
|
|
80
|
-
child.type === 'hr' ||
|
|
81
|
-
(child.props && child.props['data-slide-break'] === 'true')
|
|
82
|
-
)
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
if (hasHrChild) {
|
|
86
|
-
// Split the children
|
|
87
|
-
children.forEach(child => {
|
|
88
|
-
if (isValidElement(child) && (
|
|
89
|
-
child.type === 'hr' ||
|
|
90
|
-
(child.props && child.props['data-slide-break'] === 'true')
|
|
91
|
-
)) {
|
|
92
|
-
slides.push([])
|
|
93
|
-
} else {
|
|
94
|
-
slides[slides.length - 1].push(child)
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
} else {
|
|
98
|
-
// No hr children, add the whole element
|
|
99
|
-
slides[slides.length - 1].push(node)
|
|
100
|
-
}
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Add to current slide
|
|
106
|
-
slides[slides.length - 1].push(node)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Get the children of the rendered element
|
|
110
|
-
if (isValidElement(element) && element.props?.children) {
|
|
111
|
-
const children = Children.toArray(element.props.children)
|
|
112
|
-
children.forEach(traverse)
|
|
113
|
-
} else {
|
|
114
|
-
traverse(element)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Filter out empty slides
|
|
118
|
-
return slides.filter(slide => slide.length > 0)
|
|
8
|
+
export const slidesMdxComponents = {
|
|
9
|
+
...mdxComponents,
|
|
10
|
+
Slide,
|
|
119
11
|
}
|
|
120
12
|
|
|
121
13
|
/**
|
|
122
14
|
* Renders a single slide's content
|
|
123
15
|
*/
|
|
124
|
-
export function SlideContent({ children }: { children: ReactNode
|
|
16
|
+
export function SlideContent({ children }: { children: ReactNode }) {
|
|
125
17
|
return (
|
|
126
18
|
<div className="slide-content prose dark:prose-invert prose-headings:tracking-tight prose-p:leading-relaxed max-w-xl">
|
|
127
19
|
{children}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
+
import siteConfig from "virtual:veslx-config";
|
|
1
2
|
|
|
2
3
|
export function Welcome() {
|
|
4
|
+
const config = siteConfig;
|
|
5
|
+
|
|
3
6
|
return (
|
|
4
7
|
<div className="text-muted-foreground">
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
▐▌ ▗▄█▄▖▐▌ ▐▌▝▚▄▞▘▐▙▄▄▖▐▌ ▐▌▐▙▄▞▘
|
|
14
|
-
`}
|
|
15
|
-
</pre>
|
|
16
|
-
<div className="text-xs mt-2 font-mono">
|
|
17
|
-
PingLab is a repository for running experiments on PING Spiking Neural Networks.
|
|
18
|
-
</div>
|
|
8
|
+
<h1 className="text-xl md:text-2xl font-semibold tracking-tight text-foreground mb-2">
|
|
9
|
+
{config.name}
|
|
10
|
+
</h1>
|
|
11
|
+
{config.description && (
|
|
12
|
+
<p className="text-sm text-muted-foreground/80 font-mono">
|
|
13
|
+
{config.description}
|
|
14
|
+
</p>
|
|
15
|
+
)}
|
|
19
16
|
</div>
|
|
20
17
|
)
|
|
21
18
|
}
|