Compare commits

...

3 Commits

Author SHA1 Message Date
Peter White 276a170155 Bump @gitbook/api to 0.210.0
Updates blocks can now hold if blocks. Published content is evaluated before it reaches the renderer, so the readers only look at update nodes.
2026-11-18 14:13:34 +00:00
Peter White a4074221df Merge remote-tracking branch 'origin/main' into peter/per-link-open-in-new-tab 2026-11-18 10:52:33 +00:00
Peter White 5d19ad7ba0 Open links in the tab their author chose 2026-11-18 04:25:52 +00:00
8 changed files with 37 additions and 12 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": minor
---
Open a link in the same or a new tab when its author chose one, instead of the site-wide external links setting.
+2 -2
View File
@@ -357,7 +357,7 @@
},
"catalog": {
"@base-ui/react": "^1.7.0",
"@gitbook/api": "0.208.0",
"@gitbook/api": "0.210.0",
"@scalar/api-client-react": "^1.3.46",
"@tsconfig/node20": "^20.1.6",
"@tsconfig/strictest": "^2.0.6",
@@ -725,7 +725,7 @@
"@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@7.2.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "7.2.0" } }, "sha512-6639htZMjEkwskf3J+e6/iar+4cTNM9qhoWuRfj9F3eJD6r7iCzV1SWnQr2Mdv0QT0suuqU8BoJCZUyCtP9R4Q=="],
"@gitbook/api": ["@gitbook/api@0.208.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-i5rnGYNvgp8PDGd9FRLUjOx5gS/D7mFfikwp0Lsem4pgEG8cqBtZsDaYbLBdAdupOuZBLJtmEut51zhttok6OQ=="],
"@gitbook/api": ["@gitbook/api@0.210.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-qxroJUFDreoJNU7X28Gz+2Nbjg8PCiE4GtJkwscHYfmWHLM29NsVVt3ap8x+bz53j6mg+SaobVjeRsXdA1EbXA=="],
"@gitbook/browser-types": ["@gitbook/browser-types@workspace:packages/browser-types"],
+1 -1
View File
@@ -48,7 +48,7 @@
"@tsconfig/strictest": "^2.0.6",
"@tsconfig/node20": "^20.1.6",
"@base-ui/react": "^1.7.0",
"@gitbook/api": "0.208.0",
"@gitbook/api": "0.210.0",
"@scalar/api-client-react": "^1.3.46",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
@@ -40,7 +40,12 @@ export async function InlineLink(props: InlineProps<DocumentInlineLink>) {
return (
<NotFoundRefHoverCard context={context}>
{fallback ? (
<InlineLinkAnchor href={fallback.href} contentRef={inline.data.ref} isExternal>
<InlineLinkAnchor
href={fallback.href}
contentRef={inline.data.ref}
target={inline.data.target}
isExternal
>
{inlinesElement}
</InlineLinkAnchor>
) : (
@@ -53,6 +58,7 @@ export async function InlineLink(props: InlineProps<DocumentInlineLink>) {
<InlineLinkAnchor
href={resolved.href}
contentRef={resolved.resolvedRef ?? inline.data.ref}
target={inline.data.target}
isExternal={(resolved.resolvedRef ?? inline.data.ref).kind === 'url'}
>
{inlinesElement}
@@ -75,14 +81,16 @@ export async function InlineLink(props: InlineProps<DocumentInlineLink>) {
function InlineLinkAnchor(props: {
href: string;
contentRef: ContentRef;
target: DocumentInlineLink['data']['target'];
isExternal?: boolean;
children: React.ReactNode;
}) {
const { href, isExternal, contentRef, children } = props;
const { href, isExternal, contentRef, target, children } = props;
const isMailto = href.startsWith('mailto:');
return (
<StyledLink
href={href}
target={target ? `_${target}` : undefined}
insights={{
type: 'link_click',
link: {
+10 -6
View File
@@ -99,12 +99,16 @@ async function getSectionsFromNodes(
const revisionTags = getRevisionTags(context.revision);
const updateNodes = await Promise.all(
block.nodes.map(async (update) =>
getSectionsFromNodes(
update.nodes as DocumentBlock[],
context,
{ h1, h2 },
resolveBlockTags(update.data.tags, revisionTags).map((tag) => tag.slug)
)
update.type === 'update'
? getSectionsFromNodes(
update.nodes as DocumentBlock[],
context,
{ h1, h2 },
resolveBlockTags(update.data.tags, revisionTags).map(
(tag) => tag.slug
)
)
: []
)
);
for (const updateSections of updateNodes) {
+1 -1
View File
@@ -17,7 +17,7 @@ import {
describe('getDocumentFilterableTags', () => {
it('ignores category and deleted references without removing their stored assignments', () => {
const document = createUpdatesDocument([['category', 'constructor', 'missing']]);
const category = { ...createTag('category', 'Products'), kind: 'category' };
const category = { ...createTag('category', 'Products'), kind: 'category' as const };
const normal = createTag('constructor', 'Constructor');
const revision = { tags: [category, normal] } as unknown as Revision;
const before = JSON.stringify(document);
+4
View File
@@ -75,6 +75,10 @@ export function getDocumentFilterableTags(
for (const updatesBlock of getBlocksByType(document, 'updates')) {
for (const updateBlock of updatesBlock.nodes) {
if (updateBlock.type !== 'update') {
continue;
}
for (const tag of resolveBlockTags(updateBlock.data.tags, revisionTags)) {
if (seen.has(tag.slug)) {
continue;
+4
View File
@@ -78,6 +78,10 @@ export async function servePageRSS(
updatesBlocks.forEach((updatesBlock) => {
updatesBlock.nodes.forEach((update) => {
if (update.type !== 'update') {
return;
}
const heading = update.nodes[0];
if (!heading || !isHeadingBlock(heading)) {
return;