diff --git a/packages/gitbook/src/components/Adaptive/AIPageLinkSummary.tsx b/packages/gitbook/src/components/Adaptive/AIPageLinkSummary.tsx index 73acb6d8b..3f50c88a2 100644 --- a/packages/gitbook/src/components/Adaptive/AIPageLinkSummary.tsx +++ b/packages/gitbook/src/components/Adaptive/AIPageLinkSummary.tsx @@ -1,5 +1,7 @@ 'use client'; +import { Icon } from '@gitbook/icons'; import { useEffect, useState } from 'react'; +import { Loading } from '../primitives'; import { streamLinkPageSummary } from './server-actions/streamLinkPageSummary'; /** @@ -11,8 +13,16 @@ export function AIPageLinkSummary(props: { targetSpaceId: string; targetPageId: string; linkPreview?: string; + showTrademark: boolean; }) { - const { currentSpaceId, currentPageId, targetSpaceId, targetPageId, linkPreview } = props; + const { + currentSpaceId, + currentPageId, + targetSpaceId, + targetPageId, + linkPreview, + showTrademark = true, + } = props; const [highlight, setHighlight] = useState(''); @@ -45,5 +55,19 @@ export function AIPageLinkSummary(props: { }; }, [currentSpaceId, currentPageId, targetSpaceId, targetPageId]); - return

{highlight.length > 1 ? highlight : "Loading..."}

; + return ( +
+
+ {showTrademark ? ( + + ) : ( + + )} +
+ Page highlight +
+
+ {highlight} +
+ ); } diff --git a/packages/gitbook/src/components/Adaptive/AIPageNextRecommendedPages.tsx b/packages/gitbook/src/components/Adaptive/AIPageNextRecommendedPages.tsx index b70cc62b1..149127d1f 100644 --- a/packages/gitbook/src/components/Adaptive/AIPageNextRecommendedPages.tsx +++ b/packages/gitbook/src/components/Adaptive/AIPageNextRecommendedPages.tsx @@ -1,6 +1,7 @@ 'use client'; import { tcls } from '@/lib/tailwind'; +import { Icon } from '@gitbook/icons'; import { useEffect, useState } from 'react'; import { Link } from '../primitives'; import { streamNextRecommendedPages } from './server-actions'; @@ -15,7 +16,7 @@ export function AIPageNextRecommendedPages(props: { }) { const { spaceId, revisionId, pageId } = props; - const [pages, setPages] = useState<{ title: string; href: string }[]>([]); + const [pages, setPages] = useState<{ title: string; href: string; icon?: string }[]>([]); useEffect(() => { let canceled = false; @@ -45,17 +46,11 @@ export function AIPageNextRecommendedPages(props: { }, [spaceId, revisionId, pageId]); return ( -
+
{pages.map((page) => { return ( - + + {page.title} ); diff --git a/packages/gitbook/src/components/Adaptive/AdaptivePane.tsx b/packages/gitbook/src/components/Adaptive/AdaptivePane.tsx index dd65e2a6e..ecb78fd0a 100644 --- a/packages/gitbook/src/components/Adaptive/AdaptivePane.tsx +++ b/packages/gitbook/src/components/Adaptive/AdaptivePane.tsx @@ -4,15 +4,15 @@ import React from 'react'; import { useLanguage } from '@/intl/client'; import { tString } from '@/intl/translate'; import { tcls } from '@/lib/tailwind'; +import Link from 'next/link'; import { Button } from '../primitives'; -import { AIPageNextRecommendedPages } from './AIPageNextRecommendedPages'; import { useAdaptivePane } from './state'; export function AdaptivePane(props: { spaceId: string; revisionId: string; pageId: string }) { const language = useLanguage(); const { opened, open, close } = useAdaptivePane(); - const {spaceId, revisionId, pageId} = props; + const { spaceId, revisionId, pageId } = props; React.useEffect(() => { if (opened) { @@ -22,10 +22,17 @@ export function AdaptivePane(props: { spaceId: string; revisionId: string; pageI } }, [opened]); + const pages = [ + 'GitBook Documentation', + 'GitHub & GitLab Sync', + 'Troubleshooting', + 'Version control', + ]; + return ( -
-
-
+
+
+

- {tString(language, 'adaptive_pane_title')} + History

- +
    + {pages.map((page) => ( +
  1. + + {page} + +
  2. + ))} +
diff --git a/packages/gitbook/src/components/Adaptive/server-actions/streamLinkPageSummary.ts b/packages/gitbook/src/components/Adaptive/server-actions/streamLinkPageSummary.ts index 9d436645f..72980dea7 100644 --- a/packages/gitbook/src/components/Adaptive/server-actions/streamLinkPageSummary.ts +++ b/packages/gitbook/src/components/Adaptive/server-actions/streamLinkPageSummary.ts @@ -131,8 +131,6 @@ The content of the target page is:`, fetchServerActionSiteContext(baseContext), ]); - console.log(await response); - const emitted = new Set(); for await (const value of stream) { const highlight = value.highlight; diff --git a/packages/gitbook/src/components/Adaptive/server-actions/streamNextRecommendedPages.ts b/packages/gitbook/src/components/Adaptive/server-actions/streamNextRecommendedPages.ts index 7867883af..7743ac7a6 100644 --- a/packages/gitbook/src/components/Adaptive/server-actions/streamNextRecommendedPages.ts +++ b/packages/gitbook/src/components/Adaptive/server-actions/streamNextRecommendedPages.ts @@ -104,6 +104,7 @@ export async function* streamNextRecommendedPages({ } yield { + icon: page.page.icon ?? page.page.emoji, title: page.page.title, href: context.linker.toPathForPage({ pages: context.pages, diff --git a/packages/gitbook/src/components/DocumentView/InlineLink.tsx b/packages/gitbook/src/components/DocumentView/InlineLink.tsx index 85ac22884..1e9b22217 100644 --- a/packages/gitbook/src/components/DocumentView/InlineLink.tsx +++ b/packages/gitbook/src/components/DocumentView/InlineLink.tsx @@ -20,7 +20,7 @@ export async function InlineLink(props: InlineProps) { }) : null; - if (!resolved) { + if (!context.contentContext || !resolved) { return ( ) {
{!isExternal && - context.contentContext ? ( + 'site' in context.contentContext && + 'page' in context.contentContext && + context.contentContext.site.adaptiveContent?.enabled && + inline.data.ref.kind === 'page' ? (
-
- -
AI Summary
-
{/*
diff --git a/packages/gitbook/src/components/PageAside/PageAside.tsx b/packages/gitbook/src/components/PageAside/PageAside.tsx index 1d3a985fb..b5802c844 100644 --- a/packages/gitbook/src/components/PageAside/PageAside.tsx +++ b/packages/gitbook/src/components/PageAside/PageAside.tsx @@ -13,7 +13,7 @@ import urlJoin from 'url-join'; import { getSpaceLanguage, t } from '@/intl/server'; import { getDocumentSections } from '@/lib/document-sections'; import { tcls } from '@/lib/tailwind'; - +import { AIPageNextRecommendedPages } from '../Adaptive'; import { Ad } from '../Ads'; import { getPDFURLSearchParams } from '../PDF'; import { PageFeedbackForm } from '../PageFeedback'; @@ -42,12 +42,16 @@ export function PageAside(props: { limit: 100, }).toString()}` ); + + const prevPages = ['GitBook Documentation', 'GitHub & GitLab Sync', 'Troubleshooting']; + return (