veslx 0.1.30 → 0.1.31
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 +1 -0
- package/bin/lib/export.ts +1 -0
- package/bin/lib/serve.ts +1 -0
- package/dist/client/components/post-list.js +6 -4
- package/dist/client/components/post-list.js.map +1 -1
- package/package.json +1 -1
- package/plugin/src/types.ts +2 -2
- package/src/components/post-list.tsx +7 -5
package/bin/lib/build.ts
CHANGED
package/bin/lib/export.ts
CHANGED
package/bin/lib/serve.ts
CHANGED
|
@@ -38,15 +38,17 @@ function PostList() {
|
|
|
38
38
|
return /* @__PURE__ */ jsx("div", { className: "py-24 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-muted-foreground font-mono text-sm tracking-wide", children: "no entries" }) });
|
|
39
39
|
}
|
|
40
40
|
const sortMode = ((_a = veslxConfig.posts) == null ? void 0 : _a.sort) ?? "alpha";
|
|
41
|
-
if (sortMode === "date") {
|
|
41
|
+
if (sortMode === "date" || sortMode === "date-asc") {
|
|
42
|
+
const ascending = sortMode === "date-asc";
|
|
42
43
|
posts = posts.sort((a, b) => {
|
|
43
44
|
var _a2, _b;
|
|
44
45
|
const dateA = (_a2 = getFrontmatter(a)) == null ? void 0 : _a2.date;
|
|
45
46
|
const dateB = (_b = getFrontmatter(b)) == null ? void 0 : _b.date;
|
|
46
47
|
if (!dateA && !dateB) return a.name.localeCompare(b.name);
|
|
47
|
-
if (!dateA) return 1;
|
|
48
|
-
if (!dateB) return
|
|
49
|
-
|
|
48
|
+
if (!dateA) return -1;
|
|
49
|
+
if (!dateB) return 1;
|
|
50
|
+
const diff = new Date(dateA).getTime() - new Date(dateB).getTime();
|
|
51
|
+
return ascending ? diff : -diff;
|
|
50
52
|
});
|
|
51
53
|
} else {
|
|
52
54
|
posts = posts.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-list.js","sources":["../../../src/components/post-list.tsx"],"sourcesContent":["import { useParams } from \"react-router-dom\";\nimport {\n type PostEntry,\n directoryToPostEntries,\n filterVisiblePosts,\n getFrontmatter,\n} from \"@/lib/content-classification\";\nimport { useDirectory } from \"../../plugin/src/client\";\nimport { ErrorDisplay } from \"./page-error\";\nimport Loading from \"./loading\";\nimport { PostListItem } from \"./post-list-item\";\nimport veslxConfig from \"virtual:veslx-config\";\n\n// Helper to format name for display (e.g., \"01-getting-started\" → \"Getting Started\")\nfunction formatName(name: string): string {\n return name\n .replace(/^\\d+-/, '')\n .replace(/-/g, ' ')\n .replace(/\\b\\w/g, c => c.toUpperCase());\n}\n\n// Helper to get link path from post\nfunction getLinkPath(post: PostEntry): string {\n if (post.file) {\n // Standalone MDX file\n return `/${post.file.path}`;\n } else if (post.slides && !post.readme) {\n // Folder with only slides\n return `/${post.slides.path}`;\n } else if (post.readme) {\n // Folder with readme\n return `/${post.readme.path}`;\n } else {\n // Fallback to folder path\n return `/${post.path}`;\n }\n}\n\nexport function PostList() {\n const { \"*\": path = \".\" } = useParams();\n\n const { directory, loading, error } = useDirectory(path)\n\n if (error) {\n return <ErrorDisplay error={error} path={path} />;\n }\n\n if (loading) {\n return (\n <Loading />\n )\n }\n\n if (!directory) {\n return (\n <div className=\"py-24 text-center\">\n <p className=\"text-muted-foreground font-mono text-sm tracking-wide\">no entries</p>\n </div>\n );\n }\n\n let posts = directoryToPostEntries(directory);\n\n if (posts.length === 0) {\n return (\n <div className=\"py-24 text-center\">\n <p className=\"text-muted-foreground font-mono text-sm tracking-wide\">no entries</p>\n </div>\n );\n }\n\n // Filter out hidden and draft posts\n posts = filterVisiblePosts(posts);\n\n if (posts.length === 0) {\n return (\n <div className=\"py-24 text-center\">\n <p className=\"text-muted-foreground font-mono text-sm tracking-wide\">no entries</p>\n </div>\n );\n }\n\n // Sort based on config\n const sortMode = veslxConfig.posts?.sort ?? 'alpha';\n if (sortMode === 'date') {\n // Sort by date
|
|
1
|
+
{"version":3,"file":"post-list.js","sources":["../../../src/components/post-list.tsx"],"sourcesContent":["import { useParams } from \"react-router-dom\";\nimport {\n type PostEntry,\n directoryToPostEntries,\n filterVisiblePosts,\n getFrontmatter,\n} from \"@/lib/content-classification\";\nimport { useDirectory } from \"../../plugin/src/client\";\nimport { ErrorDisplay } from \"./page-error\";\nimport Loading from \"./loading\";\nimport { PostListItem } from \"./post-list-item\";\nimport veslxConfig from \"virtual:veslx-config\";\n\n// Helper to format name for display (e.g., \"01-getting-started\" → \"Getting Started\")\nfunction formatName(name: string): string {\n return name\n .replace(/^\\d+-/, '')\n .replace(/-/g, ' ')\n .replace(/\\b\\w/g, c => c.toUpperCase());\n}\n\n// Helper to get link path from post\nfunction getLinkPath(post: PostEntry): string {\n if (post.file) {\n // Standalone MDX file\n return `/${post.file.path}`;\n } else if (post.slides && !post.readme) {\n // Folder with only slides\n return `/${post.slides.path}`;\n } else if (post.readme) {\n // Folder with readme\n return `/${post.readme.path}`;\n } else {\n // Fallback to folder path\n return `/${post.path}`;\n }\n}\n\nexport function PostList() {\n const { \"*\": path = \".\" } = useParams();\n\n const { directory, loading, error } = useDirectory(path)\n\n if (error) {\n return <ErrorDisplay error={error} path={path} />;\n }\n\n if (loading) {\n return (\n <Loading />\n )\n }\n\n if (!directory) {\n return (\n <div className=\"py-24 text-center\">\n <p className=\"text-muted-foreground font-mono text-sm tracking-wide\">no entries</p>\n </div>\n );\n }\n\n let posts = directoryToPostEntries(directory);\n\n if (posts.length === 0) {\n return (\n <div className=\"py-24 text-center\">\n <p className=\"text-muted-foreground font-mono text-sm tracking-wide\">no entries</p>\n </div>\n );\n }\n\n // Filter out hidden and draft posts\n posts = filterVisiblePosts(posts);\n\n if (posts.length === 0) {\n return (\n <div className=\"py-24 text-center\">\n <p className=\"text-muted-foreground font-mono text-sm tracking-wide\">no entries</p>\n </div>\n );\n }\n\n // Sort based on config\n const sortMode = veslxConfig.posts?.sort ?? 'alpha';\n if (sortMode === 'date' || sortMode === 'date-asc') {\n const ascending = sortMode === 'date-asc';\n // Sort by date, posts without dates go to the top\n posts = posts.sort((a, b) => {\n const dateA = getFrontmatter(a)?.date;\n const dateB = getFrontmatter(b)?.date;\n if (!dateA && !dateB) return a.name.localeCompare(b.name);\n if (!dateA) return -1;\n if (!dateB) return 1;\n const diff = new Date(dateA as string).getTime() - new Date(dateB as string).getTime();\n return ascending ? diff : -diff;\n });\n } else {\n // Alphanumeric sorting by name\n posts = posts.sort((a, b) => a.name.localeCompare(b.name));\n }\n\n return (\n <div className=\"space-y-1 not-prose\">\n {posts.map((post) => {\n const frontmatter = getFrontmatter(post);\n const title = (frontmatter?.title as string) || formatName(post.name);\n const description = frontmatter?.description as string | undefined;\n const date = frontmatter?.date ? new Date(frontmatter.date as string) : undefined;\n const linkPath = getLinkPath(post);\n const isSlides = linkPath.endsWith('SLIDES.mdx') || linkPath.endsWith('.slides.mdx');\n\n return (\n <PostListItem\n key={post.path}\n title={title}\n description={description}\n date={date}\n linkPath={linkPath}\n isSlides={isSlides}\n />\n );\n })}\n </div>\n );\n}\n"],"names":["_a"],"mappings":";;;;;;;AAcA,SAAS,WAAW,MAAsB;AACxC,SAAO,KACJ,QAAQ,SAAS,EAAE,EACnB,QAAQ,MAAM,GAAG,EACjB,QAAQ,SAAS,CAAA,MAAK,EAAE,aAAa;AAC1C;AAGA,SAAS,YAAY,MAAyB;AAC5C,MAAI,KAAK,MAAM;AAEb,WAAO,IAAI,KAAK,KAAK,IAAI;AAAA,EAC3B,WAAW,KAAK,UAAU,CAAC,KAAK,QAAQ;AAEtC,WAAO,IAAI,KAAK,OAAO,IAAI;AAAA,EAC7B,WAAW,KAAK,QAAQ;AAEtB,WAAO,IAAI,KAAK,OAAO,IAAI;AAAA,EAC7B,OAAO;AAEL,WAAO,IAAI,KAAK,IAAI;AAAA,EACtB;AACF;AAEO,SAAS,WAAW;;AACzB,QAAM,EAAE,KAAK,OAAO,IAAA,IAAQ,UAAA;AAE5B,QAAM,EAAE,WAAoB,UAAU,aAAa,I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AU,uBACZ,UAAA,MAAM,IAAI,CAAC,SAAS;AACnB,UAAM,cAAc,eAAe,IAAI;AACvC,UAAM,SAAS,2CAAa,UAAoB,WAAW,KAAK,IAAI;AACpE,UAAM,cAAc,2CAAa;AACjC,UAAM,QAAO,2CAAa,QAAO,IAAI,KAAK,YAAY,IAAc,IAAI;AACxE,UAAM,WAAW,YAAY,IAAI;AACjC,UAAM,WAAW,SAAS,SAAS,YAAY,KAAK,SAAS,SAAS,aAAa;AAEnF,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,MALK,KAAK;AAAA,IAAA;AAAA,EAQhB,CAAC,EAAA,CACH;AAEJ;"}
|
package/package.json
CHANGED
package/plugin/src/types.ts
CHANGED
|
@@ -3,7 +3,7 @@ export interface SlidesConfig {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export interface PostsConfig {
|
|
6
|
-
sort?: 'date' | 'alpha';
|
|
6
|
+
sort?: 'date' | 'date-asc' | 'alpha';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface SiteConfig {
|
|
@@ -26,7 +26,7 @@ export interface ResolvedSlidesConfig {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface ResolvedPostsConfig {
|
|
29
|
-
sort: 'date' | 'alpha';
|
|
29
|
+
sort: 'date' | 'date-asc' | 'alpha';
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface ResolvedSiteConfig {
|
|
@@ -82,15 +82,17 @@ export function PostList() {
|
|
|
82
82
|
|
|
83
83
|
// Sort based on config
|
|
84
84
|
const sortMode = veslxConfig.posts?.sort ?? 'alpha';
|
|
85
|
-
if (sortMode === 'date') {
|
|
86
|
-
|
|
85
|
+
if (sortMode === 'date' || sortMode === 'date-asc') {
|
|
86
|
+
const ascending = sortMode === 'date-asc';
|
|
87
|
+
// Sort by date, posts without dates go to the top
|
|
87
88
|
posts = posts.sort((a, b) => {
|
|
88
89
|
const dateA = getFrontmatter(a)?.date;
|
|
89
90
|
const dateB = getFrontmatter(b)?.date;
|
|
90
91
|
if (!dateA && !dateB) return a.name.localeCompare(b.name);
|
|
91
|
-
if (!dateA) return 1;
|
|
92
|
-
if (!dateB) return
|
|
93
|
-
|
|
92
|
+
if (!dateA) return -1;
|
|
93
|
+
if (!dateB) return 1;
|
|
94
|
+
const diff = new Date(dateA as string).getTime() - new Date(dateB as string).getTime();
|
|
95
|
+
return ascending ? diff : -diff;
|
|
94
96
|
});
|
|
95
97
|
} else {
|
|
96
98
|
// Alphanumeric sorting by name
|