mirror of
https://github.com/LibreChat-AI/librechat.ai.git
synced 2026-03-27 10:48:32 +07:00
* chore: upgrade eslint to v9 * chore: update package dependencies in package.json and pnpm-lock.yaml - Added `minimatch` and `serialize-javascript` dependencies with updated versions. - Upgraded `ajv` to version 6.14.0. - Removed outdated dependencies from pnpm-lock.yaml for better package management. * feat: add Stripe logos to Companies section - Introduced new company entry for Stripe in the Companies component, including both light and dark logo variants. - Updated the Companies array to display 10 logos instead of 8. - Adjusted TypeScript environment reference to point to the development types directory.
96 lines
2.2 KiB
TypeScript
96 lines
2.2 KiB
TypeScript
/**
|
|
* Nextra compatibility shim for `nextra/context`.
|
|
* Provides stub implementations so existing pages/ components
|
|
* can resolve their imports during the migration to Fumadocs.
|
|
*
|
|
* Components like ChangelogHeader use:
|
|
* const pages = getPagesUnderRoute('/changelog');
|
|
* const page = pages.find(p => p.route === router.pathname);
|
|
* const { title } = page.frontMatter;
|
|
*
|
|
* We return a Proxy-based array that always matches .find() calls,
|
|
* returning a safe stub page with empty frontMatter defaults.
|
|
*/
|
|
|
|
const safeFrontMatter: Record<string, any> = new Proxy(
|
|
{
|
|
title: '',
|
|
description: '',
|
|
date: new Date().toISOString(),
|
|
ogImage: '',
|
|
ogVideo: '',
|
|
gif: undefined,
|
|
authorid: '',
|
|
author: '',
|
|
version: '',
|
|
tags: [],
|
|
category: '',
|
|
featured: false,
|
|
},
|
|
{
|
|
get(target, prop) {
|
|
if (prop in target) return target[prop as string]
|
|
return ''
|
|
},
|
|
},
|
|
)
|
|
|
|
function createStubPage(route: string): any {
|
|
return {
|
|
name: route.split('/').pop() || 'stub',
|
|
route,
|
|
kind: 'MdxPage',
|
|
frontMatter: safeFrontMatter,
|
|
meta: { title: '' },
|
|
children: [],
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns a proxy array that intercepts .find() calls to always return
|
|
* a valid stub page, preventing undefined access errors.
|
|
*/
|
|
export function getPagesUnderRoute(route: string): any[] {
|
|
const stubArray: any[] = []
|
|
|
|
return new Proxy(stubArray, {
|
|
get(target, prop, receiver) {
|
|
if (prop === 'find') {
|
|
return (_predicate: any) => createStubPage(route)
|
|
}
|
|
if (prop === 'filter') {
|
|
return (_predicate: any) => []
|
|
}
|
|
if (prop === 'sort') {
|
|
return (_compareFn: any) => receiver
|
|
}
|
|
if (prop === 'slice') {
|
|
return () => []
|
|
}
|
|
if (prop === 'map') {
|
|
return (_mapFn: any) => []
|
|
}
|
|
if (prop === 'flatMap') {
|
|
return (_mapFn: any) => []
|
|
}
|
|
if (prop === 'length') {
|
|
return 0
|
|
}
|
|
if (prop === Symbol.iterator) {
|
|
return function* () {}
|
|
}
|
|
return Reflect.get(target, prop, receiver)
|
|
},
|
|
})
|
|
}
|
|
|
|
/**
|
|
* Stub for useConfig - returns a config object with empty frontMatter.
|
|
*/
|
|
export function useConfig(): any {
|
|
return {
|
|
title: '',
|
|
frontMatter: safeFrontMatter,
|
|
}
|
|
}
|