veslx 0.1.27 → 0.1.28
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 +2 -1
- package/bin/lib/serve.ts +2 -1
- package/dist/client/components/header.js +2 -24
- package/dist/client/components/header.js.map +1 -1
- package/dist/client/components/mdx-components.js +2 -0
- package/dist/client/components/mdx-components.js.map +1 -1
- package/dist/client/components/post-list-item.js +43 -0
- package/dist/client/components/post-list-item.js.map +1 -0
- package/dist/client/components/post-list.js +39 -79
- package/dist/client/components/post-list.js.map +1 -1
- package/dist/client/hooks/use-mdx-content.js +64 -4
- package/dist/client/hooks/use-mdx-content.js.map +1 -1
- package/dist/client/lib/content-classification.js +1 -22
- package/dist/client/lib/content-classification.js.map +1 -1
- package/dist/client/pages/content-router.js +2 -10
- package/dist/client/pages/content-router.js.map +1 -1
- package/dist/client/pages/home.js +7 -20
- package/dist/client/pages/home.js.map +1 -1
- package/dist/client/pages/index-post.js +34 -0
- package/dist/client/pages/index-post.js.map +1 -0
- package/dist/client/pages/post.js +1 -3
- package/dist/client/pages/post.js.map +1 -1
- package/dist/client/pages/slides.js +4 -3
- package/dist/client/pages/slides.js.map +1 -1
- package/package.json +1 -1
- package/plugin/src/plugin.ts +18 -8
- package/plugin/src/types.ts +17 -4
- package/src/components/header.tsx +2 -20
- package/src/components/mdx-components.tsx +3 -1
- package/src/components/post-list-item.tsx +54 -0
- package/src/components/post-list.tsx +58 -115
- package/src/components/welcome.tsx +2 -2
- package/src/hooks/use-mdx-content.ts +96 -7
- package/src/index.css +12 -0
- package/src/lib/content-classification.ts +0 -24
- package/src/pages/content-router.tsx +6 -17
- package/src/pages/home.tsx +8 -50
- package/src/pages/index-post.tsx +59 -0
- package/src/pages/post.tsx +1 -3
- package/src/pages/slides.tsx +5 -3
- package/src/vite-env.d.ts +11 -1
- package/vite.config.ts +4 -3
- package/dist/client/components/running-bar.js +0 -15
- package/dist/client/components/running-bar.js.map +0 -1
- package/src/components/content-tabs.tsx +0 -64
- package/src/components/running-bar.tsx +0 -21
package/bin/lib/build.ts
CHANGED
package/bin/lib/serve.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { useParams, Link } from "react-router-dom";
|
|
|
3
3
|
import { ModeToggle } from "./mode-toggle.js";
|
|
4
4
|
import { SiGithub } from "@icons-pack/react-simple-icons";
|
|
5
5
|
import { ChevronUp, ChevronDown } from "lucide-react";
|
|
6
|
-
import
|
|
6
|
+
import veslxConfig from "virtual:veslx-config";
|
|
7
7
|
import { cn } from "../lib/utils.js";
|
|
8
8
|
function Header({ slideControls } = {}) {
|
|
9
|
-
const config =
|
|
9
|
+
const config = veslxConfig.site;
|
|
10
10
|
const { "*": path } = useParams();
|
|
11
11
|
return /* @__PURE__ */ jsx("header", { className: cn(
|
|
12
12
|
"print:hidden",
|
|
@@ -50,28 +50,6 @@ function Header({ slideControls } = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
)
|
|
52
52
|
] }),
|
|
53
|
-
/* @__PURE__ */ jsx(
|
|
54
|
-
Link,
|
|
55
|
-
{
|
|
56
|
-
to: `/posts`,
|
|
57
|
-
className: cn(
|
|
58
|
-
"font-medium text-muted-foreground/70 hover:text-foreground transition-colors duration-300",
|
|
59
|
-
(path == null ? void 0 : path.startsWith("posts")) && "font-semibold text-foreground"
|
|
60
|
-
),
|
|
61
|
-
children: "Posts"
|
|
62
|
-
}
|
|
63
|
-
),
|
|
64
|
-
/* @__PURE__ */ jsx(
|
|
65
|
-
Link,
|
|
66
|
-
{
|
|
67
|
-
to: `/docs`,
|
|
68
|
-
className: cn(
|
|
69
|
-
"font-medium text-muted-foreground/70 hover:text-foreground transition-colors duration-300",
|
|
70
|
-
(path == null ? void 0 : path.startsWith("docs")) && "font-semibold text-foreground"
|
|
71
|
-
),
|
|
72
|
-
children: "Docs"
|
|
73
|
-
}
|
|
74
|
-
),
|
|
75
53
|
config.github && /* @__PURE__ */ jsx(
|
|
76
54
|
Link,
|
|
77
55
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.js","sources":["../../../src/components/header.tsx"],"sourcesContent":["import { Link, useParams } from \"react-router-dom\";\nimport { ModeToggle } from \"./mode-toggle\";\nimport { SiGithub } from \"@icons-pack/react-simple-icons\";\nimport { ChevronUp, ChevronDown } from \"lucide-react\";\nimport
|
|
1
|
+
{"version":3,"file":"header.js","sources":["../../../src/components/header.tsx"],"sourcesContent":["import { Link, useParams } from \"react-router-dom\";\nimport { ModeToggle } from \"./mode-toggle\";\nimport { SiGithub } from \"@icons-pack/react-simple-icons\";\nimport { ChevronUp, ChevronDown } from \"lucide-react\";\nimport veslxConfig from \"virtual:veslx-config\";\nimport { cn } from \"@/lib/utils\";\n\ninterface HeaderProps {\n slideControls?: {\n current: number;\n total: number;\n onPrevious: () => void;\n onNext: () => void;\n };\n}\n\nexport function Header({ slideControls }: HeaderProps = {}) {\n const config = veslxConfig.site;\n\n const { \"*\": path } = useParams()\n\n return (\n <header className={cn(\n \"print:hidden\",\n slideControls && \"fixed top-0 left-0 right-0 z-40\"\n )}>\n <div className={cn(\n \"mx-auto w-full px-[var(--page-padding)] flex items-center gap-8 py-4\",\n !slideControls && \"max-w-[var(--content-width)]\"\n )}>\n <nav className=\"flex items-center gap-1\">\n <Link\n to=\"/\"\n className=\"rounded-lg font-mono py-1.5 text-sm font-medium text-muted-foreground hover:underline\"\n >\n {config.name}\n </Link>\n </nav>\n\n <div className=\"flex-1\" />\n\n {/* Navigation */}\n <nav className=\"flex items-center gap-4\">\n {slideControls && (\n <>\n <button\n onClick={slideControls.onPrevious}\n className=\"p-1.5 text-muted-foreground/70 hover:text-foreground transition-colors duration-200\"\n title=\"Previous slide (↑)\"\n >\n <ChevronUp className=\"h-4 w-4\" />\n </button>\n <span className=\"font-mono text-xs text-muted-foreground/70 tabular-nums min-w-[3ch] text-center\">\n {slideControls.current + 1}/{slideControls.total}\n </span>\n <button\n onClick={slideControls.onNext}\n className=\"p-1.5 text-muted-foreground/70 hover:text-foreground transition-colors duration-200\"\n title=\"Next slide (↓)\"\n >\n <ChevronDown className=\"h-4 w-4\" />\n </button>\n </>\n )}\n {config.github && (\n <Link\n to={`https://github.com/${config.github}`}\n target=\"_blank\"\n className=\"text-muted-foreground/70 hover:text-foreground transition-colors duration-300\"\n aria-label=\"GitHub\"\n >\n <SiGithub className=\"h-4 w-4\" />\n </Link>\n )}\n <ModeToggle />\n </nav>\n </div>\n </header>\n );\n}\n"],"names":[],"mappings":";;;;;;;AAgBO,SAAS,OAAO,EAAE,cAAA,IAA+B,IAAI;AAC1D,QAAM,SAAS,YAAY;AAE3B,QAAM,EAAE,KAAK,KAAA,IAAS,UAAA;AAEtB,SACE,oBAAC,YAAO,WAAW;AAAA,IACjB;AAAA,IACA,iBAAiB;AAAA,EAAA,GAEjB,UAAA,qBAAC,OAAA,EAAI,WAAW;AAAA,IACd;AAAA,IACA,CAAC,iBAAiB;AAAA,EAAA,GAElB,UAAA;AAAA,IAAA,oBAAC,OAAA,EAAI,WAAU,2BACb,UAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAG;AAAA,QACH,WAAU;AAAA,QAET,UAAA,OAAO;AAAA,MAAA;AAAA,IAAA,GAEZ;AAAA,IAEA,oBAAC,OAAA,EAAI,WAAU,SAAA,CAAS;AAAA,IAGxB,qBAAC,OAAA,EAAI,WAAU,2BACZ,UAAA;AAAA,MAAA,iBACC,qBAAA,UAAA,EACE,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,SAAS,cAAc;AAAA,YACvB,WAAU;AAAA,YACV,OAAM;AAAA,YAEN,UAAA,oBAAC,WAAA,EAAU,WAAU,UAAA,CAAU;AAAA,UAAA;AAAA,QAAA;AAAA,QAEjC,qBAAC,QAAA,EAAK,WAAU,mFACb,UAAA;AAAA,UAAA,cAAc,UAAU;AAAA,UAAE;AAAA,UAAE,cAAc;AAAA,QAAA,GAC7C;AAAA,QACA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,SAAS,cAAc;AAAA,YACvB,WAAU;AAAA,YACV,OAAM;AAAA,YAEN,UAAA,oBAAC,aAAA,EAAY,WAAU,UAAA,CAAU;AAAA,UAAA;AAAA,QAAA;AAAA,MACnC,GACF;AAAA,MAED,OAAO,UACN;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,IAAI,sBAAsB,OAAO,MAAM;AAAA,UACvC,QAAO;AAAA,UACP,WAAU;AAAA,UACV,cAAW;AAAA,UAEX,UAAA,oBAAC,UAAA,EAAS,WAAU,UAAA,CAAU;AAAA,QAAA;AAAA,MAAA;AAAA,0BAGjC,YAAA,CAAA,CAAW;AAAA,IAAA,EAAA,CACd;AAAA,EAAA,EAAA,CACF,EAAA,CACF;AAEJ;"}
|
|
@@ -8,6 +8,7 @@ import { HeroSlide } from "./slides/hero-slide.js";
|
|
|
8
8
|
import { FigureSlide } from "./slides/figure-slide.js";
|
|
9
9
|
import { TextSlide } from "./slides/text-slide.js";
|
|
10
10
|
import { SlideOutline } from "./slides/slide-outline.js";
|
|
11
|
+
import { PostList } from "./post-list.js";
|
|
11
12
|
function SmartLink({ href, children, ...props }) {
|
|
12
13
|
const location = useLocation();
|
|
13
14
|
const isExternal = (href == null ? void 0 : href.startsWith("http")) || (href == null ? void 0 : href.startsWith("mailto:")) || (href == null ? void 0 : href.startsWith("tel:"));
|
|
@@ -57,6 +58,7 @@ const mdxComponents = {
|
|
|
57
58
|
FigureSlide,
|
|
58
59
|
TextSlide,
|
|
59
60
|
SlideOutline,
|
|
61
|
+
PostList,
|
|
60
62
|
// Headings - clean sans-serif
|
|
61
63
|
h1: (props) => {
|
|
62
64
|
const id = generateId(props.children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdx-components.js","sources":["../../../src/components/mdx-components.tsx"],"sourcesContent":["import { Link, useLocation } from 'react-router-dom'\nimport Gallery from '@/components/gallery'\nimport { ParameterTable } from '@/components/parameter-table'\nimport { ParameterBadge } from '@/components/parameter-badge'\nimport { FrontMatter } from './front-matter'\nimport { HeroSlide } from './slides/hero-slide'\nimport { FigureSlide } from './slides/figure-slide'\nimport { TextSlide } from './slides/text-slide'\nimport { SlideOutline } from './slides/slide-outline'\n\n/**\n * Smart link component that uses React Router for internal links\n * and regular anchor tags for external links.\n */\nfunction SmartLink({ href, children, ...props }: React.AnchorHTMLAttributes<HTMLAnchorElement>) {\n const location = useLocation()\n\n // External links: absolute URLs, mailto, tel, etc.\n const isExternal = href?.startsWith('http') || href?.startsWith('mailto:') || href?.startsWith('tel:')\n\n // Hash-only links stay as anchors for in-page navigation\n const isHashOnly = href?.startsWith('#')\n\n if (isExternal || isHashOnly || !href) {\n return (\n <a\n href={href}\n className=\"text-primary hover:underline underline-offset-2\"\n {...(isExternal ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n {...props}\n >\n {children}\n </a>\n )\n }\n\n // Resolve relative paths (./foo.mdx, ../bar.mdx) against current location\n let resolvedHref = href\n if (href.startsWith('./') || href.startsWith('../')) {\n // Get current directory from pathname\n const currentPath = location.pathname\n const currentDir = currentPath.replace(/\\/[^/]+\\.mdx$/, '') || currentPath.replace(/\\/[^/]*$/, '') || '/'\n\n // Simple relative path resolution\n if (href.startsWith('./')) {\n resolvedHref = `${currentDir}/${href.slice(2)}`.replace(/\\/+/g, '/')\n } else if (href.startsWith('../')) {\n const parentDir = currentDir.replace(/\\/[^/]+$/, '') || '/'\n resolvedHref = `${parentDir}/${href.slice(3)}`.replace(/\\/+/g, '/')\n }\n }\n\n // Internal link - use React Router Link\n return (\n <Link\n to={resolvedHref}\n className=\"text-primary hover:underline underline-offset-2\"\n {...props}\n >\n {children}\n </Link>\n )\n}\n\nfunction generateId(children: unknown): string {\n return children\n ?.toString()\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, '')\n .replace(/\\s+/g, '-') ?? ''\n}\n\n// Shared MDX components - lab notebook / coder aesthetic\nexport const mdxComponents = {\n\n FrontMatter,\n\n Gallery,\n\n ParameterTable,\n\n ParameterBadge,\n\n HeroSlide,\n\n FigureSlide,\n\n TextSlide,\n\n SlideOutline,\n\n // Headings - clean sans-serif\n h1: (props: React.HTMLAttributes<HTMLHeadingElement>) => {\n const id = generateId(props.children)\n return (\n <h1\n id={id}\n className=\"text-2xl font-semibold tracking-tight mt-12 mb-4 first:mt-0\"\n {...props}\n />\n )\n },\n h2: (props: React.HTMLAttributes<HTMLHeadingElement>) => {\n const id = generateId(props.children)\n return (\n <h2\n id={id}\n className=\"text-xl font-semibold tracking-tight mt-10 mb-3 pb-2 border-b border-border\"\n {...props}\n />\n )\n },\n h3: (props: React.HTMLAttributes<HTMLHeadingElement>) => {\n const id = generateId(props.children)\n return (\n <h3\n id={id}\n className=\"text-lg font-medium tracking-tight mt-8 mb-2\"\n {...props}\n />\n )\n },\n h4: (props: React.HTMLAttributes<HTMLHeadingElement>) => {\n const id = generateId(props.children)\n return (\n <h4\n id={id}\n className=\"text-base font-medium mt-6 mb-2\"\n {...props}\n />\n )\n },\n h5: (props: React.HTMLAttributes<HTMLHeadingElement>) => {\n const id = generateId(props.children)\n return (\n <h5\n id={id}\n className=\"text-sm font-medium mt-4 mb-1\"\n {...props}\n />\n )\n },\n\n // Code blocks - IDE/terminal style\n pre: (props: React.HTMLAttributes<HTMLPreElement>) => (\n <pre\n className=\"not-prose w-full overflow-x-auto p-4 text-sm bg-muted/50 border border-border rounded-md font-mono my-6\"\n {...props}\n />\n ),\n code: (props: React.HTMLAttributes<HTMLElement> & { className?: string }) => {\n const isInline = !props.className?.includes('language-')\n if (isInline) {\n return (\n <code\n className=\"font-mono text-[0.85em] bg-muted px-1.5 py-0.5 rounded text-primary\"\n {...props}\n />\n )\n }\n return <code {...props} />\n },\n\n // Blockquote\n blockquote: (props: React.HTMLAttributes<HTMLQuoteElement>) => (\n <blockquote\n className=\"border-l-2 border-primary pl-4 my-6 text-muted-foreground\"\n {...props}\n />\n ),\n\n // Lists\n ul: (props: React.HTMLAttributes<HTMLUListElement>) => (\n <ul className=\"my-4 ml-6 list-disc marker:text-muted-foreground\" {...props} />\n ),\n ol: (props: React.HTMLAttributes<HTMLOListElement>) => (\n <ol className=\"my-4 ml-6 list-decimal marker:text-muted-foreground\" {...props} />\n ),\n li: (props: React.HTMLAttributes<HTMLLIElement>) => (\n <li className=\"mt-1.5\" {...props} />\n ),\n\n // Links - uses React Router for internal navigation\n a: SmartLink,\n\n // Tables\n table: (props: React.TableHTMLAttributes<HTMLTableElement>) => (\n <div className=\"not-prose my-6 overflow-x-auto border border-border rounded-md\">\n <table className=\"w-full text-sm border-collapse\" {...props} />\n </div>\n ),\n thead: (props: React.HTMLAttributes<HTMLTableSectionElement>) => (\n <thead className=\"bg-muted/50\" {...props} />\n ),\n tbody: (props: React.HTMLAttributes<HTMLTableSectionElement>) => (\n <tbody {...props} />\n ),\n tr: (props: React.HTMLAttributes<HTMLTableRowElement>) => (\n <tr className=\"border-b border-border last:border-b-0\" {...props} />\n ),\n th: (props: React.ThHTMLAttributes<HTMLTableCellElement>) => (\n <th\n className=\"px-4 py-3 text-left text-xs font-medium text-muted-foreground uppercase tracking-wider\"\n {...props}\n />\n ),\n td: (props: React.TdHTMLAttributes<HTMLTableCellElement>) => (\n <td className=\"px-4 py-3 align-top\" {...props} />\n ),\n\n // Horizontal rule\n hr: (props: React.HTMLAttributes<HTMLHRElement>) => (\n <hr className=\"my-8 border-t border-border\" {...props} />\n ),\n\n // Paragraph\n p: (props: React.HTMLAttributes<HTMLParagraphElement>) => (\n <p className=\"leading-relaxed mb-4 last:mb-0\" {...props} />\n ),\n\n // Strong/emphasis\n strong: (props: React.HTMLAttributes<HTMLElement>) => (\n <strong className=\"font-semibold\" {...props} />\n ),\n em: (props: React.HTMLAttributes<HTMLElement>) => (\n <em className=\"italic\" {...props} />\n ),\n}\n"],"names":[],"mappings":";;;;;;;;;;AAcA,SAAS,UAAU,EAAE,MAAM,UAAU,GAAG,SAAwD;AAC9F,QAAM,WAAW,YAAA;AAGjB,QAAM,cA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../../src/components/mdx-components.tsx"],"sourcesContent":["import { Link, useLocation } from 'react-router-dom'\nimport Gallery from '@/components/gallery'\nimport { ParameterTable } from '@/components/parameter-table'\nimport { ParameterBadge } from '@/components/parameter-badge'\nimport { FrontMatter } from './front-matter'\nimport { HeroSlide } from './slides/hero-slide'\nimport { FigureSlide } from './slides/figure-slide'\nimport { TextSlide } from './slides/text-slide'\nimport { SlideOutline } from './slides/slide-outline'\nimport { PostList } from '@/components/post-list'\n/**\n * Smart link component that uses React Router for internal links\n * and regular anchor tags for external links.\n */\nfunction SmartLink({ href, children, ...props }: React.AnchorHTMLAttributes<HTMLAnchorElement>) {\n const location = useLocation()\n\n // External links: absolute URLs, mailto, tel, etc.\n const isExternal = href?.startsWith('http') || href?.startsWith('mailto:') || href?.startsWith('tel:')\n\n // Hash-only links stay as anchors for in-page navigation\n const isHashOnly = href?.startsWith('#')\n\n if (isExternal || isHashOnly || !href) {\n return (\n <a\n href={href}\n className=\"text-primary hover:underline underline-offset-2\"\n {...(isExternal ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n {...props}\n >\n {children}\n </a>\n )\n }\n\n // Resolve relative paths (./foo.mdx, ../bar.mdx) against current location\n let resolvedHref = href\n if (href.startsWith('./') || href.startsWith('../')) {\n // Get current directory from pathname\n const currentPath = location.pathname\n const currentDir = currentPath.replace(/\\/[^/]+\\.mdx$/, '') || currentPath.replace(/\\/[^/]*$/, '') || '/'\n\n // Simple relative path resolution\n if (href.startsWith('./')) {\n resolvedHref = `${currentDir}/${href.slice(2)}`.replace(/\\/+/g, '/')\n } else if (href.startsWith('../')) {\n const parentDir = currentDir.replace(/\\/[^/]+$/, '') || '/'\n resolvedHref = `${parentDir}/${href.slice(3)}`.replace(/\\/+/g, '/')\n }\n }\n\n // Internal link - use React Router Link\n return (\n <Link\n to={resolvedHref}\n className=\"text-primary hover:underline underline-offset-2\"\n {...props}\n >\n {children}\n </Link>\n )\n}\n\nfunction generateId(children: unknown): string {\n return children\n ?.toString()\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, '')\n .replace(/\\s+/g, '-') ?? ''\n}\n\n// Shared MDX components - lab notebook / coder aesthetic\nexport const mdxComponents = {\n\n FrontMatter,\n\n Gallery,\n\n ParameterTable,\n\n ParameterBadge,\n\n HeroSlide,\n\n FigureSlide,\n\n TextSlide,\n\n SlideOutline,\n\n PostList,\n\n // Headings - clean sans-serif\n h1: (props: React.HTMLAttributes<HTMLHeadingElement>) => {\n const id = generateId(props.children)\n return (\n <h1\n id={id}\n className=\"text-2xl font-semibold tracking-tight mt-12 mb-4 first:mt-0\"\n {...props}\n />\n )\n },\n h2: (props: React.HTMLAttributes<HTMLHeadingElement>) => {\n const id = generateId(props.children)\n return (\n <h2\n id={id}\n className=\"text-xl font-semibold tracking-tight mt-10 mb-3 pb-2 border-b border-border\"\n {...props}\n />\n )\n },\n h3: (props: React.HTMLAttributes<HTMLHeadingElement>) => {\n const id = generateId(props.children)\n return (\n <h3\n id={id}\n className=\"text-lg font-medium tracking-tight mt-8 mb-2\"\n {...props}\n />\n )\n },\n h4: (props: React.HTMLAttributes<HTMLHeadingElement>) => {\n const id = generateId(props.children)\n return (\n <h4\n id={id}\n className=\"text-base font-medium mt-6 mb-2\"\n {...props}\n />\n )\n },\n h5: (props: React.HTMLAttributes<HTMLHeadingElement>) => {\n const id = generateId(props.children)\n return (\n <h5\n id={id}\n className=\"text-sm font-medium mt-4 mb-1\"\n {...props}\n />\n )\n },\n\n // Code blocks - IDE/terminal style\n pre: (props: React.HTMLAttributes<HTMLPreElement>) => (\n <pre\n className=\"not-prose w-full overflow-x-auto p-4 text-sm bg-muted/50 border border-border rounded-md font-mono my-6\"\n {...props}\n />\n ),\n code: (props: React.HTMLAttributes<HTMLElement> & { className?: string }) => {\n const isInline = !props.className?.includes('language-')\n if (isInline) {\n return (\n <code\n className=\"font-mono text-[0.85em] bg-muted px-1.5 py-0.5 rounded text-primary\"\n {...props}\n />\n )\n }\n return <code {...props} />\n },\n\n // Blockquote\n blockquote: (props: React.HTMLAttributes<HTMLQuoteElement>) => (\n <blockquote\n className=\"border-l-2 border-primary pl-4 my-6 text-muted-foreground\"\n {...props}\n />\n ),\n\n // Lists\n ul: (props: React.HTMLAttributes<HTMLUListElement>) => (\n <ul className=\"my-4 ml-6 list-disc marker:text-muted-foreground\" {...props} />\n ),\n ol: (props: React.HTMLAttributes<HTMLOListElement>) => (\n <ol className=\"my-4 ml-6 list-decimal marker:text-muted-foreground\" {...props} />\n ),\n li: (props: React.HTMLAttributes<HTMLLIElement>) => (\n <li className=\"mt-1.5\" {...props} />\n ),\n\n // Links - uses React Router for internal navigation\n a: SmartLink,\n\n // Tables\n table: (props: React.TableHTMLAttributes<HTMLTableElement>) => (\n <div className=\"not-prose my-6 overflow-x-auto border border-border rounded-md\">\n <table className=\"w-full text-sm border-collapse\" {...props} />\n </div>\n ),\n thead: (props: React.HTMLAttributes<HTMLTableSectionElement>) => (\n <thead className=\"bg-muted/50\" {...props} />\n ),\n tbody: (props: React.HTMLAttributes<HTMLTableSectionElement>) => (\n <tbody {...props} />\n ),\n tr: (props: React.HTMLAttributes<HTMLTableRowElement>) => (\n <tr className=\"border-b border-border last:border-b-0\" {...props} />\n ),\n th: (props: React.ThHTMLAttributes<HTMLTableCellElement>) => (\n <th\n className=\"px-4 py-3 text-left text-xs font-medium text-muted-foreground uppercase tracking-wider\"\n {...props}\n />\n ),\n td: (props: React.TdHTMLAttributes<HTMLTableCellElement>) => (\n <td className=\"px-4 py-3 align-top\" {...props} />\n ),\n\n // Horizontal rule\n hr: (props: React.HTMLAttributes<HTMLHRElement>) => (\n <hr className=\"my-8 border-t border-border\" {...props} />\n ),\n\n // Paragraph\n p: (props: React.HTMLAttributes<HTMLParagraphElement>) => (\n <p className=\"leading-relaxed mb-4 last:mb-0\" {...props} />\n ),\n\n // Strong/emphasis\n strong: (props: React.HTMLAttributes<HTMLElement>) => (\n <strong className=\"font-semibold\" {...props} />\n ),\n em: (props: React.HTMLAttributes<HT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C,UACP,oBAAC,YAAO,WAAU,iBAAiB,GAAG,OAAO;AAAA,EAE/C,IAAI,CAAC,UACH,oBAAC,QAAG,WAAU,UAAU,GAAG,MAAA,CAAO;AAEtC;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Link } from "react-router-dom";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { formatDate } from "../lib/format-date.js";
|
|
5
|
+
import { ArrowRight, Presentation } from "lucide-react";
|
|
6
|
+
function PostListItem({ title, description, date, linkPath, isSlides }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
Link,
|
|
9
|
+
{
|
|
10
|
+
to: linkPath,
|
|
11
|
+
className: cn(
|
|
12
|
+
"group block py-3 px-3 -mx-3 rounded-md",
|
|
13
|
+
"transition-colors duration-150"
|
|
14
|
+
),
|
|
15
|
+
children: /* @__PURE__ */ jsxs("article", { className: "flex items-center gap-4", children: [
|
|
16
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
17
|
+
/* @__PURE__ */ jsxs("div", { className: cn(
|
|
18
|
+
"text-sm font-medium text-foreground",
|
|
19
|
+
"group-hover:underline",
|
|
20
|
+
"flex items-center gap-2"
|
|
21
|
+
), children: [
|
|
22
|
+
/* @__PURE__ */ jsx("span", { children: title }),
|
|
23
|
+
/* @__PURE__ */ jsx(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" })
|
|
24
|
+
] }),
|
|
25
|
+
description && /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground line-clamp-1 mt-0.5", children: description })
|
|
26
|
+
] }),
|
|
27
|
+
isSlides && /* @__PURE__ */ jsx(Presentation, { className: "h-3 w-3 text-muted-foreground" }),
|
|
28
|
+
/* @__PURE__ */ jsx(
|
|
29
|
+
"time",
|
|
30
|
+
{
|
|
31
|
+
dateTime: date == null ? void 0 : date.toISOString(),
|
|
32
|
+
className: "font-mono text-xs text-muted-foreground tabular-nums w-20 flex-shrink-0",
|
|
33
|
+
children: date && formatDate(date)
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
] })
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
PostListItem
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=post-list-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-list-item.js","sources":["../../../src/components/post-list-item.tsx"],"sourcesContent":["import { Link } from \"react-router-dom\";\nimport { cn } from \"@/lib/utils\";\nimport { formatDate } from \"@/lib/format-date\";\nimport { ArrowRight, Presentation } from \"lucide-react\";\n\ninterface PostListItemProps {\n title: string;\n description?: string;\n date?: Date;\n linkPath: string;\n isSlides?: boolean;\n}\n\nexport function PostListItem({ title, description, date, linkPath, isSlides }: PostListItemProps) {\n return (\n <Link\n to={linkPath}\n className={cn(\n \"group block py-3 px-3 -mx-3 rounded-md\",\n \"transition-colors duration-150\",\n )}\n >\n <article className=\"flex items-center gap-4\">\n {/* Main content */}\n <div className=\"flex-1 min-w-0\">\n <div className={cn(\n \"text-sm font-medium text-foreground\",\n \"group-hover:underline\",\n \"flex items-center gap-2\"\n )}>\n <span>{title}</span>\n <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\" />\n </div>\n\n {description && (\n <div className=\"text-sm text-muted-foreground line-clamp-1 mt-0.5\">\n {description}\n </div>\n )}\n </div>\n\n {isSlides && (\n <Presentation className=\"h-3 w-3 text-muted-foreground\" />\n )}\n <time\n dateTime={date?.toISOString()}\n className=\"font-mono text-xs text-muted-foreground tabular-nums w-20 flex-shrink-0\"\n >\n {date && formatDate(date)}\n </time>\n </article>\n </Link>\n );\n}\n"],"names":[],"mappings":";;;;;AAaO,SAAS,aAAa,EAAE,OAAO,aAAa,MAAM,UAAU,YAA+B;AAChG,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI;AAAA,MACJ,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MAAA;AAAA,MAGF,UAAA,qBAAC,WAAA,EAAQ,WAAU,2BAEjB,UAAA;AAAA,QAAA,qBAAC,OAAA,EAAI,WAAU,kBACb,UAAA;AAAA,UAAA,qBAAC,SAAI,WAAW;AAAA,YACd;AAAA,YACA;AAAA,YACA;AAAA,UAAA,GAEA,UAAA;AAAA,YAAA,oBAAC,UAAM,UAAA,MAAA,CAAM;AAAA,YACb,oBAAC,YAAA,EAAW,WAAU,8HAAA,CAA8H;AAAA,UAAA,GACtJ;AAAA,UAEC,eACC,oBAAC,OAAA,EAAI,WAAU,qDACZ,UAAA,YAAA,CACH;AAAA,QAAA,GAEJ;AAAA,QAEC,YACC,oBAAC,cAAA,EAAa,WAAU,gCAAA,CAAgC;AAAA,QAE1D;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,UAAU,6BAAM;AAAA,YAChB,WAAU;AAAA,YAET,UAAA,QAAQ,WAAW,IAAI;AAAA,UAAA;AAAA,QAAA;AAAA,MAC1B,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1,102 +1,62 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
function
|
|
8
|
-
const match = name.match(/^(\d+)-/);
|
|
9
|
-
return match ? parseInt(match[1], 10) : null;
|
|
10
|
-
}
|
|
11
|
-
function stripNumericPrefix(name) {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useParams } from "react-router-dom";
|
|
3
|
+
import { directoryToPostEntries, filterVisiblePosts, getFrontmatter } from "../lib/content-classification.js";
|
|
4
|
+
import { useDirectory } from "../plugin/src/client.js";
|
|
5
|
+
import { ErrorDisplay } from "./page-error.js";
|
|
6
|
+
import { PostListItem } from "./post-list-item.js";
|
|
7
|
+
function formatName(name) {
|
|
12
8
|
return name.replace(/^\d+-/, "").replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
13
9
|
}
|
|
14
|
-
function
|
|
10
|
+
function getLinkPath(post) {
|
|
11
|
+
if (post.file) {
|
|
12
|
+
return `/${post.file.path}`;
|
|
13
|
+
} else if (post.slides && !post.readme) {
|
|
14
|
+
return `/${post.slides.path}`;
|
|
15
|
+
} else if (post.readme) {
|
|
16
|
+
return `/${post.readme.path}`;
|
|
17
|
+
} else {
|
|
18
|
+
return `/${post.path}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function PostList() {
|
|
22
|
+
const { "*": path = "." } = useParams();
|
|
23
|
+
const { directory, error } = useDirectory(path);
|
|
24
|
+
if (error) {
|
|
25
|
+
return /* @__PURE__ */ jsx(ErrorDisplay, { error, path });
|
|
26
|
+
}
|
|
27
|
+
if (!directory) {
|
|
28
|
+
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" }) });
|
|
29
|
+
}
|
|
15
30
|
let posts = directoryToPostEntries(directory);
|
|
16
31
|
if (posts.length === 0) {
|
|
17
32
|
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" }) });
|
|
18
33
|
}
|
|
19
34
|
posts = filterVisiblePosts(posts);
|
|
20
|
-
posts = filterByView(posts, view);
|
|
21
35
|
if (posts.length === 0) {
|
|
22
36
|
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" }) });
|
|
23
37
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return (frontmatter == null ? void 0 : frontmatter.date) ? new Date(frontmatter.date) : null;
|
|
27
|
-
};
|
|
28
|
-
posts = posts.sort((a, b) => {
|
|
29
|
-
var _a, _b;
|
|
30
|
-
const aOrder = extractOrder(a.name);
|
|
31
|
-
const bOrder = extractOrder(b.name);
|
|
32
|
-
const aDate = getPostDate(a);
|
|
33
|
-
const bDate = getPostDate(b);
|
|
34
|
-
if (aOrder !== null && bOrder !== null) {
|
|
35
|
-
return aOrder - bOrder;
|
|
36
|
-
}
|
|
37
|
-
if (aOrder !== null) return -1;
|
|
38
|
-
if (bOrder !== null) return 1;
|
|
39
|
-
if (aDate && bDate) {
|
|
40
|
-
return bDate.getTime() - aDate.getTime();
|
|
41
|
-
}
|
|
42
|
-
if (aDate) return -1;
|
|
43
|
-
if (bDate) return 1;
|
|
44
|
-
const aTitle = ((_a = getFrontmatter(a)) == null ? void 0 : _a.title) || a.name;
|
|
45
|
-
const bTitle = ((_b = getFrontmatter(b)) == null ? void 0 : _b.title) || b.name;
|
|
46
|
-
return aTitle.localeCompare(bTitle);
|
|
47
|
-
});
|
|
48
|
-
return /* @__PURE__ */ jsx("div", { className: "space-y-1", children: posts.map((post) => {
|
|
38
|
+
posts = posts.sort((a, b) => a.name.localeCompare(b.name));
|
|
39
|
+
return /* @__PURE__ */ jsx("div", { className: "space-y-1 not-prose", children: posts.map((post) => {
|
|
49
40
|
const frontmatter = getFrontmatter(post);
|
|
50
|
-
const title = (frontmatter == null ? void 0 : frontmatter.title) ||
|
|
41
|
+
const title = (frontmatter == null ? void 0 : frontmatter.title) || formatName(post.name);
|
|
51
42
|
const description = frontmatter == null ? void 0 : frontmatter.description;
|
|
52
|
-
const date = (frontmatter == null ? void 0 : frontmatter.date) ? new Date(frontmatter.date) :
|
|
53
|
-
|
|
54
|
-
if (post.file) {
|
|
55
|
-
linkPath = `/${post.file.path}`;
|
|
56
|
-
} else if (post.slides && !post.readme) {
|
|
57
|
-
linkPath = `/${post.slides.path}`;
|
|
58
|
-
} else if (post.readme) {
|
|
59
|
-
linkPath = `/${post.readme.path}`;
|
|
60
|
-
} else {
|
|
61
|
-
linkPath = `/${post.path}`;
|
|
62
|
-
}
|
|
43
|
+
const date = (frontmatter == null ? void 0 : frontmatter.date) ? new Date(frontmatter.date) : void 0;
|
|
44
|
+
const linkPath = getLinkPath(post);
|
|
63
45
|
const isSlides = linkPath.endsWith("SLIDES.mdx") || linkPath.endsWith(".slides.mdx");
|
|
64
46
|
return /* @__PURE__ */ jsx(
|
|
65
|
-
|
|
47
|
+
PostListItem,
|
|
66
48
|
{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
children: /* @__PURE__ */ jsxs("article", { className: "flex items-center gap-4", children: [
|
|
73
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
74
|
-
/* @__PURE__ */ jsxs("h3", { className: cn(
|
|
75
|
-
"text-sm font-medium text-foreground",
|
|
76
|
-
"group-hover:underline",
|
|
77
|
-
"flex items-center gap-2"
|
|
78
|
-
), children: [
|
|
79
|
-
/* @__PURE__ */ jsx("span", { children: title }),
|
|
80
|
-
/* @__PURE__ */ jsx(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" })
|
|
81
|
-
] }),
|
|
82
|
-
description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground line-clamp-1 mt-0.5", children: description })
|
|
83
|
-
] }),
|
|
84
|
-
isSlides && /* @__PURE__ */ jsx(Presentation, { className: "h-3 w-3 text-muted-foreground" }),
|
|
85
|
-
/* @__PURE__ */ jsx(
|
|
86
|
-
"time",
|
|
87
|
-
{
|
|
88
|
-
dateTime: date == null ? void 0 : date.toISOString(),
|
|
89
|
-
className: "font-mono text-xs text-muted-foreground tabular-nums w-20 flex-shrink-0",
|
|
90
|
-
children: date && formatDate(date)
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
] })
|
|
49
|
+
title,
|
|
50
|
+
description,
|
|
51
|
+
date,
|
|
52
|
+
linkPath,
|
|
53
|
+
isSlides
|
|
94
54
|
},
|
|
95
55
|
post.path
|
|
96
56
|
);
|
|
97
57
|
}) });
|
|
98
58
|
}
|
|
99
59
|
export {
|
|
100
|
-
PostList
|
|
60
|
+
PostList
|
|
101
61
|
};
|
|
102
62
|
//# sourceMappingURL=post-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-list.js","sources":["../../../src/components/post-list.tsx"],"sourcesContent":["import {
|
|
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\";\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 // Alphanumeric sorting by name\n posts = posts.sort((a, b) => a.name.localeCompare(b.name));\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":[],"mappings":";;;;;;AAaA,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,a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|
3
3
|
const keys = Object.keys(modules);
|
|
4
4
|
const normalizedPath = path.replace(/^\//, "");
|
|
5
|
-
if (normalizedPath.endsWith(".mdx")) {
|
|
5
|
+
if (normalizedPath.endsWith(".mdx") || normalizedPath.endsWith(".md")) {
|
|
6
6
|
const matchingKey = keys.find((key) => {
|
|
7
7
|
if (key.endsWith(`/${normalizedPath}`)) return true;
|
|
8
8
|
if (key === `@content/${normalizedPath}`) return true;
|
|
@@ -15,8 +15,11 @@ function findMdxModule(modules, path) {
|
|
|
15
15
|
}
|
|
16
16
|
const candidates = [
|
|
17
17
|
`${normalizedPath}/index.mdx`,
|
|
18
|
+
`${normalizedPath}/index.md`,
|
|
18
19
|
`${normalizedPath}/README.mdx`,
|
|
19
|
-
`${normalizedPath}.
|
|
20
|
+
`${normalizedPath}/README.md`,
|
|
21
|
+
`${normalizedPath}.mdx`,
|
|
22
|
+
`${normalizedPath}.md`
|
|
20
23
|
];
|
|
21
24
|
for (const candidate of candidates) {
|
|
22
25
|
const matchingKey = keys.find((key) => {
|
|
@@ -67,7 +70,7 @@ function useMDXContent(path) {
|
|
|
67
70
|
function findSlidesModule(modules, path) {
|
|
68
71
|
const keys = Object.keys(modules);
|
|
69
72
|
const normalizedPath = path.replace(/^\//, "");
|
|
70
|
-
if (normalizedPath.endsWith(".mdx")) {
|
|
73
|
+
if (normalizedPath.endsWith(".mdx") || normalizedPath.endsWith(".md")) {
|
|
71
74
|
const matchingKey = keys.find((key) => {
|
|
72
75
|
if (key.endsWith(`/${normalizedPath}`)) return true;
|
|
73
76
|
if (key === `@content/${normalizedPath}`) return true;
|
|
@@ -80,7 +83,9 @@ function findSlidesModule(modules, path) {
|
|
|
80
83
|
}
|
|
81
84
|
const candidates = [
|
|
82
85
|
`${normalizedPath}/SLIDES.mdx`,
|
|
83
|
-
`${normalizedPath}/
|
|
86
|
+
`${normalizedPath}/SLIDES.md`,
|
|
87
|
+
`${normalizedPath}/index.slides.mdx`,
|
|
88
|
+
`${normalizedPath}/index.slides.md`
|
|
84
89
|
];
|
|
85
90
|
for (const candidate of candidates) {
|
|
86
91
|
const matchingKey = keys.find((key) => {
|
|
@@ -130,7 +135,62 @@ function useMDXSlides(path) {
|
|
|
130
135
|
}, [path]);
|
|
131
136
|
return { Content, frontmatter, slideCount, loading, error };
|
|
132
137
|
}
|
|
138
|
+
function findIndexModule(modules, path) {
|
|
139
|
+
const keys = Object.keys(modules);
|
|
140
|
+
const normalizedPath = path.replace(/^\//, "") || ".";
|
|
141
|
+
const candidates = normalizedPath === "." ? ["index.mdx", "index.md"] : [`${normalizedPath}/index.mdx`, `${normalizedPath}/index.md`];
|
|
142
|
+
for (const candidate of candidates) {
|
|
143
|
+
const matchingKey = keys.find((key) => {
|
|
144
|
+
if (key.endsWith(`/${candidate}`)) return true;
|
|
145
|
+
if (key === `@content/${candidate}`) return true;
|
|
146
|
+
if (key === candidate) return true;
|
|
147
|
+
return false;
|
|
148
|
+
});
|
|
149
|
+
if (matchingKey) {
|
|
150
|
+
return modules[matchingKey];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
function useIndexContent(path) {
|
|
156
|
+
const [Content, setContent] = useState(null);
|
|
157
|
+
const [frontmatter, setFrontmatter] = useState(void 0);
|
|
158
|
+
const [loading, setLoading] = useState(true);
|
|
159
|
+
const [notFound, setNotFound] = useState(false);
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
let cancelled = false;
|
|
162
|
+
setLoading(true);
|
|
163
|
+
setNotFound(false);
|
|
164
|
+
import("virtual:content-modules").then(({ modules }) => {
|
|
165
|
+
const loader = findIndexModule(modules, path);
|
|
166
|
+
if (!loader) {
|
|
167
|
+
if (!cancelled) {
|
|
168
|
+
setNotFound(true);
|
|
169
|
+
setLoading(false);
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return loader();
|
|
174
|
+
}).then((mod) => {
|
|
175
|
+
if (mod && !cancelled) {
|
|
176
|
+
setContent(() => mod.default);
|
|
177
|
+
setFrontmatter(mod.frontmatter);
|
|
178
|
+
setLoading(false);
|
|
179
|
+
}
|
|
180
|
+
}).catch(() => {
|
|
181
|
+
if (!cancelled) {
|
|
182
|
+
setNotFound(true);
|
|
183
|
+
setLoading(false);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return () => {
|
|
187
|
+
cancelled = true;
|
|
188
|
+
};
|
|
189
|
+
}, [path]);
|
|
190
|
+
return { Content, frontmatter, loading, notFound };
|
|
191
|
+
}
|
|
133
192
|
export {
|
|
193
|
+
useIndexContent,
|
|
134
194
|
useMDXContent,
|
|
135
195
|
useMDXSlides
|
|
136
196
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mdx-content.js","sources":["../../../src/hooks/use-mdx-content.ts"],"sourcesContent":["import { useState, useEffect } from 'react'\nimport type { ComponentType } from 'react'\n\ninterface MDXModule {\n default: ComponentType<{ components?: Record<string, ComponentType> }>\n frontmatter?: {\n title?: string\n description?: string\n date?: string\n visibility?: string\n draft?: boolean\n }\n slideCount?: number // Exported by remark-slides plugin for SLIDES.mdx files\n}\n\ntype ModuleLoader = () => Promise<MDXModule>\ntype ModuleMap = Record<string, ModuleLoader>\n\n/**\n * Find MDX module by path. Supports:\n * - Full path: \"docs/intro.mdx\" -> matches exactly\n * - Folder path: \"docs\" -> matches \"docs/index.mdx\", \"docs/README.mdx\", or \"docs.mdx\"\n */\nfunction findMdxModule(modules: ModuleMap, path: string): ModuleLoader | null {\n const keys = Object.keys(modules)\n\n // Normalize path - remove leading slash if present\n const normalizedPath = path.replace(/^\\//, '')\n\n // If path already ends with .mdx, match exactly\n if (normalizedPath.endsWith('.mdx')) {\n // Try multiple matching strategies for different Vite glob formats\n const matchingKey = keys.find(key => {\n // Strategy 1: Key ends with /path (e.g., @content/docs/foo.mdx matches docs/foo.mdx)\n if (key.endsWith(`/${normalizedPath}`)) return true\n // Strategy 2: Key equals @content/path (alias form)\n if (key === `@content/${normalizedPath}`) return true\n // Strategy 3: Key equals /@content/path (with leading slash)\n if (key === `/@content/${normalizedPath}`) return true\n // Strategy 4: Key equals path directly\n if (key === normalizedPath) return true\n // Strategy 5: Key equals /path (with leading slash)\n if (key === `/${normalizedPath}`) return true\n return false\n })\n return matchingKey ? modules[matchingKey] : null\n }\n\n // Otherwise, try folder conventions in order of preference:\n // 1. folder/index.mdx (modern convention)\n // 2. folder/README.mdx (current convention)\n // 3. folder.mdx (file alongside folders)\n const candidates = [\n `${normalizedPath}/index.mdx`,\n `${normalizedPath}/README.mdx`,\n `${normalizedPath}.mdx`,\n ]\n\n for (const candidate of candidates) {\n const matchingKey = keys.find(key => {\n if (key.endsWith(`/${candidate}`)) return true\n if (key === `@content/${candidate}`) return true\n if (key === candidate) return true\n return false\n })\n if (matchingKey) {\n return modules[matchingKey]\n }\n }\n\n return null\n}\n\nexport function useMDXContent(path: string) {\n const [Content, setContent] = useState<MDXModule['default'] | null>(null)\n const [frontmatter, setFrontmatter] = useState<MDXModule['frontmatter']>(undefined)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState<Error | null>(null)\n\n useEffect(() => {\n let cancelled = false\n setLoading(true)\n setError(null)\n\n // Dynamic import to avoid pre-bundling issues\n import('virtual:content-modules')\n .then(({ modules }) => {\n const loader = findMdxModule(modules as ModuleMap, path)\n\n if (!loader) {\n throw new Error(`MDX module not found for path: ${path}`)\n }\n\n return loader()\n })\n .then((mod) => {\n if (!cancelled) {\n setContent(() => mod.default)\n setFrontmatter(mod.frontmatter)\n setLoading(false)\n }\n })\n .catch((err) => {\n if (!cancelled) {\n setError(err)\n setLoading(false)\n }\n })\n\n return () => {\n cancelled = true\n }\n }, [path])\n\n return { Content, frontmatter, loading, error }\n}\n\n/**\n * Find slides module by path. Supports:\n * - Full path: \"docs/intro.slides.mdx\" or \"docs/SLIDES.mdx\" -> matches exactly\n * - Folder path: \"docs\" -> matches \"docs/SLIDES.mdx\" or \"docs/index.slides.mdx\"\n */\nfunction findSlidesModule(modules: ModuleMap, path: string): ModuleLoader | null {\n const keys = Object.keys(modules)\n\n // Normalize path - remove leading slash if present\n const normalizedPath = path.replace(/^\\//, '')\n\n // If path already ends with .mdx, match exactly\n if (normalizedPath.endsWith('.mdx')) {\n // Try multiple matching strategies for different Vite glob formats\n const matchingKey = keys.find(key => {\n // Strategy 1: Key ends with /path (e.g., @content/docs/foo.slides.mdx matches docs/foo.slides.mdx)\n if (key.endsWith(`/${normalizedPath}`)) return true\n // Strategy 2: Key equals @content/path (alias form)\n if (key === `@content/${normalizedPath}`) return true\n // Strategy 3: Key equals /@content/path (with leading slash)\n if (key === `/@content/${normalizedPath}`) return true\n // Strategy 4: Key equals path directly\n if (key === normalizedPath) return true\n // Strategy 5: Key equals /path (with leading slash)\n if (key === `/${normalizedPath}`) return true\n return false\n })\n return matchingKey ? modules[matchingKey] : null\n }\n\n // Otherwise, try folder conventions:\n // 1. folder/SLIDES.mdx (current convention)\n // 2. folder/index.slides.mdx (alternative)\n const candidates = [\n `${normalizedPath}/SLIDES.mdx`,\n `${normalizedPath}/index.slides.mdx`,\n ]\n\n for (const candidate of candidates) {\n const matchingKey = keys.find(key => {\n if (key.endsWith(`/${candidate}`)) return true\n if (key === `@content/${candidate}`) return true\n if (key === candidate) return true\n return false\n })\n if (matchingKey) {\n return modules[matchingKey]\n }\n }\n\n return null\n}\n\nexport function useMDXSlides(path: string) {\n const [Content, setContent] = useState<MDXModule['default'] | null>(null)\n const [frontmatter, setFrontmatter] = useState<MDXModule['frontmatter']>(undefined)\n const [slideCount, setSlideCount] = useState<number | undefined>(undefined)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState<Error | null>(null)\n\n useEffect(() => {\n let cancelled = false\n setLoading(true)\n setError(null)\n\n // Dynamic import to avoid pre-bundling issues\n import('virtual:content-modules')\n .then(({ slides }) => {\n const loader = findSlidesModule(slides as ModuleMap, path)\n\n if (!loader) {\n throw new Error(`Slides module not found for path: ${path}`)\n }\n\n return loader()\n })\n .then((mod) => {\n if (!cancelled) {\n setContent(() => mod.default)\n setFrontmatter(mod.frontmatter)\n setSlideCount(mod.slideCount)\n setLoading(false)\n }\n })\n .catch((err) => {\n if (!cancelled) {\n setError(err)\n setLoading(false)\n }\n })\n\n return () => {\n cancelled = true\n }\n }, [path])\n\n return { Content, frontmatter, slideCount, loading, error }\n}\n"],"names":[],"mappings":";AAuBA,SAAS,cAAc,SAAoB,MAAmC;AAC5E,QAAM,OAAO,OAAO,KAAK,OAAO;AAGhC,QAAM,iBAAiB,KAAK,QAAQ,OAAO,EAAE;AAG7C,MAAI,eAAe,SAAS,MAAM,GAAG;AAEnC,UAAM,cAAc,KAAK,KAAK,CAAA,QAAO;AAEnC,UAAI,IAAI,SAAS,IAAI,cAAc,EAAE,EAAG,QAAO;AAE/C,UAAI,QAAQ,YAAY,cAAc,GAAI,QAAO;AAEjD,UAAI,QAAQ,aAAa,cAAc,GAAI,QAAO;AAElD,UAAI,QAAQ,eAAgB,QAAO;AAEnC,UAAI,QAAQ,IAAI,cAAc,GAAI,QAAO;AACzC,aAAO;AAAA,IACT,CAAC;AACD,WAAO,cAAc,QAAQ,WAAW,IAAI;AAAA,EAC9C;AAMA,QAAM,aAAa;AAAA,IACjB,GAAG,cAAc;AAAA,IACjB,GAAG,cAAc;AAAA,IACjB,GAAG,cAAc;AAAA,EAAA;AAGnB,aAAW,aAAa,YAAY;AAClC,UAAM,cAAc,KAAK,KAAK,CAAA,QAAO;AACnC,UAAI,IAAI,SAAS,IAAI,SAAS,EAAE,EAAG,QAAO;AAC1C,UAAI,QAAQ,YAAY,SAAS,GAAI,QAAO;AAC5C,UAAI,QAAQ,UAAW,QAAO;AAC9B,aAAO;AAAA,IACT,CAAC;AACD,QAAI,aAAa;AACf,aAAO,QAAQ,WAAW;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,cAAc,MAAc;AAC1C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAsC,IAAI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,UAAI,CAAC,WAAW;AACd,iBAAS,GAAG;AACZ,mBAAW,KAAK;AAAA,MAClB;AAAA,IACF,CAAC;AAEH,WAAO,MAAM;AACX,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,IAAI,CAAC;AAET,SAAO,EAAE,SAAS,aAAa,YAAY,SAAS,MAAA;AACtD;"}
|
|
1
|
+
{"version":3,"file":"use-mdx-content.js","sources":["../../../src/hooks/use-mdx-content.ts"],"sourcesContent":["import { useState, useEffect } from 'react'\nimport type { ComponentType } from 'react'\n\ninterface MDXModule {\n default: ComponentType<{ components?: Record<string, ComponentType> }>\n frontmatter?: {\n title?: string\n description?: string\n date?: string\n visibility?: string\n draft?: boolean\n }\n slideCount?: number // Exported by remark-slides plugin for SLIDES.mdx files\n}\n\ntype ModuleLoader = () => Promise<MDXModule>\ntype ModuleMap = Record<string, ModuleLoader>\n\n/**\n * Find MDX/MD module by path. Supports:\n * - Full path: \"docs/intro.mdx\" or \"docs/intro.md\" -> matches exactly\n * - Folder path: \"docs\" -> matches \"docs/index.mdx\", \"docs/README.mdx\", or \"docs.mdx\" (and .md variants)\n */\nfunction findMdxModule(modules: ModuleMap, path: string): ModuleLoader | null {\n const keys = Object.keys(modules)\n\n // Normalize path - remove leading slash if present\n const normalizedPath = path.replace(/^\\//, '')\n\n // If path already ends with .mdx or .md, match exactly\n if (normalizedPath.endsWith('.mdx') || normalizedPath.endsWith('.md')) {\n // Try multiple matching strategies for different Vite glob formats\n const matchingKey = keys.find(key => {\n // Strategy 1: Key ends with /path (e.g., @content/docs/foo.mdx matches docs/foo.mdx)\n if (key.endsWith(`/${normalizedPath}`)) return true\n // Strategy 2: Key equals @content/path (alias form)\n if (key === `@content/${normalizedPath}`) return true\n // Strategy 3: Key equals /@content/path (with leading slash)\n if (key === `/@content/${normalizedPath}`) return true\n // Strategy 4: Key equals path directly\n if (key === normalizedPath) return true\n // Strategy 5: Key equals /path (with leading slash)\n if (key === `/${normalizedPath}`) return true\n return false\n })\n return matchingKey ? modules[matchingKey] : null\n }\n\n // Otherwise, try folder conventions in order of preference:\n // 1. folder/index.mdx (modern convention)\n // 2. folder/README.mdx (current convention)\n // 3. folder.mdx (file alongside folders)\n // Also try .md variants\n const candidates = [\n `${normalizedPath}/index.mdx`,\n `${normalizedPath}/index.md`,\n `${normalizedPath}/README.mdx`,\n `${normalizedPath}/README.md`,\n `${normalizedPath}.mdx`,\n `${normalizedPath}.md`,\n ]\n\n for (const candidate of candidates) {\n const matchingKey = keys.find(key => {\n if (key.endsWith(`/${candidate}`)) return true\n if (key === `@content/${candidate}`) return true\n if (key === candidate) return true\n return false\n })\n if (matchingKey) {\n return modules[matchingKey]\n }\n }\n\n return null\n}\n\nexport function useMDXContent(path: string) {\n const [Content, setContent] = useState<MDXModule['default'] | null>(null)\n const [frontmatter, setFrontmatter] = useState<MDXModule['frontmatter']>(undefined)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState<Error | null>(null)\n\n useEffect(() => {\n let cancelled = false\n setLoading(true)\n setError(null)\n\n // Dynamic import to avoid pre-bundling issues\n import('virtual:content-modules')\n .then(({ modules }) => {\n const loader = findMdxModule(modules as ModuleMap, path)\n\n if (!loader) {\n throw new Error(`MDX module not found for path: ${path}`)\n }\n\n return loader()\n })\n .then((mod) => {\n if (!cancelled) {\n setContent(() => mod.default)\n setFrontmatter(mod.frontmatter)\n setLoading(false)\n }\n })\n .catch((err) => {\n if (!cancelled) {\n setError(err)\n setLoading(false)\n }\n })\n\n return () => {\n cancelled = true\n }\n }, [path])\n\n return { Content, frontmatter, loading, error }\n}\n\n/**\n * Find slides module by path. Supports:\n * - Full path: \"docs/intro.slides.mdx\" or \"docs/SLIDES.mdx\" -> matches exactly\n * - Folder path: \"docs\" -> matches \"docs/SLIDES.mdx\" or \"docs/index.slides.mdx\"\n */\nfunction findSlidesModule(modules: ModuleMap, path: string): ModuleLoader | null {\n const keys = Object.keys(modules)\n\n // Normalize path - remove leading slash if present\n const normalizedPath = path.replace(/^\\//, '')\n\n // If path already ends with .mdx or .md, match exactly\n if (normalizedPath.endsWith('.mdx') || normalizedPath.endsWith('.md')) {\n // Try multiple matching strategies for different Vite glob formats\n const matchingKey = keys.find(key => {\n // Strategy 1: Key ends with /path (e.g., @content/docs/foo.slides.mdx matches docs/foo.slides.mdx)\n if (key.endsWith(`/${normalizedPath}`)) return true\n // Strategy 2: Key equals @content/path (alias form)\n if (key === `@content/${normalizedPath}`) return true\n // Strategy 3: Key equals /@content/path (with leading slash)\n if (key === `/@content/${normalizedPath}`) return true\n // Strategy 4: Key equals path directly\n if (key === normalizedPath) return true\n // Strategy 5: Key equals /path (with leading slash)\n if (key === `/${normalizedPath}`) return true\n return false\n })\n return matchingKey ? modules[matchingKey] : null\n }\n\n // Otherwise, try folder conventions:\n // 1. folder/SLIDES.mdx (current convention)\n // 2. folder/index.slides.mdx (alternative)\n // Also try .md variants\n const candidates = [\n `${normalizedPath}/SLIDES.mdx`,\n `${normalizedPath}/SLIDES.md`,\n `${normalizedPath}/index.slides.mdx`,\n `${normalizedPath}/index.slides.md`,\n ]\n\n for (const candidate of candidates) {\n const matchingKey = keys.find(key => {\n if (key.endsWith(`/${candidate}`)) return true\n if (key === `@content/${candidate}`) return true\n if (key === candidate) return true\n return false\n })\n if (matchingKey) {\n return modules[matchingKey]\n }\n }\n\n return null\n}\n\nexport function useMDXSlides(path: string) {\n const [Content, setContent] = useState<MDXModule['default'] | null>(null)\n const [frontmatter, setFrontmatter] = useState<MDXModule['frontmatter']>(undefined)\n const [slideCount, setSlideCount] = useState<number | undefined>(undefined)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState<Error | null>(null)\n\n useEffect(() => {\n let cancelled = false\n setLoading(true)\n setError(null)\n\n // Dynamic import to avoid pre-bundling issues\n import('virtual:content-modules')\n .then(({ slides }) => {\n const loader = findSlidesModule(slides as ModuleMap, path)\n\n if (!loader) {\n throw new Error(`Slides module not found for path: ${path}`)\n }\n\n return loader()\n })\n .then((mod) => {\n if (!cancelled) {\n setContent(() => mod.default)\n setFrontmatter(mod.frontmatter)\n setSlideCount(mod.slideCount)\n setLoading(false)\n }\n })\n .catch((err) => {\n if (!cancelled) {\n setError(err)\n setLoading(false)\n }\n })\n\n return () => {\n cancelled = true\n }\n }, [path])\n\n return { Content, frontmatter, slideCount, loading, error }\n}\n\n/**\n * Find only index.mdx or index.md in a directory (not README or other conventions)\n */\nfunction findIndexModule(modules: ModuleMap, path: string): ModuleLoader | null {\n const keys = Object.keys(modules)\n\n // Normalize path - remove leading slash, handle root\n const normalizedPath = path.replace(/^\\//, '') || '.'\n\n // Only look for index.mdx or index.md\n const candidates = normalizedPath === '.'\n ? ['index.mdx', 'index.md']\n : [`${normalizedPath}/index.mdx`, `${normalizedPath}/index.md`]\n\n for (const candidate of candidates) {\n const matchingKey = keys.find(key => {\n if (key.endsWith(`/${candidate}`)) return true\n if (key === `@content/${candidate}`) return true\n if (key === candidate) return true\n return false\n })\n if (matchingKey) {\n return modules[matchingKey]\n }\n }\n\n return null\n}\n\n/**\n * Hook for loading index.mdx/index.md content only.\n * Returns notFound: true if no index file exists (instead of throwing an error).\n */\nexport function useIndexContent(path: string) {\n const [Content, setContent] = useState<MDXModule['default'] | null>(null)\n const [frontmatter, setFrontmatter] = useState<MDXModule['frontmatter']>(undefined)\n const [loading, setLoading] = useState(true)\n const [notFound, setNotFound] = useState(false)\n\n useEffect(() => {\n let cancelled = false\n setLoading(true)\n setNotFound(false)\n\n import('virtual:content-modules')\n .then(({ modules }) => {\n const loader = findIndexModule(modules as ModuleMap, path)\n\n if (!loader) {\n // No index file - this is not an error, just means fallback to directory listing\n if (!cancelled) {\n setNotFound(true)\n setLoading(false)\n }\n return null\n }\n\n return loader()\n })\n .then((mod) => {\n if (mod && !cancelled) {\n setContent(() => mod.default)\n setFrontmatter(mod.frontmatter)\n setLoading(false)\n }\n })\n .catch(() => {\n // Treat load errors as not found\n if (!cancelled) {\n setNotFound(true)\n setLoading(false)\n }\n })\n\n return () => {\n cancelled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AA,MACT;AAEA,aAAO,OAAA;AAAA,IACT,CAAC,EACA,KAAK,CAAC,QAAQ;AACb,UAAI,OAAO,CAAC,WAAW;AACrB,mBAAW,MAAM,IAAI,OAAO;AAC5B,uBAAe,IAAI,WAAW;AAC9B,mBAAW,KAAK;AAAA,MAClB;AAAA,IACF,CAAC,EACA,MAAM,MAAM;AAEX,UAAI,CAAC,WAAW;AACd,oBAAY,IAAI;AAChB,mBAAW,KAAK;AAAA,MAClB;AAAA,IACF,CAAC;AAEH,WAAO,MAAM;AACX,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,IAAI,CAAC;AAET,SAAO,EAAE,SAAS,aAAa,SAAS,SAAA;AAC1C;"}
|
|
@@ -3,24 +3,6 @@ function getFrontmatter(post) {
|
|
|
3
3
|
var _a, _b, _c;
|
|
4
4
|
return ((_a = post.readme) == null ? void 0 : _a.frontmatter) || ((_b = post.file) == null ? void 0 : _b.frontmatter) || ((_c = post.slides) == null ? void 0 : _c.frontmatter);
|
|
5
5
|
}
|
|
6
|
-
function hasDate(post) {
|
|
7
|
-
const frontmatter = getFrontmatter(post);
|
|
8
|
-
return (frontmatter == null ? void 0 : frontmatter.date) !== void 0 && frontmatter.date !== null && frontmatter.date !== "";
|
|
9
|
-
}
|
|
10
|
-
function filterByView(posts, view) {
|
|
11
|
-
if (view === "all") return posts;
|
|
12
|
-
if (view === "posts") return posts.filter(hasDate);
|
|
13
|
-
if (view === "docs") return posts.filter((post) => !hasDate(post));
|
|
14
|
-
return posts;
|
|
15
|
-
}
|
|
16
|
-
function getViewCounts(posts) {
|
|
17
|
-
const dated = posts.filter(hasDate).length;
|
|
18
|
-
return {
|
|
19
|
-
posts: dated,
|
|
20
|
-
docs: posts.length - dated,
|
|
21
|
-
all: posts.length
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
6
|
function directoryToPostEntries(directory) {
|
|
25
7
|
const folders = directory.children.filter((c) => c.type === "directory");
|
|
26
8
|
const standaloneFiles = findMdxFiles(directory);
|
|
@@ -59,10 +41,7 @@ function filterVisiblePosts(posts) {
|
|
|
59
41
|
}
|
|
60
42
|
export {
|
|
61
43
|
directoryToPostEntries,
|
|
62
|
-
filterByView,
|
|
63
44
|
filterVisiblePosts,
|
|
64
|
-
getFrontmatter
|
|
65
|
-
getViewCounts,
|
|
66
|
-
hasDate
|
|
45
|
+
getFrontmatter
|
|
67
46
|
};
|
|
68
47
|
//# sourceMappingURL=content-classification.js.map
|