mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-01 06:28:38 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3d240c481 | |||
| 8df1bf152b |
@@ -120,6 +120,8 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gitbook/api": "^0.90.0",
|
"@gitbook/api": "^0.90.0",
|
||||||
|
"@gitbook/icons": "workspace:*",
|
||||||
|
"clsx": "^2.1.1",
|
||||||
"next": "canary",
|
"next": "canary",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
@@ -1466,7 +1468,7 @@
|
|||||||
|
|
||||||
"clone-response": ["clone-response@1.0.3", "", { "dependencies": { "mimic-response": "^1.0.0" } }, "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA=="],
|
"clone-response": ["clone-response@1.0.3", "", { "dependencies": { "mimic-response": "^1.0.0" } }, "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA=="],
|
||||||
|
|
||||||
"clsx": ["clsx@2.0.0", "", {}, "sha512-rQ1+kcj+ttHG0MKVGBUXwayCCF1oh39BF5COIpRzuCEv8Mwjv0XucrI2ExNTOn9IlLifGClWQcU9BrZORvtw6Q=="],
|
"clsx": ["clsx@2.1.1", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
|
||||||
|
|
||||||
"code-block-writer": ["code-block-writer@13.0.3", "", {}, "sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg=="],
|
"code-block-writer": ["code-block-writer@13.0.3", "", {}, "sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg=="],
|
||||||
|
|
||||||
@@ -4272,6 +4274,8 @@
|
|||||||
|
|
||||||
"convict/yargs-parser": ["yargs-parser@20.2.9", "", {}, "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w=="],
|
"convict/yargs-parser": ["yargs-parser@20.2.9", "", {}, "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w=="],
|
||||||
|
|
||||||
|
"cva/clsx": ["clsx@2.0.0", "", {}, "sha512-rQ1+kcj+ttHG0MKVGBUXwayCCF1oh39BF5COIpRzuCEv8Mwjv0XucrI2ExNTOn9IlLifGClWQcU9BrZORvtw6Q=="],
|
||||||
|
|
||||||
"decamelize-keys/map-obj": ["map-obj@1.0.1", "", {}, "sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg=="],
|
"decamelize-keys/map-obj": ["map-obj@1.0.1", "", {}, "sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg=="],
|
||||||
|
|
||||||
"deep-equal/isarray": ["isarray@2.0.5", "", {}, "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw=="],
|
"deep-equal/isarray": ["isarray@2.0.5", "", {}, "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw=="],
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
"next": "canary",
|
"next": "canary",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
"@gitbook/api": "^0.90.0"
|
"@gitbook/api": "^0.90.0",
|
||||||
|
"@gitbook/icons": "workspace:*",
|
||||||
|
"clsx": "^2.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@opennextjs/cloudflare": "^0.4.3"
|
"@opennextjs/cloudflare": "^0.4.3"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { SiteContentLayout } from '@/components/routes/SiteContentLayout';
|
import { SiteContentLayout } from '@v2/components/routes/SiteContentLayout';
|
||||||
import { createDynamicSiteContext } from '@/lib/context';
|
import { createDynamicSiteContext } from '@v2/lib/context';
|
||||||
|
|
||||||
export default async function RootLayout({
|
export default async function RootLayout({
|
||||||
params,
|
params,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { SiteContentPage } from '@/components/routes/SiteContentPage';
|
import { SiteContentPage } from '@v2/components/routes/SiteContentPage';
|
||||||
import { createDynamicSiteContext } from '@/lib/context';
|
import { createDynamicSiteContext } from '@v2/lib/context';
|
||||||
|
|
||||||
export default async function Page({ params }: { params: Promise<{ url: string[] }> }) {
|
export default async function Page({ params }: { params: Promise<{ url: string[] }> }) {
|
||||||
const { url } = await params;
|
const { url } = await params;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { unstable_cacheTag as cacheTag } from 'next/cache';
|
import { unstable_cacheTag as cacheTag } from 'next/cache';
|
||||||
import { SiteContentLayout } from '@/components/routes/SiteContentLayout';
|
import { SiteContentLayout } from '@v2/components/routes/SiteContentLayout';
|
||||||
import { getSiteCacheTag } from '@/lib/cache';
|
import { getSiteCacheTag } from '@v2/lib/cache';
|
||||||
import { createStaticSiteContext } from '@/lib/context';
|
import { createStaticSiteContext } from '@v2/lib/context';
|
||||||
|
|
||||||
export default async function RootLayout({
|
export default async function RootLayout({
|
||||||
params,
|
params,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { unstable_cacheTag as cacheTag } from 'next/cache';
|
import { unstable_cacheTag as cacheTag } from 'next/cache';
|
||||||
import { createStaticSiteContext } from '@/lib/context';
|
import { createStaticSiteContext } from '@v2/lib/context';
|
||||||
import { getSiteCacheTag } from '@/lib/cache';
|
import { getSiteCacheTag } from '@v2/lib/cache';
|
||||||
import { SiteContentPage } from '@/components/routes/SiteContentPage';
|
import { SiteContentPage } from '@v2/components/routes/SiteContentPage';
|
||||||
|
|
||||||
export default async function Page({ params }: { params: Promise<{ url: string[] }> }) {
|
export default async function Page({ params }: { params: Promise<{ url: string[] }> }) {
|
||||||
'use cache';
|
'use cache';
|
||||||
|
|||||||
+8
-47
@@ -1,12 +1,11 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import clsx from 'clsx';
|
||||||
|
|
||||||
import { Icon } from '@gitbook/icons';
|
import { Icon } from '@gitbook/icons';
|
||||||
import classNames from 'classnames';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
|
||||||
import { tcls } from '@/lib/tailwind';
|
|
||||||
|
|
||||||
import styles from './ZoomImage.module.css';
|
import styles from './ZoomImage.module.css';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,7 +165,7 @@ export function ZoomImage(
|
|||||||
startViewTransition(change);
|
startViewTransition(change);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
className={classNames(
|
className={clsx(
|
||||||
props.className,
|
props.className,
|
||||||
zoomable ? styles.zoomImg : null,
|
zoomable ? styles.zoomImg : null,
|
||||||
active ? styles.zoomImageActive : null,
|
active ? styles.zoomImageActive : null,
|
||||||
@@ -208,19 +207,9 @@ function ZoomImageModal(props: {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
data-testid="zoom-image-modal"
|
data-testid="zoom-image-modal"
|
||||||
className={classNames(
|
className={clsx(
|
||||||
styles.zoomModal,
|
styles.zoomModal,
|
||||||
tcls(
|
'fixed inset-0 z-50 flex items-center justify-center bg-light dark:bg-dark p-8',
|
||||||
'fixed',
|
|
||||||
'inset-0',
|
|
||||||
'z-50',
|
|
||||||
'flex',
|
|
||||||
'items-center',
|
|
||||||
'justify-center',
|
|
||||||
'bg-light',
|
|
||||||
'dark:bg-dark',
|
|
||||||
'p-8',
|
|
||||||
),
|
|
||||||
)}
|
)}
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
>
|
>
|
||||||
@@ -228,43 +217,15 @@ function ZoomImageModal(props: {
|
|||||||
src={src}
|
src={src}
|
||||||
alt={alt}
|
alt={alt}
|
||||||
crossOrigin={crossOrigin}
|
crossOrigin={crossOrigin}
|
||||||
className={tcls(
|
className="max-w-full max-h-full object-contain bg-light dark:bg-dark"
|
||||||
'max-w-full',
|
|
||||||
'max-h-full',
|
|
||||||
'object-contain',
|
|
||||||
'bg-light',
|
|
||||||
'dark:bg-dark',
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
ref={buttonRef}
|
ref={buttonRef}
|
||||||
className={tcls(
|
className="absolute top-5 right-5 flex flex-row items-center justify-center text-sm text-dark/6 dark:text-light/5 hover:text-primary p-4 dark:text-light/5 rounded-full bg-white dark:bg-dark/3 shadow-sm hover:shadow-md border-slate-300 dark:border-dark/2 border dark:text-light/5 hover:text-primary p-4 dark:text-light/5 rounded-full bg-white dark:bg-dark/3 shadow-sm hover:shadow-md border-slate-300 dark:border-dark/2 border"
|
||||||
'absolute',
|
|
||||||
'top-5',
|
|
||||||
'right-5',
|
|
||||||
'flex',
|
|
||||||
'flex-row',
|
|
||||||
'items-center',
|
|
||||||
'justify-center',
|
|
||||||
'text-sm',
|
|
||||||
'text-dark/6',
|
|
||||||
'dark:text-light/5',
|
|
||||||
'hover:text-primary',
|
|
||||||
'p-4',
|
|
||||||
'dark:text-light/5',
|
|
||||||
'rounded-full',
|
|
||||||
'bg-white',
|
|
||||||
'dark:bg-dark/3',
|
|
||||||
'shadow-sm',
|
|
||||||
'hover:shadow-md',
|
|
||||||
'border-slate-300',
|
|
||||||
'dark:border-dark/2',
|
|
||||||
'border',
|
|
||||||
)}
|
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
>
|
>
|
||||||
<Icon icon="compress-wide" className={tcls('size-5')} />
|
<Icon icon="compress-wide" className="size-5" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { GitBookSiteContext } from '@/lib/context';
|
import { GitBookSiteSpaceContext } from '@v2/lib/context';
|
||||||
|
import { Footer } from '@/components/Footer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layout component to render the site content.
|
* Layout component to render the site content.
|
||||||
@@ -7,20 +8,29 @@ export async function SiteContentLayout({
|
|||||||
context,
|
context,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
context: GitBookSiteContext;
|
context: GitBookSiteSpaceContext;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const { api } = context;
|
const [publishedSite, space] = await Promise.all([
|
||||||
const { data: publishedSite } = await api.orgs.getPublishedContentSite(
|
context.getPublishedContentSite(
|
||||||
context.organizationId,
|
context.organizationId,
|
||||||
context.siteId,
|
context.siteId,
|
||||||
);
|
),
|
||||||
|
context.getSpaceById(context.spaceId, context.siteShareKey),
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<body>
|
<body>
|
||||||
<h1>{publishedSite.site.title}</h1>
|
<h1>{publishedSite.site.title}</h1>
|
||||||
{children}
|
{children}
|
||||||
|
<Footer
|
||||||
|
space={space}
|
||||||
|
customization={
|
||||||
|
publishedSite.customizations.siteSpaces[context.siteSpaceId] ??
|
||||||
|
publishedSite.customizations.site
|
||||||
|
}
|
||||||
|
/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { GitBookSiteContext } from '@/lib/context';
|
import { GitBookSiteContext } from '@v2/lib/context';
|
||||||
|
|
||||||
export async function SiteContentPage({ context }: { context: GitBookSiteContext }) {
|
export async function SiteContentPage({ context }: { context: GitBookSiteContext }) {
|
||||||
const { api } = context;
|
const { api } = context;
|
||||||
|
|||||||
@@ -1,17 +1,8 @@
|
|||||||
import { headers } from 'next/headers';
|
import { headers } from 'next/headers';
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
import { GitBookAPI } from '@gitbook/api';
|
import { GitBookAPI } from '@gitbook/api';
|
||||||
import { GITBOOK_API_TOKEN, GITBOOK_API_URL, GITBOOK_USER_AGENT } from '@/lib/env';
|
import { GITBOOK_API_TOKEN, GITBOOK_API_URL, GITBOOK_USER_AGENT } from '@v2/lib/env';
|
||||||
|
import { GitBookContext } from '@/lib/v2/context';
|
||||||
/**
|
|
||||||
* Generic context about rendering content.
|
|
||||||
*/
|
|
||||||
export interface GitBookContext {
|
|
||||||
/**
|
|
||||||
* API client to fetch data from GitBook.
|
|
||||||
*/
|
|
||||||
api: GitBookAPI;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context when rendering a site.
|
* Context when rendering a site.
|
||||||
@@ -28,10 +19,35 @@ export interface GitBookSiteContext extends GitBookContext {
|
|||||||
siteId: string;
|
siteId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context when rendering a space in a site.
|
||||||
|
*/
|
||||||
|
export interface GitBookSiteSpaceContext extends GitBookSiteContext {
|
||||||
|
/**
|
||||||
|
* ID of the space.
|
||||||
|
*/
|
||||||
|
spaceId: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the site section.
|
||||||
|
*/
|
||||||
|
siteSectionId: string | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the site space.
|
||||||
|
*/
|
||||||
|
siteSpaceId: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Share key of the site.
|
||||||
|
*/
|
||||||
|
siteShareKey: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a site context, when rendering a static page.
|
* Create a site context, when rendering a static page.
|
||||||
*/
|
*/
|
||||||
export async function createStaticSiteContext(url: string[]): Promise<GitBookSiteContext> {
|
export async function createStaticSiteContext(url: string[]): Promise<GitBookSiteSpaceContext> {
|
||||||
const context = createStaticContext();
|
const context = createStaticContext();
|
||||||
return fetchSiteContext(url, context);
|
return fetchSiteContext(url, context);
|
||||||
}
|
}
|
||||||
@@ -39,7 +55,7 @@ export async function createStaticSiteContext(url: string[]): Promise<GitBookSit
|
|||||||
/**
|
/**
|
||||||
* Create a site context, when rendering a dynamic page.
|
* Create a site context, when rendering a dynamic page.
|
||||||
*/
|
*/
|
||||||
export async function createDynamicSiteContext(url: string[]): Promise<GitBookSiteContext> {
|
export async function createDynamicSiteContext(url: string[]): Promise<GitBookSiteSpaceContext> {
|
||||||
const context = await createDynamicContext();
|
const context = await createDynamicContext();
|
||||||
return fetchSiteContext(url, context);
|
return fetchSiteContext(url, context);
|
||||||
}
|
}
|
||||||
@@ -50,7 +66,7 @@ export async function createDynamicSiteContext(url: string[]): Promise<GitBookSi
|
|||||||
async function fetchSiteContext(
|
async function fetchSiteContext(
|
||||||
urlParts: string[],
|
urlParts: string[],
|
||||||
baseContext: GitBookContext,
|
baseContext: GitBookContext,
|
||||||
): Promise<GitBookSiteContext> {
|
): Promise<GitBookSiteSpaceContext> {
|
||||||
const { api } = baseContext;
|
const { api } = baseContext;
|
||||||
const url = getURLFromParams(urlParts);
|
const url = getURLFromParams(urlParts);
|
||||||
const { data } = await api.urls.getPublishedContentByUrl({
|
const { data } = await api.urls.getPublishedContentByUrl({
|
||||||
@@ -70,6 +86,9 @@ async function fetchSiteContext(
|
|||||||
}),
|
}),
|
||||||
siteId: data.site,
|
siteId: data.site,
|
||||||
organizationId: data.organization,
|
organizationId: data.organization,
|
||||||
|
siteSectionId: data.siteSection,
|
||||||
|
siteSpaceId: data.siteSpace,
|
||||||
|
spaceId: data.space,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,9 +102,7 @@ function createStaticContext(): GitBookContext {
|
|||||||
userAgent: GITBOOK_USER_AGENT,
|
userAgent: GITBOOK_USER_AGENT,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return createContextFromClient(api);
|
||||||
api,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,8 +118,36 @@ async function createDynamicContext(): Promise<GitBookContext> {
|
|||||||
userAgent: GITBOOK_USER_AGENT,
|
userAgent: GITBOOK_USER_AGENT,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return createContextFromClient(api);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createContextFromClient(api: GitBookAPI): GitBookContext {
|
||||||
return {
|
return {
|
||||||
api,
|
api,
|
||||||
|
getLink: (pathname: string) => pathname,
|
||||||
|
getPublishedContentSite: async (organizationId: string, siteId: string) => {
|
||||||
|
const { data } = await api.orgs.getPublishedContentSite(organizationId, siteId);
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
getRevisionFile: async (spaceId: string, revisionId: string, file: string) => {
|
||||||
|
throw new Error('Not implemented');
|
||||||
|
},
|
||||||
|
getUserById: async (userId: string) => {
|
||||||
|
const { data } = await api.users.getUserById(userId);
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
getSpaceById: async (spaceId: string, shareKey: string | undefined) => {
|
||||||
|
const { data } = await api.spaces.getSpaceById(spaceId, { shareKey });
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
getCollection: async (collectionId: string) => {
|
||||||
|
const { data } = await api.collections.getCollectionById(collectionId);
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
getReusableContent: async (spaceId: string, revisionId: string, reusableContentId: string) => {
|
||||||
|
const { data } = await api.spaces.getReusableContentInRevisionById(spaceId, revisionId, reusableContentId);
|
||||||
|
return data;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"],
|
"@v2/*": ["./src/*"],
|
||||||
"@v1/*": ["../gitbook/src/*"]
|
"@/*": ["../gitbook/src/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
|
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { checkIsHttpURL, getImageSize, getResizedImageURLFactory } from '@/lib/i
|
|||||||
import { ClassValue, tcls } from '@/lib/tailwind';
|
import { ClassValue, tcls } from '@/lib/tailwind';
|
||||||
|
|
||||||
import { PolymorphicComponentProp } from './types';
|
import { PolymorphicComponentProp } from './types';
|
||||||
import { ZoomImage } from './ZoomImage';
|
import { ZoomImage } from '@v2/components/images/ZoomImage';
|
||||||
|
|
||||||
export type ImageSize = { width: number; height: number };
|
export type ImageSize = { width: number; height: number };
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { Collection, GitBookAPI, PublishedContentSite, RevisionFile, RevisionReusableContent, Space, User } from "@gitbook/api";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global context for rendering GitBook.
|
||||||
|
* The context is designed to help migrate from v1 to v2, with components implemented for both versions.
|
||||||
|
*/
|
||||||
|
export interface GitBookContext {
|
||||||
|
/**
|
||||||
|
* API client to fetch data from GitBook.
|
||||||
|
*/
|
||||||
|
api: GitBookAPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a url/pathname to a link.
|
||||||
|
*/
|
||||||
|
getLink(pathname: string): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a published site by ID.
|
||||||
|
*/
|
||||||
|
getPublishedContentSite(organizationId: string, siteId: string): Promise<PublishedContentSite>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a file from a revision.
|
||||||
|
*/
|
||||||
|
getRevisionFile(spaceId: string, revisionId: string, file: string): Promise<RevisionFile>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a user by ID.
|
||||||
|
*/
|
||||||
|
getUserById(userId: string): Promise<User>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a space by ID.
|
||||||
|
*/
|
||||||
|
getSpaceById(spaceId: string, shareKey: string | undefined): Promise<Space>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a collection by ID.
|
||||||
|
*/
|
||||||
|
getCollection(collectionId: string): Promise<Collection>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a reusable content by ID.
|
||||||
|
*/
|
||||||
|
getReusableContent(spaceId: string, revisionId: string, reusableContentId: string): Promise<RevisionReusableContent>;
|
||||||
|
}
|
||||||
@@ -55,6 +55,9 @@ const config: Config = {
|
|||||||
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
|
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
|
||||||
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
|
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
|
||||||
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
|
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
|
||||||
|
|
||||||
|
// V2
|
||||||
|
'../gitbook-v2/src/**/*.{js,ts,jsx,tsx,mdx}',
|
||||||
],
|
],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"]
|
"@/*": ["./src/*"],
|
||||||
|
"@v2/*": ["../gitbook-v2/src/*"]
|
||||||
},
|
},
|
||||||
"types": [
|
"types": [
|
||||||
"bun-types" // add Bun global
|
"bun-types" // add Bun global
|
||||||
|
|||||||
Reference in New Issue
Block a user