-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from thegalactiks/changeset-release/main
[ci] release
- Loading branch information
Showing
21 changed files
with
188 additions
and
115 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ | |
"target": "ES2021", | ||
"module": "ES2022", | ||
"declarationDir": "./dist", | ||
"outDir": "./dist" | ||
} | ||
"outDir": "./dist", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ | |
"allowJs": true, | ||
"target": "ES2021", | ||
"module": "ES2022", | ||
"outDir": "./dist" | ||
} | ||
"outDir": "./dist", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ | |
"allowJs": true, | ||
"target": "ES2021", | ||
"module": "ES2022", | ||
"outDir": "./dist" | ||
} | ||
"outDir": "./dist", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 15 additions & 2 deletions
17
packages/explorer/src/core/content/hydrate/missing-fields.mts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 42 additions & 25 deletions
67
packages/explorer/src/core/content/hydrate/same-language.mts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,66 @@ | ||
import type { GalactiksConfig } from '@galactiks/config'; | ||
import groupBy from 'lodash.groupby'; | ||
import type { ContentlayerDocumentWithRender, ContentlayerWebPageDocument, ContentlayerWebPageDocumentWithRender } from '../../types/index.mjs'; | ||
import type { | ||
ContentlayerDocumentWithRender, | ||
ContentlayerWebPageDocument, | ||
ContentlayerWebPageDocumentWithRender, | ||
} from '../../types/index.mjs'; | ||
import { documentByIdentifierAndLanguageSelector } from '../selectors.mjs'; | ||
import { createPage } from './common.mjs'; | ||
|
||
const groupLocalesByLanguage = (config: GalactiksConfig) => | ||
groupBy(config.locales?.available ?? [], locale => new Intl.Locale(locale).language) | ||
groupBy( | ||
config.locales?.available ?? [], | ||
(locale) => new Intl.Locale(locale).language | ||
); | ||
|
||
const getLanguagesWithMultipleLocales = (config: GalactiksConfig) => Object.fromEntries( | ||
Object.entries(groupLocalesByLanguage(config)).filter(([, locales]) => locales.length > 1) | ||
) | ||
const getLanguagesWithMultipleLocales = (config: GalactiksConfig) => | ||
Object.fromEntries( | ||
Object.entries(groupLocalesByLanguage(config)).filter( | ||
([, locales]) => locales.length > 1 | ||
) | ||
); | ||
|
||
export const createSameLanguagePages = (config: GalactiksConfig) => { | ||
const localesGroupedByLanguage = getLanguagesWithMultipleLocales(config) | ||
const languagesWithMultipleLocales = Object.keys(localesGroupedByLanguage) | ||
const localesGroupedByLanguage = getLanguagesWithMultipleLocales(config); | ||
const languagesWithMultipleLocales = Object.keys(localesGroupedByLanguage); | ||
|
||
return async ( | ||
documents: ContentlayerWebPageDocumentWithRender[] | ||
) => { | ||
return async (documents: ContentlayerWebPageDocumentWithRender[]) => { | ||
if (languagesWithMultipleLocales.length === 0) { | ||
return documents | ||
return documents; | ||
} | ||
const selectPageByIdentifierAndInLanguage = documentByIdentifierAndLanguageSelector(documents) | ||
const selectPageByIdentifierAndInLanguage = | ||
documentByIdentifierAndLanguageSelector(documents); | ||
|
||
return documents.reduce((acc, _d) => { | ||
if (!_d.inLanguage) { | ||
return acc | ||
return acc; | ||
} | ||
|
||
const language = new Intl.Locale(_d.inLanguage).language | ||
const language = new Intl.Locale(_d.inLanguage).language; | ||
if (!languagesWithMultipleLocales.includes(language)) { | ||
return acc | ||
return acc; | ||
} | ||
|
||
acc = acc.concat( | ||
localesGroupedByLanguage[language] | ||
.filter(locale => locale !== _d.inLanguage) // Exclude current language | ||
.filter(locale => selectPageByIdentifierAndInLanguage(_d.identifier, locale) === undefined) // Exclude already existing locale | ||
.map(locale => createPage<ContentlayerDocumentWithRender<ContentlayerWebPageDocument>>(_d.identifier, { | ||
..._d, | ||
inLanguage: locale | ||
})) | ||
) | ||
|
||
return acc | ||
}, documents) | ||
.filter((locale) => locale !== _d.inLanguage) // Exclude current language | ||
.filter( | ||
(locale) => | ||
selectPageByIdentifierAndInLanguage(_d.identifier, locale) === | ||
undefined | ||
) // Exclude already existing locale | ||
.map((locale) => | ||
createPage< | ||
ContentlayerDocumentWithRender<ContentlayerWebPageDocument> | ||
>(_d.identifier, { | ||
..._d, | ||
inLanguage: locale, | ||
}) | ||
) | ||
); | ||
|
||
return acc; | ||
}, documents); | ||
}; | ||
}; |
Oops, something went wrong.