Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] release #134

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .changeset/neat-lobsters-lick.md

This file was deleted.

10 changes: 10 additions & 0 deletions packages/adapters/astro/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @galactiks/astro-integration

## 0.2.13

### Patch Changes

- [`f8efe83`](https://github.com/thegalactiks/explorer/commit/f8efe83b0d724eeb239f3581c56ad1133282c3b0) Thanks [@emmanuelgautier](https://github.com/emmanuelgautier)! - upgrade packages and fix duplicated page bug

- Updated dependencies [[`f8efe83`](https://github.com/thegalactiks/explorer/commit/f8efe83b0d724eeb239f3581c56ad1133282c3b0)]:
- @galactiks/config@0.2.9
- @galactiks/explorer@0.2.12

## 0.2.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/astro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galactiks/astro-integration",
"version": "0.2.12",
"version": "0.2.13",
"description": "Galactiks Astro integration",
"author": "thegalactiks",
"types": "./dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/adapters/astro/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"target": "ES2021",
"module": "ES2022",
"declarationDir": "./dist",
"outDir": "./dist"
}
"outDir": "./dist",
},
}
6 changes: 6 additions & 0 deletions packages/config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @galactiks/config

## 0.2.9

### Patch Changes

- [`f8efe83`](https://github.com/thegalactiks/explorer/commit/f8efe83b0d724eeb239f3581c56ad1133282c3b0) Thanks [@emmanuelgautier](https://github.com/emmanuelgautier)! - upgrade packages and fix duplicated page bug

## 0.2.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galactiks/config",
"version": "0.2.8",
"version": "0.2.9",
"description": "Reading Galactiks configurations files and get config during website generation",
"author": "thegalactiks",
"types": "./dist/index.d.mts",
Expand Down
4 changes: 2 additions & 2 deletions packages/config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"allowJs": true,
"target": "ES2021",
"module": "ES2022",
"outDir": "./dist"
}
"outDir": "./dist",
},
}
4 changes: 2 additions & 2 deletions packages/contentlayer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"allowJs": true,
"target": "ES2021",
"module": "ES2022",
"outDir": "./dist"
}
"outDir": "./dist",
},
}
9 changes: 9 additions & 0 deletions packages/explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @galactiks/explorer

## 0.2.12

### Patch Changes

- [`f8efe83`](https://github.com/thegalactiks/explorer/commit/f8efe83b0d724eeb239f3581c56ad1133282c3b0) Thanks [@emmanuelgautier](https://github.com/emmanuelgautier)! - upgrade packages and fix duplicated page bug

- Updated dependencies [[`f8efe83`](https://github.com/thegalactiks/explorer/commit/f8efe83b0d724eeb239f3581c56ad1133282c3b0)]:
- @galactiks/config@0.2.9

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/explorer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galactiks/explorer",
"version": "0.2.11",
"version": "0.2.12",
"description": "Ensure Galactiks content model consistence, explore content built with ContentLayer and create dynamically missing pages and fields for SEO purposes",
"author": "thegalactiks",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/explorer/src/core/content/hydrate/common.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ContentlayerWebPageDocument } from '../../types/index.mjs'
import type { ContentlayerWebPageDocument } from '../../types/index.mjs';
import { addBodyRender, emptyRender } from './render.mjs';

export function createPage<T>(
Expand Down
5 changes: 4 additions & 1 deletion packages/explorer/src/core/content/hydrate/index.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { Content, ContentlayerWebPageDocument } from '../../types/index.mjs';
import type {
Content,
ContentlayerWebPageDocument,
} from '../../types/index.mjs';
import type { ComputeDTO } from './types.mjs';
import { computeRemainingListingPages } from './listing-pages.mjs';
import { computeDocumentsUrl } from './urls.mjs';
Expand Down
120 changes: 65 additions & 55 deletions packages/explorer/src/core/content/hydrate/listing-pages.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import type { Id } from '@galactiks/contentlayer';
import { documentByIdentifierSelector, isInLanguage } from '../selectors.mjs';
import { createIdentifierFromString } from '../utils.mjs';
import type { ContentlayerWebPageDocument, ContentlayerDocumentWithRender, ContentlayerWebPageDocumentWithRender } from '../../types/index.mjs';
import type {
ContentlayerWebPageDocument,
ContentlayerDocumentWithRender,
ContentlayerWebPageDocumentWithRender,
} from '../../types/index.mjs';

import { createPage } from './common.mjs';

Expand All @@ -17,67 +21,73 @@ const createListingPage = (
}
);

export const computeRemainingListingPages = () => async (
documents: ContentlayerWebPageDocumentWithRender[]
) => {
const getDocumentByIdentifier = documentByIdentifierSelector(documents);
export const computeRemainingListingPages =
() => async (documents: ContentlayerWebPageDocumentWithRender[]) => {
const getDocumentByIdentifier = documentByIdentifierSelector(documents);

return documents.reduce((acc, _d) => {
const templateDocument: Partial<ContentlayerWebPageDocument> = {
dateCreated: _d.dateCreated,
datePublished: _d.datePublished,
dateModified: _d.dateModified,
inLanguage: _d.inLanguage,
};
return documents.reduce((acc, _d) => {
const templateDocument: Partial<ContentlayerWebPageDocument> = {
dateCreated: _d.dateCreated,
datePublished: _d.datePublished,
dateModified: _d.dateModified,
inLanguage: _d.inLanguage,
};

if (_d.isPartOf) {
const _isPartOfIdentifier = createIdentifierFromString(_d.isPartOf);
if (_d.isPartOf) {
const _isPartOfIdentifier = createIdentifierFromString(_d.isPartOf);

// If parent page does not exist, create it
if (acc.some((_a) => _a.identifier === _isPartOfIdentifier && isInLanguage(_a, _d.inLanguage)) === false) {
let translationOfWork: Id | undefined = undefined;
if (_d.translationOfWork && _d.translationOfWork['@id']) {
const translationOfWorkDocument = getDocumentByIdentifier(
_d.translationOfWork['@id']
);
if (translationOfWorkDocument?.isPartOf) {
translationOfWork = {
type: 'Id',
'@id': translationOfWorkDocument.isPartOf,
};
// If parent page does not exist, create it
if (
acc.some(
(_a) =>
_a.identifier === _isPartOfIdentifier &&
isInLanguage(_a, _d.inLanguage)
) === false
) {
let translationOfWork: Id | undefined = undefined;
if (_d.translationOfWork && _d.translationOfWork['@id']) {
const translationOfWorkDocument = getDocumentByIdentifier(
_d.translationOfWork['@id']
);
if (translationOfWorkDocument?.isPartOf) {
translationOfWork = {
type: 'Id',
'@id': translationOfWorkDocument.isPartOf,
};
}
}

acc = acc.concat(
createListingPage(_isPartOfIdentifier, {
...templateDocument,
translationOfWork,
})
);
}
}

// Create all keywords pages not existing yet
if (Array.isArray(_d.keywords)) {
acc = acc.concat(
createListingPage(_isPartOfIdentifier, {
...templateDocument,
translationOfWork,
})
_d.keywords
.map(createIdentifierFromString)
.filter(
(_k) =>
_k &&
acc.some(
(_a) =>
_a.identifier === _k && isInLanguage(_a, _d.inLanguage)
) === false
)
.map((_k) =>
createListingPage(_k, {
...templateDocument,
type: 'Tag',
})
)
);
}
}

// Create all keywords pages not existing yet
if (Array.isArray(_d.keywords)) {
acc = acc.concat(
_d.keywords
.map(createIdentifierFromString)
.filter(
(_k) =>
_k &&
acc.some(
(_a) => _a.identifier === _k && isInLanguage(_a, _d.inLanguage)
) === false
)
.map((_k) =>
createListingPage(_k, {
...templateDocument,
type: 'Tag',
})
)
);
}

return acc;
}, documents);
};
return acc;
}, documents);
};
17 changes: 15 additions & 2 deletions packages/explorer/src/core/content/hydrate/missing-fields.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import type { GalactiksConfig } from '@galactiks/config';
import type { Content, ContentlayerPerson, ContentlayerDocumentWithURL, ContentlayerWebPageDocumentWithRender, Person } from '../../types/index.mjs';
import type {
Content,
ContentlayerPerson,
ContentlayerDocumentWithURL,
ContentlayerWebPageDocumentWithRender,
Person,
} from '../../types/index.mjs';
import { documentByTypeAndIdentifierAndLanguageSelector } from '../selectors.mjs';
import { alternatesHeaderBuilder, breadcrumbBuilder, getBasicHeaders, getOpenGraphObjects, getStructuredDataSchemas, getTwitterCard } from '../metadata/index.mjs';
import {
alternatesHeaderBuilder,
breadcrumbBuilder,
getBasicHeaders,
getOpenGraphObjects,
getStructuredDataSchemas,
getTwitterCard,
} from '../metadata/index.mjs';

export const computeMissingFields =
(_: GalactiksConfig, people: ContentlayerPerson[]) =>
Expand Down
5 changes: 1 addition & 4 deletions packages/explorer/src/core/content/hydrate/render.mts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { getMDXComponent } from 'mdx-bundler/client/index.js';
import * as React from 'react';
import type {
ContentlayerDocumentTypes,
Render,
} from '../../types/index.mjs';
import type { ContentlayerDocumentTypes, Render } from '../../types/index.mjs';

export const emptyRender: Render = () => ({ Content: () => null });

Expand Down
67 changes: 42 additions & 25 deletions packages/explorer/src/core/content/hydrate/same-language.mts
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);
};
};
Loading
Loading