File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,16 @@ export function getSiteStructureSections(
3939 : [ ] ;
4040}
4141
42+ /**
43+ * Filter site spaces to only include those matching the given locale
44+ */
45+ export function filterSiteSpacesByLocale (
46+ siteSpaces : SiteSpace [ ] ,
47+ locale : TranslationLanguage | undefined
48+ ) : SiteSpace [ ] {
49+ return siteSpaces . filter ( ( siteSpace ) => siteSpace . space . language === locale ) ;
50+ }
51+
4252/*
4353 * Gets all site spaces, in a site structure and overrides the title
4454 */
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { throwIfDataError } from '@/lib/data';
33import { fromPageMarkdown , toPageMarkdown } from '@/lib/markdownPage' ;
44import { joinPath } from '@/lib/paths' ;
55import { getIndexablePages } from '@/lib/sitemap' ;
6- import { getSiteStructureSections } from '@/lib/sites' ;
6+ import { filterSiteSpacesByLocale , getSiteStructureSections } from '@/lib/sites' ;
77import type { RevisionPageDocument , SiteSection , SiteSpace } from '@gitbook/api' ;
88import assertNever from 'assert-never' ;
99import type { Paragraph } from 'mdast' ;
@@ -118,7 +118,9 @@ export async function streamMarkdownFromSiteSpaces(
118118 const allPages : Array < { page : RevisionPageDocument ; siteSpace : SiteSpace ; basePath : string } > =
119119 [ ] ;
120120
121- for ( const siteSpace of siteSpaces ) {
121+ const filteredSiteSpaces = filterSiteSpacesByLocale ( siteSpaces , context . locale ) ;
122+
123+ for ( const siteSpace of filteredSiteSpaces ) {
122124 const siteSpaceUrl = siteSpace . urls . published ;
123125 if ( ! siteSpaceUrl ) {
124126 continue ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { throwIfDataError } from '@/lib/data';
33import type { GitBookLinker } from '@/lib/links' ;
44import { joinPath } from '@/lib/paths' ;
55import { type FlatPageEntry , getIndexablePages } from '@/lib/sitemap' ;
6- import { getLocalizedTitle , getSiteStructureSections } from '@/lib/sites' ;
6+ import { filterSiteSpacesByLocale , getLocalizedTitle , getSiteStructureSections } from '@/lib/sites' ;
77import type { SiteSection , SiteSpace } from '@gitbook/api' ;
88import assertNever from 'assert-never' ;
99import type { ListItem , Paragraph , Root , RootContent } from 'mdast' ;
@@ -131,8 +131,10 @@ async function getNodesFromSiteSpaces(
131131) : Promise < RootContent [ ] > {
132132 const { dataFetcher, linker } = context ;
133133
134+ const filteredSiteSpaces = filterSiteSpacesByLocale ( siteSpaces , context . locale ) ;
135+
134136 const all = await Promise . all (
135- siteSpaces . map ( async ( siteSpace ) : Promise < RootContent [ ] > => {
137+ filteredSiteSpaces . map ( async ( siteSpace ) : Promise < RootContent [ ] > => {
136138 const siteSpaceUrl = siteSpace . urls . published ;
137139 if ( ! siteSpaceUrl ) {
138140 return [ ] ;
You can’t perform that action at this time.
0 commit comments