mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-18 14:20:18 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 276a170155 | |||
| a4074221df | |||
| 5d19ad7ba0 |
@@ -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.
|
||||
@@ -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
@@ -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: {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user