Skip to content

Commit

Permalink
feat(@galactiks/astro-integration): add sitemap news support
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelgautier committed Sep 24, 2023
1 parent 88615e0 commit 7639900
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion packages/adapters/astro/src/preset.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,47 @@ import partytown from '@astrojs/partytown';
import prefetch from '@astrojs/prefetch';
import react from '@astrojs/react';
import sitemap from '@astrojs/sitemap';
import { getConfig, getDefaultLanguage, getLanguages } from '@galactiks/config';
import critters from 'astro-critters';
import robotsTxt from 'astro-robots-txt';
import { getPageByURL } from '@galactiks/explorer';

const defaultLocale = getDefaultLanguage();

export const integrationsPreset = (): AstroIntegration[] => [
react(),
partytown(),
prefetch(),
sitemap(),
sitemap({
i18n: defaultLocale ? {
defaultLocale,
locales: Object.fromEntries(getLanguages().map(lang => ([lang, lang])))
} : undefined,
serialize: async (item) => {
const page = await getPageByURL(item.url);
if (!page) {
return item;
}

// console.log(page.dateModified.toUTCString());
// console.log(page.datePublished.toISOString());

return ({
url: page.url,
// lastmod: page.dateModified.toUTCString(),
news: {
publication: {
name: getConfig().webManifest.name,
language: getDefaultLanguage(),
},

// publication_date: page.datePublished.toISOString(),
title: page.name,
keywords: page.keywords?.join(', '),
},
});
}
}),
robotsTxt(),
critters(),
];

0 comments on commit 7639900

Please sign in to comment.