fumadocs-core 13.4.9 → 14.0.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.
Files changed (36) hide show
  1. package/dist/{search-algolia/client.js → algolia-NTWLS6J3.js} +10 -27
  2. package/dist/breadcrumb.d.ts +15 -7
  3. package/dist/breadcrumb.js +47 -25
  4. package/dist/chunk-2V6SCS43.js +12 -0
  5. package/dist/chunk-2ZSMGYVH.js +78 -0
  6. package/dist/{chunk-UQV4A7HQ.js → chunk-4MNUWZIW.js} +9 -7
  7. package/dist/{chunk-KGMG4N3Y.js → chunk-I5BWASD6.js} +2 -2
  8. package/dist/dynamic-link.js +2 -1
  9. package/dist/fetch-4K7QOPFM.js +17 -0
  10. package/dist/i18n/index.js +64 -3
  11. package/dist/mdx-plugins/index.d.ts +20 -5
  12. package/dist/mdx-plugins/index.js +140 -14
  13. package/dist/{page-tree-BTCDMLTU.d.ts → page-tree-r8qjoUla.d.ts} +7 -4
  14. package/dist/{search-algolia/server.d.ts → search/algolia.d.ts} +1 -1
  15. package/dist/{search-algolia/server.js → search/algolia.js} +1 -1
  16. package/dist/search/client.d.ts +37 -7
  17. package/dist/search/client.js +74 -22
  18. package/dist/search/server.d.ts +65 -32
  19. package/dist/search/server.js +272 -234
  20. package/dist/server/index.d.ts +56 -4
  21. package/dist/server/index.js +59 -1
  22. package/dist/sidebar.js +7 -5
  23. package/dist/source/index.d.ts +20 -29
  24. package/dist/source/index.js +89 -81
  25. package/dist/static-5GPJ7RUY.js +60 -0
  26. package/dist/toc.js +1 -1
  27. package/dist/{search/shared.d.ts → types-Ch8gnVgO.d.ts} +1 -1
  28. package/dist/utils/use-on-change.d.ts +6 -1
  29. package/dist/utils/use-on-change.js +1 -1
  30. package/package.json +27 -86
  31. package/dist/chunk-MXOJWF66.js +0 -67
  32. package/dist/chunk-NREWOIVI.js +0 -19
  33. package/dist/middleware.d.ts +0 -3
  34. package/dist/middleware.js +0 -7
  35. package/dist/search/shared.js +0 -0
  36. package/dist/search-algolia/client.d.ts +0 -37
@@ -1,67 +0,0 @@
1
- // src/i18n/middleware.ts
2
- import { match as matchLocale } from "@formatjs/intl-localematcher";
3
- import Negotiator from "negotiator";
4
- import { NextResponse } from "next/server";
5
- var COOKIE = "FD_LOCALE";
6
- function getLocale(request, locales, defaultLanguage) {
7
- const negotiatorHeaders = {};
8
- request.headers.forEach((value, key) => negotiatorHeaders[key] = value);
9
- const languages = new Negotiator({ headers: negotiatorHeaders }).languages(
10
- locales
11
- );
12
- return matchLocale(languages, locales, defaultLanguage);
13
- }
14
- var defaultFormat = (locale, path) => {
15
- return `/${locale}/${path}`;
16
- };
17
- function createI18nMiddleware({
18
- languages,
19
- defaultLanguage,
20
- format = defaultFormat,
21
- hideLocale = "never"
22
- }) {
23
- function getUrl(request, pathname, locale) {
24
- if (!locale) {
25
- return new URL(
26
- pathname.startsWith("/") ? pathname : `/${pathname}`,
27
- request.url
28
- );
29
- }
30
- return new URL(
31
- format(locale, pathname.startsWith("/") ? pathname.slice(1) : pathname),
32
- request.url
33
- );
34
- }
35
- return (request) => {
36
- const { pathname } = request.nextUrl;
37
- const pathLocale = languages.find(
38
- (locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`
39
- );
40
- if (!pathLocale) {
41
- if (hideLocale === "default-locale") {
42
- return NextResponse.rewrite(getUrl(request, pathname, defaultLanguage));
43
- }
44
- const preferred = getLocale(request, languages, defaultLanguage);
45
- if (hideLocale === "always") {
46
- const locale = request.cookies.get(COOKIE)?.value ?? preferred;
47
- return NextResponse.rewrite(getUrl(request, pathname, locale));
48
- }
49
- return NextResponse.redirect(getUrl(request, pathname, preferred));
50
- }
51
- if (hideLocale === "always") {
52
- const path = pathname.slice(`/${pathLocale}`.length);
53
- const res = NextResponse.redirect(getUrl(request, path));
54
- res.cookies.set(COOKIE, pathLocale);
55
- return res;
56
- }
57
- if (hideLocale === "default-locale" && pathLocale === defaultLanguage) {
58
- const path = pathname.slice(`/${pathLocale}`.length);
59
- return NextResponse.redirect(getUrl(request, path));
60
- }
61
- return NextResponse.next();
62
- };
63
- }
64
-
65
- export {
66
- createI18nMiddleware
67
- };
@@ -1,19 +0,0 @@
1
- // src/utils/use-debounce.ts
2
- import { useRef, useState } from "react";
3
- function useDebounce(value, delayMs = 1e3) {
4
- const [debouncedValue, setDebouncedValue] = useState(value);
5
- const timer = useRef();
6
- if (delayMs === 0) return value;
7
- if (value !== debouncedValue && timer.current?.value !== value) {
8
- if (timer.current) clearTimeout(timer.current.handler);
9
- const handler = window.setTimeout(() => {
10
- setDebouncedValue(value);
11
- }, delayMs);
12
- timer.current = { value, handler };
13
- }
14
- return debouncedValue;
15
- }
16
-
17
- export {
18
- useDebounce
19
- };
@@ -1,3 +0,0 @@
1
- export { createI18nMiddleware } from './i18n/index.js';
2
- import './config-inq6kP6y.js';
3
- import 'next/dist/server/web/types';
@@ -1,7 +0,0 @@
1
- import {
2
- createI18nMiddleware
3
- } from "./chunk-MXOJWF66.js";
4
- import "./chunk-MLKGABMK.js";
5
- export {
6
- createI18nMiddleware
7
- };
File without changes
@@ -1,37 +0,0 @@
1
- import { SearchOptions, Hit } from '@algolia/client-search';
2
- import { SearchIndex } from 'algoliasearch/lite';
3
- import { SWRResponse } from 'swr';
4
- import { SortedResult } from '../search/shared.js';
5
- import { BaseIndex } from './server.js';
6
- import 'algoliasearch';
7
- import '../remark-structure-mP51W1AN.js';
8
- import 'mdast';
9
- import 'unified';
10
- import 'unist-util-visit';
11
-
12
- interface Options extends SearchOptions {
13
- /**
14
- * Use `empty` as result if query is empty
15
- *
16
- * @defaultValue true
17
- */
18
- allowEmpty?: boolean;
19
- /**
20
- * Delay to debounce (in ms)
21
- *
22
- * @defaultValue 300
23
- */
24
- delay?: number;
25
- }
26
- declare function groupResults(hits: Hit<BaseIndex>[]): SortedResult[];
27
- declare function searchDocs(index: SearchIndex, query: string, options?: SearchOptions): Promise<SortedResult[]>;
28
- interface UseAlgoliaSearch {
29
- search: string;
30
- setSearch: (v: string) => void;
31
- query: SWRResponse<SortedResult[] | 'empty', Error, {
32
- keepPreviousData: true;
33
- }>;
34
- }
35
- declare function useAlgoliaSearch(index: SearchIndex, { allowEmpty, delay, ...options }?: Options): UseAlgoliaSearch;
36
-
37
- export { type Options, groupResults, searchDocs, useAlgoliaSearch };