@ox-content/vite-plugin 2.88.0 → 2.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -568,6 +568,297 @@ interface TransformAllOptions {
568
568
  */
569
569
  declare function transformAllPlugins(html: string, options?: TransformAllOptions): Promise<string>;
570
570
  //#endregion
571
+ //#region src/page-context.d.ts
572
+ /**
573
+ * Base page props available for all pages.
574
+ */
575
+ interface BasePageProps {
576
+ /** Page title from frontmatter or first heading */
577
+ title: string;
578
+ /** Page description from frontmatter */
579
+ description?: string;
580
+ /** Rendered HTML content */
581
+ html: string;
582
+ /** Table of contents entries */
583
+ toc: TocEntry[];
584
+ /** Last git commit timestamp in milliseconds */
585
+ lastUpdated?: number;
586
+ /** Source file path (relative to docs root) */
587
+ path: string;
588
+ /** Output URL path */
589
+ url: string;
590
+ /** Raw frontmatter object */
591
+ frontmatter: Record<string, unknown>;
592
+ /** Layout name from frontmatter */
593
+ layout?: string;
594
+ }
595
+ /**
596
+ * Extended page props with custom frontmatter.
597
+ */
598
+ type PageProps<T extends Record<string, unknown> = Record<string, unknown>> = BasePageProps & {
599
+ /** Custom frontmatter fields */
600
+ frontmatter: T & Record<string, unknown>;
601
+ };
602
+ /**
603
+ * Site-wide configuration available in context.
604
+ */
605
+ interface SiteConfig {
606
+ /** Site name */
607
+ name: string;
608
+ /** Base URL path */
609
+ base: string;
610
+ /** All pages in the site */
611
+ pages: BasePageProps[];
612
+ /** Navigation groups */
613
+ nav: NavGroup[];
614
+ }
615
+ /**
616
+ * Navigation group.
617
+ */
618
+ interface NavGroup {
619
+ title: string;
620
+ items: NavItem[];
621
+ }
622
+ /**
623
+ * Navigation item.
624
+ */
625
+ interface NavItem {
626
+ title: string;
627
+ path: string;
628
+ href: string;
629
+ }
630
+ /**
631
+ * Complete render context.
632
+ */
633
+ interface RenderContext<T extends Record<string, unknown> = Record<string, unknown>> {
634
+ /** Current page props */
635
+ page: PageProps<T>;
636
+ /** Site configuration */
637
+ site: SiteConfig;
638
+ }
639
+ /**
640
+ * Sets the current render context.
641
+ * Called internally during page rendering.
642
+ * @internal
643
+ */
644
+ declare function setRenderContext(ctx: RenderContext): void;
645
+ /**
646
+ * Clears the current render context.
647
+ * Called internally after page rendering.
648
+ * @internal
649
+ */
650
+ declare function clearRenderContext(): void;
651
+ /**
652
+ * Gets the current page props.
653
+ *
654
+ * @returns The current page props
655
+ * @throws Error if called outside of a render context
656
+ *
657
+ * @example
658
+ * ```tsx
659
+ * function PageTitle() {
660
+ * const page = usePageProps();
661
+ * return <h1>{page.title}</h1>;
662
+ * }
663
+ * ```
664
+ */
665
+ declare function usePageProps<T extends Record<string, unknown> = Record<string, unknown>>(): PageProps<T>;
666
+ /**
667
+ * Gets the site configuration.
668
+ *
669
+ * @returns The site configuration
670
+ * @throws Error if called outside of a render context
671
+ *
672
+ * @example
673
+ * ```tsx
674
+ * function SiteHeader() {
675
+ * const site = useSiteConfig();
676
+ * return <header>{site.name}</header>;
677
+ * }
678
+ * ```
679
+ */
680
+ declare function useSiteConfig(): SiteConfig;
681
+ /**
682
+ * Gets the full render context.
683
+ *
684
+ * @returns The complete render context
685
+ * @throws Error if called outside of a render context
686
+ *
687
+ * @example
688
+ * ```tsx
689
+ * function Layout({ children }) {
690
+ * const ctx = useRenderContext();
691
+ * return (
692
+ * <html>
693
+ * <head><title>{ctx.page.title} - {ctx.site.name}</title></head>
694
+ * <body>{children}</body>
695
+ * </html>
696
+ * );
697
+ * }
698
+ * ```
699
+ */
700
+ declare function useRenderContext<T extends Record<string, unknown> = Record<string, unknown>>(): RenderContext<T>;
701
+ /**
702
+ * Gets the navigation groups.
703
+ *
704
+ * @example
705
+ * ```tsx
706
+ * function Sidebar() {
707
+ * const nav = useNav();
708
+ * return (
709
+ * <nav>
710
+ * {each(nav, (group) => (
711
+ * <div>
712
+ * <h3>{group.title}</h3>
713
+ * <ul>
714
+ * {each(group.items, (item) => (
715
+ * <li><a href={item.href}>{item.title}</a></li>
716
+ * ))}
717
+ * </ul>
718
+ * </div>
719
+ * ))}
720
+ * </nav>
721
+ * );
722
+ * }
723
+ * ```
724
+ */
725
+ declare function useNav(): NavGroup[];
726
+ /**
727
+ * Checks if the given path is the current page.
728
+ *
729
+ * @example
730
+ * ```tsx
731
+ * function NavLink({ href, children }) {
732
+ * const isActive = useIsActive(href);
733
+ * return <a href={href} class={isActive ? 'active' : ''}>{children}</a>;
734
+ * }
735
+ * ```
736
+ */
737
+ declare function useIsActive(path: string): boolean;
738
+ /**
739
+ * Schema for frontmatter type generation.
740
+ */
741
+ interface FrontmatterSchema {
742
+ /** Field name */
743
+ name: string;
744
+ /** TypeScript type */
745
+ type: string;
746
+ /** Whether the field is optional */
747
+ optional: boolean;
748
+ /** JSDoc description */
749
+ description?: string;
750
+ }
751
+ /**
752
+ * Infers TypeScript types from frontmatter values.
753
+ */
754
+ declare function inferType(value: unknown): string;
755
+ /**
756
+ * Generates TypeScript interface from frontmatter samples.
757
+ */
758
+ declare function generateFrontmatterTypes(samples: Record<string, unknown>[], interfaceName?: string): string;
759
+ //#endregion
760
+ //#region src/theme-renderer.d.ts
761
+ /**
762
+ * Theme component type.
763
+ */
764
+ type ThemeComponent = (props: ThemeProps) => JSXNode;
765
+ /**
766
+ * Props passed to the theme component.
767
+ */
768
+ interface ThemeProps {
769
+ /** Rendered page content as JSX */
770
+ children: JSXNode;
771
+ }
772
+ /**
773
+ * Page data for rendering.
774
+ */
775
+ interface PageData {
776
+ /** Page title */
777
+ title: string;
778
+ /** Page description */
779
+ description?: string;
780
+ /** Rendered HTML content */
781
+ html: string;
782
+ /** Table of contents */
783
+ toc: TocEntry[];
784
+ /** Last git commit timestamp in milliseconds */
785
+ lastUpdated?: number;
786
+ /** Source file path */
787
+ path: string;
788
+ /** Output URL path */
789
+ url: string;
790
+ /** Frontmatter */
791
+ frontmatter: Record<string, unknown>;
792
+ /** Layout name */
793
+ layout?: string;
794
+ }
795
+ /**
796
+ * Theme render options.
797
+ */
798
+ interface ThemeRenderOptions {
799
+ /** Theme component to use */
800
+ theme: ThemeComponent;
801
+ /** Site name */
802
+ siteName: string;
803
+ /** Base URL path */
804
+ base: string;
805
+ /** Navigation groups */
806
+ nav: NavGroup[];
807
+ /** All pages (for site context) */
808
+ pages: PageData[];
809
+ /** Output directory for type definitions */
810
+ typesOutDir?: string;
811
+ }
812
+ /**
813
+ * Renders a page using the theme component.
814
+ *
815
+ * @param page - Page data to render
816
+ * @param options - Theme render options
817
+ * @returns Rendered HTML string
818
+ */
819
+ declare function renderPage(page: PageData, options: ThemeRenderOptions): string;
820
+ /**
821
+ * Renders all pages and generates type definitions.
822
+ *
823
+ * @param pages - All pages to render
824
+ * @param options - Theme render options
825
+ * @returns Map of output paths to rendered HTML
826
+ */
827
+ declare function renderAllPages(pages: PageData[], options: ThemeRenderOptions): Promise<Map<string, string>>;
828
+ /**
829
+ * Generates TypeScript type definitions from page frontmatter.
830
+ *
831
+ * @param pages - All pages
832
+ * @param outDir - Output directory for types
833
+ */
834
+ declare function generateTypes(pages: PageData[], outDir: string): Promise<void>;
835
+ /**
836
+ * Default theme component.
837
+ * A minimal theme that renders page content with basic styling.
838
+ */
839
+ declare function DefaultTheme({ children }: ThemeProps): JSXNode;
840
+ /**
841
+ * Creates a theme with layout switching support.
842
+ *
843
+ * @example
844
+ * ```tsx
845
+ * import { createTheme } from '@ox-content/vite-plugin';
846
+ * import { DefaultLayout } from './layouts/Default';
847
+ * import { EntryLayout } from './layouts/Entry';
848
+ *
849
+ * export default createTheme({
850
+ * layouts: {
851
+ * default: DefaultLayout,
852
+ * entry: EntryLayout,
853
+ * },
854
+ * });
855
+ * ```
856
+ */
857
+ declare function createTheme(config: {
858
+ layouts: Record<string, ThemeComponent>;
859
+ defaultLayout?: string;
860
+ }): ThemeComponent;
861
+ //#endregion
571
862
  //#region src/types.d.ts
572
863
  /**
573
864
  * Hero section action button.
@@ -723,22 +1014,71 @@ interface SsgOptions {
723
1014
  */
724
1015
  bare?: boolean;
725
1016
  /**
726
- * Site name shown in the default theme header and title suffix.
1017
+ * Site name shown in the default theme header and title suffix.
1018
+ *
1019
+ * When omitted, the renderer falls back to project metadata where available.
1020
+ *
1021
+ * @default undefined
1022
+ */
1023
+ siteName?: string;
1024
+ /**
1025
+ * Static Open Graph image URL used for social sharing.
1026
+ *
1027
+ * When `generateOgImage` is enabled, this value is still useful as a fallback
1028
+ * for pages that cannot produce a generated image.
1029
+ *
1030
+ * @default undefined
1031
+ */
1032
+ ogImage?: string;
1033
+ /**
1034
+ * Render each page with a JSX theme component instead of the built-in
1035
+ * renderer.
1036
+ *
1037
+ * The component owns the whole document, so `theme`, `bare` and the head
1038
+ * metadata options do not apply — everything from `<html>` down is yours.
1039
+ * Compose one per layout with `createTheme()`, and read the current page
1040
+ * through `usePageProps()` / `useSiteConfig()`.
1041
+ *
1042
+ * ```ts
1043
+ * ssg: { render: createTheme({ layouts: { default: DefaultLayout } }) }
1044
+ * ```
1045
+ *
1046
+ * @default undefined
1047
+ */
1048
+ render?: ThemeComponent;
1049
+ /**
1050
+ * `lang` attribute for the generated `<html>` element.
1051
+ *
1052
+ * Bare mode uses this verbatim; themed pages derive it from `i18n` instead.
1053
+ *
1054
+ * @default "en"
1055
+ */
1056
+ lang?: string;
1057
+ /**
1058
+ * Raw markup appended to `<head>`.
1059
+ *
1060
+ * Bare mode only — themed pages own their head. Use it for the stylesheet
1061
+ * your own build emits, or any tag the plugin does not generate.
1062
+ *
1063
+ * @default undefined
1064
+ */
1065
+ head?: string;
1066
+ /**
1067
+ * Raw markup inserted directly after `<body>`.
727
1068
  *
728
- * When omitted, the renderer falls back to project metadata where available.
1069
+ * Bare mode only. Use it for a site header that wraps the rendered page.
729
1070
  *
730
1071
  * @default undefined
731
1072
  */
732
- siteName?: string;
1073
+ bodyStart?: string;
733
1074
  /**
734
- * Static Open Graph image URL used for social sharing.
1075
+ * Raw markup inserted directly before `</body>`.
735
1076
  *
736
- * When `generateOgImage` is enabled, this value is still useful as a fallback
737
- * for pages that cannot produce a generated image.
1077
+ * Bare mode only. Use it for a site footer, or scripts you inject yourself.
738
1078
  *
739
1079
  * @default undefined
740
1080
  */
741
- ogImage?: string;
1081
+ bodyEnd?: string;
742
1082
  /**
743
1083
  * Generate one Open Graph image per page.
744
1084
  *
@@ -807,6 +1147,11 @@ interface ResolvedSsgOptions {
807
1147
  extension: string;
808
1148
  clean: boolean;
809
1149
  bare: boolean;
1150
+ render?: ThemeComponent;
1151
+ lang?: string;
1152
+ head?: string;
1153
+ bodyStart?: string;
1154
+ bodyEnd?: string;
810
1155
  siteName?: string;
811
1156
  ogImage?: string;
812
1157
  generateOgImage: boolean;
@@ -3360,437 +3705,158 @@ interface MarkdownLintFilesResult {
3360
3705
  diagnostics: MarkdownLintFileDiagnostic[];
3361
3706
  errorCount: number;
3362
3707
  files: MarkdownLintFileResult[];
3363
- infoCount: number;
3364
- warningCount: number;
3365
- }
3366
- /**
3367
- * Returns true if the file path is included by the configured glob filters.
3368
- */
3369
- declare function shouldLintMarkdownFile(filePath: string, options?: MarkdownLintFileOptions): boolean;
3370
- /**
3371
- * Lints a single Markdown file using project-style include/exclude settings.
3372
- *
3373
- * If the file is filtered out by `include` / `exclude`, the returned result is
3374
- * marked as `skipped` and contains no diagnostics.
3375
- */
3376
- declare function lintMarkdownFile(filePath: string, options?: MarkdownLintFileOptions): Promise<MarkdownLintFileResult>;
3377
- /**
3378
- * Lints all Markdown files matched by the configured include/exclude patterns.
3379
- */
3380
- declare function lintMarkdownFiles(options?: MarkdownLintFileOptions): Promise<MarkdownLintFilesResult>;
3381
- //#endregion
3382
- //#region src/ssg.d.ts
3383
- /**
3384
- * Deprecated compatibility export for consumers that imported the former
3385
- * TypeScript SSG template. HTML generation is Rust-backed now.
3386
- *
3387
- * @deprecated Use `generateHtmlPage`/`buildSsg` instead.
3388
- */
3389
- declare const DEFAULT_HTML_TEMPLATE = "<!-- ox-content default HTML template is Rust-backed -->";
3390
- /**
3391
- * Resolves SSG options with defaults.
3392
- */
3393
- declare function resolveSsgOptions(ssg: SsgOptions | boolean | undefined): ResolvedSsgOptions;
3394
- /**
3395
- * Builds all markdown files to static HTML.
3396
- */
3397
- declare function buildSsg(options: ResolvedOptions, root: string): Promise<{
3398
- files: string[];
3399
- errors: string[];
3400
- }>;
3401
- //#endregion
3402
- //#region src/search.d.ts
3403
- /**
3404
- * Resolves search options with defaults.
3405
- */
3406
- declare function resolveSearchOptions(options: SearchOptions | boolean | undefined): ResolvedSearchOptions;
3407
- /**
3408
- * Builds the search index from Markdown files.
3409
- */
3410
- declare function buildSearchIndex(srcDir: string, base: string, extensions?: readonly string[]): Promise<string>;
3411
- /**
3412
- * Writes the search index to a file.
3413
- */
3414
- declare function writeSearchIndex(indexJson: string, outDir: string): Promise<void>;
3415
- //#endregion
3416
- //#region src/collections.d.ts
3417
- declare function defineCollection<T extends CollectionOptions>(collection: T): T;
3418
- declare function defineCollections<T extends CollectionsOptions>(collections: T): T;
3419
- declare function resolveCollectionsOptions(options: CollectionsOptions | boolean | undefined): ResolvedCollectionsOptions;
3420
- declare function buildCollectionManifest(root: string, options: ResolvedOptions): Promise<CollectionManifest>;
3421
- declare function generateCollectionsVirtualModule(root: string, options: ResolvedOptions): Promise<string>;
3422
- //#endregion
3423
- //#region src/markdown.d.ts
3424
- declare const DEFAULT_MARKDOWN_EXTENSIONS: readonly [".md", ".markdown", ".mdx"];
3425
- declare function normalizeMarkdownExtensions(extensions?: readonly string[]): string[];
3426
- declare function isMarkdownFilePath(filePath: string, extensions?: readonly string[]): boolean;
3427
- declare function stripMarkdownExtension(filePath: string, extensions?: readonly string[]): string;
3428
- //#endregion
3429
- //#region src/vitepress.d.ts
3430
- interface VitePressLogo {
3431
- light?: string;
3432
- dark?: string;
3433
- src?: string;
3434
- alt?: string;
3435
- }
3436
- interface VitePressSocialLink {
3437
- icon: string;
3438
- link: string;
3439
- ariaLabel?: string;
3440
- }
3441
- interface VitePressFooter {
3442
- message?: string;
3443
- copyright?: string;
3444
- }
3445
- interface VitePressSidebarItem {
3446
- text?: string;
3447
- link?: string;
3448
- items?: VitePressSidebarItem[];
3449
- collapsed?: boolean;
3450
- }
3451
- type VitePressSidebar = VitePressSidebarItem[] | Record<string, VitePressSidebarItem[]>;
3452
- interface VitePressNavItem {
3453
- text?: string;
3454
- link?: string;
3455
- items?: VitePressNavItem[];
3456
- activeMatch?: string;
3457
- }
3458
- interface VitePressThemeConfig {
3459
- siteTitle?: string | false;
3460
- logo?: string | VitePressLogo;
3461
- nav?: VitePressNavItem[];
3462
- sidebar?: VitePressSidebar;
3463
- socialLinks?: VitePressSocialLink[];
3464
- footer?: VitePressFooter;
3465
- search?: {
3466
- placeholder?: string;
3467
- };
3468
- }
3469
- interface VitePressConfig {
3470
- title?: string;
3471
- description?: string;
3472
- base?: string;
3473
- themeConfig?: VitePressThemeConfig;
3474
- }
3475
- interface GenerateVitePressMigrationConfigOptions {
3476
- importSource?: string;
3477
- }
3478
- /**
3479
- * Converts a VitePress sidebar config into ox-content navigation groups.
3480
- * Nested VitePress items are flattened into the nearest ox-content group.
3481
- */
3482
- declare function convertVitePressSidebar(sidebar: VitePressSidebar): SsgNavigationGroup[];
3483
- /**
3484
- * Converts VitePress top navigation into ox-content sidebar groups.
3485
- * This is used as a fallback when no explicit sidebar is defined.
3486
- */
3487
- declare function convertVitePressNav(nav: VitePressNavItem[]): SsgNavigationGroup[];
3488
- /**
3489
- * Creates ox-content plugin options from an existing VitePress config.
3490
- */
3491
- declare function fromVitePressConfig(config: VitePressConfig, overrides?: OxContentOptions): OxContentOptions;
3492
- /**
3493
- * Generates a TypeScript module exporting migrated ox-content options.
3494
- *
3495
- * This is used by the migration CLI so users can inspect and edit the resulting
3496
- * object instead of keeping a runtime dependency on their VitePress config.
3497
- */
3498
- declare function generateVitePressMigrationConfig(config: VitePressConfig, overrides?: OxContentOptions, options?: GenerateVitePressMigrationConfigOptions): string;
3499
- /**
3500
- * Normalizes VitePress-specific frontmatter into ox-content's entry-page shape.
3501
- */
3502
- declare function normalizeVitePressFrontmatter(frontmatter: Record<string, unknown>): Record<string, unknown>;
3503
- //#endregion
3504
- //#region src/page-context.d.ts
3505
- /**
3506
- * Base page props available for all pages.
3507
- */
3508
- interface BasePageProps {
3509
- /** Page title from frontmatter or first heading */
3510
- title: string;
3511
- /** Page description from frontmatter */
3512
- description?: string;
3513
- /** Rendered HTML content */
3514
- html: string;
3515
- /** Table of contents entries */
3516
- toc: TocEntry[];
3517
- /** Last git commit timestamp in milliseconds */
3518
- lastUpdated?: number;
3519
- /** Source file path (relative to docs root) */
3520
- path: string;
3521
- /** Output URL path */
3522
- url: string;
3523
- /** Raw frontmatter object */
3524
- frontmatter: Record<string, unknown>;
3525
- /** Layout name from frontmatter */
3526
- layout?: string;
3527
- }
3528
- /**
3529
- * Extended page props with custom frontmatter.
3530
- */
3531
- type PageProps<T extends Record<string, unknown> = Record<string, unknown>> = BasePageProps & {
3532
- /** Custom frontmatter fields */
3533
- frontmatter: T & Record<string, unknown>;
3534
- };
3535
- /**
3536
- * Site-wide configuration available in context.
3537
- */
3538
- interface SiteConfig {
3539
- /** Site name */
3540
- name: string;
3541
- /** Base URL path */
3542
- base: string;
3543
- /** All pages in the site */
3544
- pages: BasePageProps[];
3545
- /** Navigation groups */
3546
- nav: NavGroup[];
3547
- }
3548
- /**
3549
- * Navigation group.
3550
- */
3551
- interface NavGroup {
3552
- title: string;
3553
- items: NavItem[];
3554
- }
3555
- /**
3556
- * Navigation item.
3557
- */
3558
- interface NavItem {
3559
- title: string;
3560
- path: string;
3561
- href: string;
3562
- }
3563
- /**
3564
- * Complete render context.
3565
- */
3566
- interface RenderContext<T extends Record<string, unknown> = Record<string, unknown>> {
3567
- /** Current page props */
3568
- page: PageProps<T>;
3569
- /** Site configuration */
3570
- site: SiteConfig;
3571
- }
3572
- /**
3573
- * Sets the current render context.
3574
- * Called internally during page rendering.
3575
- * @internal
3576
- */
3577
- declare function setRenderContext(ctx: RenderContext): void;
3578
- /**
3579
- * Clears the current render context.
3580
- * Called internally after page rendering.
3581
- * @internal
3582
- */
3583
- declare function clearRenderContext(): void;
3584
- /**
3585
- * Gets the current page props.
3586
- *
3587
- * @returns The current page props
3588
- * @throws Error if called outside of a render context
3589
- *
3590
- * @example
3591
- * ```tsx
3592
- * function PageTitle() {
3593
- * const page = usePageProps();
3594
- * return <h1>{page.title}</h1>;
3595
- * }
3596
- * ```
3597
- */
3598
- declare function usePageProps<T extends Record<string, unknown> = Record<string, unknown>>(): PageProps<T>;
3599
- /**
3600
- * Gets the site configuration.
3601
- *
3602
- * @returns The site configuration
3603
- * @throws Error if called outside of a render context
3604
- *
3605
- * @example
3606
- * ```tsx
3607
- * function SiteHeader() {
3608
- * const site = useSiteConfig();
3609
- * return <header>{site.name}</header>;
3610
- * }
3611
- * ```
3708
+ infoCount: number;
3709
+ warningCount: number;
3710
+ }
3711
+ /**
3712
+ * Returns true if the file path is included by the configured glob filters.
3612
3713
  */
3613
- declare function useSiteConfig(): SiteConfig;
3714
+ declare function shouldLintMarkdownFile(filePath: string, options?: MarkdownLintFileOptions): boolean;
3614
3715
  /**
3615
- * Gets the full render context.
3616
- *
3617
- * @returns The complete render context
3618
- * @throws Error if called outside of a render context
3716
+ * Lints a single Markdown file using project-style include/exclude settings.
3619
3717
  *
3620
- * @example
3621
- * ```tsx
3622
- * function Layout({ children }) {
3623
- * const ctx = useRenderContext();
3624
- * return (
3625
- * <html>
3626
- * <head><title>{ctx.page.title} - {ctx.site.name}</title></head>
3627
- * <body>{children}</body>
3628
- * </html>
3629
- * );
3630
- * }
3631
- * ```
3718
+ * If the file is filtered out by `include` / `exclude`, the returned result is
3719
+ * marked as `skipped` and contains no diagnostics.
3632
3720
  */
3633
- declare function useRenderContext<T extends Record<string, unknown> = Record<string, unknown>>(): RenderContext<T>;
3721
+ declare function lintMarkdownFile(filePath: string, options?: MarkdownLintFileOptions): Promise<MarkdownLintFileResult>;
3634
3722
  /**
3635
- * Gets the navigation groups.
3636
- *
3637
- * @example
3638
- * ```tsx
3639
- * function Sidebar() {
3640
- * const nav = useNav();
3641
- * return (
3642
- * <nav>
3643
- * {each(nav, (group) => (
3644
- * <div>
3645
- * <h3>{group.title}</h3>
3646
- * <ul>
3647
- * {each(group.items, (item) => (
3648
- * <li><a href={item.href}>{item.title}</a></li>
3649
- * ))}
3650
- * </ul>
3651
- * </div>
3652
- * ))}
3653
- * </nav>
3654
- * );
3655
- * }
3656
- * ```
3723
+ * Lints all Markdown files matched by the configured include/exclude patterns.
3657
3724
  */
3658
- declare function useNav(): NavGroup[];
3725
+ declare function lintMarkdownFiles(options?: MarkdownLintFileOptions): Promise<MarkdownLintFilesResult>;
3726
+ //#endregion
3727
+ //#region src/ssg.d.ts
3659
3728
  /**
3660
- * Checks if the given path is the current page.
3729
+ * Deprecated compatibility export for consumers that imported the former
3730
+ * TypeScript SSG template. HTML generation is Rust-backed now.
3661
3731
  *
3662
- * @example
3663
- * ```tsx
3664
- * function NavLink({ href, children }) {
3665
- * const isActive = useIsActive(href);
3666
- * return <a href={href} class={isActive ? 'active' : ''}>{children}</a>;
3667
- * }
3668
- * ```
3732
+ * @deprecated Use `generateHtmlPage`/`buildSsg` instead.
3669
3733
  */
3670
- declare function useIsActive(path: string): boolean;
3734
+ declare const DEFAULT_HTML_TEMPLATE = "<!-- ox-content default HTML template is Rust-backed -->";
3671
3735
  /**
3672
- * Schema for frontmatter type generation.
3736
+ * Resolves SSG options with defaults.
3673
3737
  */
3674
- interface FrontmatterSchema {
3675
- /** Field name */
3676
- name: string;
3677
- /** TypeScript type */
3678
- type: string;
3679
- /** Whether the field is optional */
3680
- optional: boolean;
3681
- /** JSDoc description */
3682
- description?: string;
3738
+ declare function resolveSsgOptions(ssg: SsgOptions | boolean | undefined): ResolvedSsgOptions;
3739
+ /** Result of an SSG build. */
3740
+ interface SsgBuildResult {
3741
+ /** Every file written, HTML pages and generated OG images alike. */
3742
+ files: string[];
3743
+ /** Per-page failures that did not abort the build. */
3744
+ errors: string[];
3745
+ /**
3746
+ * Generated OG image URL per source file, keyed by absolute input path.
3747
+ *
3748
+ * Bare mode renders these into the page itself, but a consumer
3749
+ * post-processing the output had no way to find them short of probing the
3750
+ * output directory for `og-image.png`.
3751
+ */
3752
+ ogImages: Record<string, string>;
3683
3753
  }
3684
3754
  /**
3685
- * Infers TypeScript types from frontmatter values.
3686
- */
3687
- declare function inferType(value: unknown): string;
3688
- /**
3689
- * Generates TypeScript interface from frontmatter samples.
3755
+ * Builds all markdown files to static HTML.
3690
3756
  */
3691
- declare function generateFrontmatterTypes(samples: Record<string, unknown>[], interfaceName?: string): string;
3757
+ declare function buildSsg(options: ResolvedOptions, root: string): Promise<SsgBuildResult>;
3692
3758
  //#endregion
3693
- //#region src/theme-renderer.d.ts
3759
+ //#region src/search.d.ts
3694
3760
  /**
3695
- * Theme component type.
3761
+ * Resolves search options with defaults.
3696
3762
  */
3697
- type ThemeComponent = (props: ThemeProps) => JSXNode;
3763
+ declare function resolveSearchOptions(options: SearchOptions | boolean | undefined): ResolvedSearchOptions;
3698
3764
  /**
3699
- * Props passed to the theme component.
3765
+ * Builds the search index from Markdown files.
3700
3766
  */
3701
- interface ThemeProps {
3702
- /** Rendered page content as JSX */
3703
- children: JSXNode;
3704
- }
3767
+ declare function buildSearchIndex(srcDir: string, base: string, extensions?: readonly string[]): Promise<string>;
3705
3768
  /**
3706
- * Page data for rendering.
3769
+ * Writes the search index to a file.
3707
3770
  */
3708
- interface PageData {
3709
- /** Page title */
3710
- title: string;
3711
- /** Page description */
3771
+ declare function writeSearchIndex(indexJson: string, outDir: string): Promise<void>;
3772
+ //#endregion
3773
+ //#region src/collections.d.ts
3774
+ declare function defineCollection<T extends CollectionOptions>(collection: T): T;
3775
+ declare function defineCollections<T extends CollectionsOptions>(collections: T): T;
3776
+ declare function resolveCollectionsOptions(options: CollectionsOptions | boolean | undefined): ResolvedCollectionsOptions;
3777
+ declare function buildCollectionManifest(root: string, options: ResolvedOptions): Promise<CollectionManifest>;
3778
+ declare function generateCollectionsVirtualModule(root: string, options: ResolvedOptions): Promise<string>;
3779
+ //#endregion
3780
+ //#region src/markdown.d.ts
3781
+ declare const DEFAULT_MARKDOWN_EXTENSIONS: readonly [".md", ".markdown", ".mdx"];
3782
+ declare function normalizeMarkdownExtensions(extensions?: readonly string[]): string[];
3783
+ declare function isMarkdownFilePath(filePath: string, extensions?: readonly string[]): boolean;
3784
+ declare function stripMarkdownExtension(filePath: string, extensions?: readonly string[]): string;
3785
+ //#endregion
3786
+ //#region src/vitepress.d.ts
3787
+ interface VitePressLogo {
3788
+ light?: string;
3789
+ dark?: string;
3790
+ src?: string;
3791
+ alt?: string;
3792
+ }
3793
+ interface VitePressSocialLink {
3794
+ icon: string;
3795
+ link: string;
3796
+ ariaLabel?: string;
3797
+ }
3798
+ interface VitePressFooter {
3799
+ message?: string;
3800
+ copyright?: string;
3801
+ }
3802
+ interface VitePressSidebarItem {
3803
+ text?: string;
3804
+ link?: string;
3805
+ items?: VitePressSidebarItem[];
3806
+ collapsed?: boolean;
3807
+ }
3808
+ type VitePressSidebar = VitePressSidebarItem[] | Record<string, VitePressSidebarItem[]>;
3809
+ interface VitePressNavItem {
3810
+ text?: string;
3811
+ link?: string;
3812
+ items?: VitePressNavItem[];
3813
+ activeMatch?: string;
3814
+ }
3815
+ interface VitePressThemeConfig {
3816
+ siteTitle?: string | false;
3817
+ logo?: string | VitePressLogo;
3818
+ nav?: VitePressNavItem[];
3819
+ sidebar?: VitePressSidebar;
3820
+ socialLinks?: VitePressSocialLink[];
3821
+ footer?: VitePressFooter;
3822
+ search?: {
3823
+ placeholder?: string;
3824
+ };
3825
+ }
3826
+ interface VitePressConfig {
3827
+ title?: string;
3712
3828
  description?: string;
3713
- /** Rendered HTML content */
3714
- html: string;
3715
- /** Table of contents */
3716
- toc: TocEntry[];
3717
- /** Last git commit timestamp in milliseconds */
3718
- lastUpdated?: number;
3719
- /** Source file path */
3720
- path: string;
3721
- /** Output URL path */
3722
- url: string;
3723
- /** Frontmatter */
3724
- frontmatter: Record<string, unknown>;
3725
- /** Layout name */
3726
- layout?: string;
3829
+ base?: string;
3830
+ themeConfig?: VitePressThemeConfig;
3727
3831
  }
3728
- /**
3729
- * Theme render options.
3730
- */
3731
- interface ThemeRenderOptions {
3732
- /** Theme component to use */
3733
- theme: ThemeComponent;
3734
- /** Site name */
3735
- siteName: string;
3736
- /** Base URL path */
3737
- base: string;
3738
- /** Navigation groups */
3739
- nav: NavGroup[];
3740
- /** All pages (for site context) */
3741
- pages: PageData[];
3742
- /** Output directory for type definitions */
3743
- typesOutDir?: string;
3832
+ interface GenerateVitePressMigrationConfigOptions {
3833
+ importSource?: string;
3744
3834
  }
3745
3835
  /**
3746
- * Renders a page using the theme component.
3747
- *
3748
- * @param page - Page data to render
3749
- * @param options - Theme render options
3750
- * @returns Rendered HTML string
3836
+ * Converts a VitePress sidebar config into ox-content navigation groups.
3837
+ * Nested VitePress items are flattened into the nearest ox-content group.
3751
3838
  */
3752
- declare function renderPage(page: PageData, options: ThemeRenderOptions): string;
3839
+ declare function convertVitePressSidebar(sidebar: VitePressSidebar): SsgNavigationGroup[];
3753
3840
  /**
3754
- * Renders all pages and generates type definitions.
3755
- *
3756
- * @param pages - All pages to render
3757
- * @param options - Theme render options
3758
- * @returns Map of output paths to rendered HTML
3841
+ * Converts VitePress top navigation into ox-content sidebar groups.
3842
+ * This is used as a fallback when no explicit sidebar is defined.
3759
3843
  */
3760
- declare function renderAllPages(pages: PageData[], options: ThemeRenderOptions): Promise<Map<string, string>>;
3844
+ declare function convertVitePressNav(nav: VitePressNavItem[]): SsgNavigationGroup[];
3761
3845
  /**
3762
- * Generates TypeScript type definitions from page frontmatter.
3763
- *
3764
- * @param pages - All pages
3765
- * @param outDir - Output directory for types
3846
+ * Creates ox-content plugin options from an existing VitePress config.
3766
3847
  */
3767
- declare function generateTypes(pages: PageData[], outDir: string): Promise<void>;
3848
+ declare function fromVitePressConfig(config: VitePressConfig, overrides?: OxContentOptions): OxContentOptions;
3768
3849
  /**
3769
- * Default theme component.
3770
- * A minimal theme that renders page content with basic styling.
3850
+ * Generates a TypeScript module exporting migrated ox-content options.
3851
+ *
3852
+ * This is used by the migration CLI so users can inspect and edit the resulting
3853
+ * object instead of keeping a runtime dependency on their VitePress config.
3771
3854
  */
3772
- declare function DefaultTheme({ children }: ThemeProps): JSXNode;
3855
+ declare function generateVitePressMigrationConfig(config: VitePressConfig, overrides?: OxContentOptions, options?: GenerateVitePressMigrationConfigOptions): string;
3773
3856
  /**
3774
- * Creates a theme with layout switching support.
3775
- *
3776
- * @example
3777
- * ```tsx
3778
- * import { createTheme } from '@ox-content/vite-plugin';
3779
- * import { DefaultLayout } from './layouts/Default';
3780
- * import { EntryLayout } from './layouts/Entry';
3781
- *
3782
- * export default createTheme({
3783
- * layouts: {
3784
- * default: DefaultLayout,
3785
- * entry: EntryLayout,
3786
- * },
3787
- * });
3788
- * ```
3857
+ * Normalizes VitePress-specific frontmatter into ox-content's entry-page shape.
3789
3858
  */
3790
- declare function createTheme(config: {
3791
- layouts: Record<string, ThemeComponent>;
3792
- defaultLayout?: string;
3793
- }): ThemeComponent;
3859
+ declare function normalizeVitePressFrontmatter(frontmatter: Record<string, unknown>): Record<string, unknown>;
3794
3860
  //#endregion
3795
3861
  //#region src/island/parse.d.ts
3796
3862
  /**