Skip to content

Commit

Permalink
Merge pull request #91 from thegalactiks/changeset-release/main
Browse files Browse the repository at this point in the history
[ci] release
  • Loading branch information
emmanuelgautier authored Oct 25, 2023
2 parents 9e1871e + 8500ea6 commit 94772ee
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 93 deletions.
8 changes: 0 additions & 8 deletions .changeset/neat-moons-admire.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.5

### Patch Changes

- [`9e1871e`](https://github.com/thegalactiks/explorer/commit/9e1871e5918a76e65113010815a3437f97cbdec8) Thanks [@emmanuelgautier](https://github.com/emmanuelgautier)! - fixes some bugs and add sitemap news support

- Updated dependencies [[`9e1871e`](https://github.com/thegalactiks/explorer/commit/9e1871e5918a76e65113010815a3437f97cbdec8)]:
- @galactiks/config@0.2.5
- @galactiks/explorer@0.2.5

## 0.2.4

### 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.4",
"version": "0.2.5",
"description": "Galactiks Astro integration",
"author": "thegalactiks",
"types": "./dist/index.d.ts",
Expand Down
30 changes: 20 additions & 10 deletions packages/adapters/astro/src/preset.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,41 @@ export const integrationsPreset = (): AstroIntegration[] => [
partytown(),
prefetch(),
sitemap({
i18n: defaultLocale ? {
defaultLocale,
locales: Object.fromEntries(getLanguages().map(lang => ([lang, lang])))
} : undefined,
i18n: defaultLocale
? {
defaultLocale,
locales: Object.fromEntries(
getLanguages().map((lang) => [lang, lang])
),
}
: undefined,
serialize: async (item) => {
const page = await getPageByURL(item.url);
if (!page) {
return undefined;
}

return ({
return {
url: page.url,
lastmod: isValid(page.dateModified) ? page.dateModified.toISOString() : undefined,
lastmod: isValid(page.dateModified)
? page.dateModified.toISOString()
: undefined,
news: page.type === 'Article' && {
publication: {
name: getConfig().webManifest.name,
language: (page.inLanguage && getDefaultLanguage())?.substring(0, 2).toLowerCase(),
language: (page.inLanguage && getDefaultLanguage())
?.substring(0, 2)
.toLowerCase(),
},

publication_date: isValid(page.datePublished) ? page.datePublished.toISOString() : undefined,
publication_date: isValid(page.datePublished)
? page.datePublished.toISOString()
: undefined,
title: page.name,
keywords: page.keywords?.join(', '),
},
});
}
};
},
}),
robotsTxt(),
critters(),
Expand Down
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.5

### Patch Changes

- [`9e1871e`](https://github.com/thegalactiks/explorer/commit/9e1871e5918a76e65113010815a3437f97cbdec8) Thanks [@emmanuelgautier](https://github.com/emmanuelgautier)! - fixes some bugs and add sitemap news support

## 0.2.4

### 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.4",
"version": "0.2.5",
"description": "Reading Galactiks configurations files and get config during website generation",
"author": "thegalactiks",
"types": "./dist/index.d.mts",
Expand Down
6 changes: 6 additions & 0 deletions packages/contentlayer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @galactiks/contentlayer

## 0.1.4

### Patch Changes

- [`9e1871e`](https://github.com/thegalactiks/explorer/commit/9e1871e5918a76e65113010815a3437f97cbdec8) Thanks [@emmanuelgautier](https://github.com/emmanuelgautier)! - fixes some bugs and add sitemap news support

## 0.1.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/contentlayer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galactiks/contentlayer",
"version": "0.1.3",
"version": "0.1.4",
"description": "Galactiks contentlayer configurations",
"author": "galactiks",
"types": "./dist/index.d.mts",
Expand Down
10 changes: 10 additions & 0 deletions packages/explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @galactiks/explorer

## 0.2.5

### Patch Changes

- [`9e1871e`](https://github.com/thegalactiks/explorer/commit/9e1871e5918a76e65113010815a3437f97cbdec8) Thanks [@emmanuelgautier](https://github.com/emmanuelgautier)! - fixes some bugs and add sitemap news support

- Updated dependencies [[`9e1871e`](https://github.com/thegalactiks/explorer/commit/9e1871e5918a76e65113010815a3437f97cbdec8)]:
- @galactiks/config@0.2.5
- @galactiks/contentlayer@0.1.4

## 0.2.4

### 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.4",
"version": "0.2.5",
"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
144 changes: 74 additions & 70 deletions packages/explorer/src/core/content/compute.mts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ function createPage<T>(
body: document.body?.raw
? addBodyRender(document.body)
: {
raw: '',
code: '',
render: emptyRender,
},
raw: '',
code: '',
render: emptyRender,
},
} as T;
}

Expand Down Expand Up @@ -106,21 +106,25 @@ const computeRemainingListingPages = async (
) {
let translationOfWork: Id | undefined = undefined;
if (_d.translationOfWork && _d.translationOfWork['@id']) {
const translationOfWorkDocument = getDocumentByIdentifier(_d.translationOfWork['@id']);
console.log(_d.translationOfWork, translationOfWorkDocument)
const translationOfWorkDocument = getDocumentByIdentifier(
_d.translationOfWork['@id']
);
console.log(_d.translationOfWork, translationOfWorkDocument);

if (translationOfWorkDocument?.isPartOf) {
translationOfWork = {
"type": "Id",
"@id": translationOfWorkDocument.isPartOf,
type: 'Id',
'@id': translationOfWorkDocument.isPartOf,
};
}
}

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

// Create all keywords pages not existing yet
Expand All @@ -145,71 +149,71 @@ const computeRemainingListingPages = async (

return acc;
}, documents);
}
};

const computeMissingFields =
(_: GalactiksConfig, people: ContentlayerPerson[]) =>
async (
documents: Array<
ContentlayerDocumentWithURL & ContentlayerWebPageDocumentWithRender
>
): Promise<Content[]> => {
const buildBreadcrumb = breadcrumbBuilder(documents);
const buildAlternates = alternatesHeaderBuilder(documents);
const selectPersonByIdentifierAndLanguage =
documentByTypeAndIdentifierAndLanguageSelector('Person', documents);

const getAuthor = (
identifier?: string,
inLanguage?: string
): Person | undefined => {
let author;
if (identifier) {
author = selectPersonByIdentifierAndLanguage(identifier, inLanguage);
} else if (people.length === 1) {
author = people[0];
async (
documents: Array<
ContentlayerDocumentWithURL & ContentlayerWebPageDocumentWithRender
>
): Promise<Content[]> => {
const buildBreadcrumb = breadcrumbBuilder(documents);
const buildAlternates = alternatesHeaderBuilder(documents);
const selectPersonByIdentifierAndLanguage =
documentByTypeAndIdentifierAndLanguageSelector('Person', documents);

const getAuthor = (
identifier?: string,
inLanguage?: string
): Person | undefined => {
let author;
if (identifier) {
author = selectPersonByIdentifierAndLanguage(identifier, inLanguage);
} else if (people.length === 1) {
author = people[0];
}

return (
author && {
identifier: author.identifier,
name: author.name,
description: author.description,
url: author.url,
image: author.image,
}
);
};

return (
author && {
identifier: author.identifier,
name: author.name,
description: author.description,
url: author.url,
image: author.image,
}
);
return documents.map((document) => {
const dateCreated = new Date(document.dateCreated);
const contentWithoutHeaders: Omit<Content, 'headers'> = {
...document,
author: getAuthor(document.author, document.inLanguage),
breadcrumb: buildBreadcrumb(document),
dateCreated,
dateModified: document.dateModified
? new Date(document.dateModified)
: dateCreated,
datePublished: document.datePublished
? new Date(document.datePublished)
: dateCreated,
};

return documents.map((document) => {
const dateCreated = new Date(document.dateCreated);
const contentWithoutHeaders: Omit<Content, 'headers'> = {
...document,
author: getAuthor(document.author, document.inLanguage),
breadcrumb: buildBreadcrumb(document),
dateCreated,
dateModified: document.dateModified
? new Date(document.dateModified)
: dateCreated,
datePublished: document.datePublished
? new Date(document.datePublished)
: dateCreated,
};

return {
...contentWithoutHeaders,
headers: {
...getBasicHeaders(contentWithoutHeaders),
alternates: buildAlternates(contentWithoutHeaders),
structuredDataSchemas: getStructuredDataSchemas(
contentWithoutHeaders
),
openGraph: getOpenGraphObjects(contentWithoutHeaders),
twitterCard: getTwitterCard(contentWithoutHeaders),
},
};
});
};
return {
...contentWithoutHeaders,
headers: {
...getBasicHeaders(contentWithoutHeaders),
alternates: buildAlternates(contentWithoutHeaders),
structuredDataSchemas: getStructuredDataSchemas(
contentWithoutHeaders
),
openGraph: getOpenGraphObjects(contentWithoutHeaders),
twitterCard: getTwitterCard(contentWithoutHeaders),
},
};
});
};

export const computeDocuments = async ({
config,
Expand Down
3 changes: 2 additions & 1 deletion packages/explorer/src/core/content/repositories/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const getPageByIdentifier = async (
filters?: RepositoryFilters
) => documentByIdentifierSelector(await getPages(filters))(identifier);

export const getPageByURL = async (url: string) => (await getPages()).find(_p => _p.url === url)
export const getPageByURL = async (url: string) =>
(await getPages()).find((_p) => _p.url === url);

export const getTagPageByKeyword = async (
keyword: string,
Expand Down

0 comments on commit 94772ee

Please sign in to comment.