Skip to content

Commit

Permalink
Allow core.js customisation
Browse files Browse the repository at this point in the history
Call methods via service
  • Loading branch information
ilnytskyi authored Apr 3, 2024
1 parent 1563f75 commit 7c45e6d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/services/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const getLanguageLinks = async (config, page, contentType, defaultURL) => {

// add optional x-default link url
if (config.defaultLanguageUrlType) {
const defaultLink = await getDefaultLanguageLink(config, links);
const defaultLink = await getService('core').getDefaultLanguageLink(config, links);
if (defaultLink) links.push(defaultLink);
}

Expand Down Expand Up @@ -119,7 +119,7 @@ const getSitemapPageData = async (config, page, contentType) => {
const pageData = {
lastmod: page.updatedAt,
url: url,
links: await getLanguageLinks(config, page, contentType, url),
links: await getService('core').getLanguageLinks(config, page, contentType, url),
changefreq: config.contentTypes[contentType]['languages'][locale].changefreq || 'monthly',
priority: parseFloat(config.contentTypes[contentType]['languages'][locale].priority) || 0.5,
};
Expand Down Expand Up @@ -156,7 +156,7 @@ const createSitemapEntries = async (invalidationObject) => {

// Add formatted sitemap page data to the array.
await Promise.all(pages.map(async (page, i) => {
const pageData = await getSitemapPageData(config, page, contentType);
const pageData = await getService('core').getSitemapPageData(config, page, contentType);
if (pageData) {
sitemapEntries.push(pageData);

Expand Down Expand Up @@ -294,7 +294,7 @@ const createSitemap = async (cache, invalidationObject) => {
const {
sitemapEntries,
cacheEntries,
} = await createSitemapEntries(invalidationObject);
} = await getService('core').createSitemapEntries(invalidationObject);
// Format cache to regular entries
const formattedCache = formatCache(cache, invalidationObject);

Expand All @@ -315,7 +315,7 @@ const createSitemap = async (cache, invalidationObject) => {
allEntries.map((sitemapEntry) => sitemap.write(sitemapEntry));
sitemap.end();

const sitemapId = await saveSitemap('default', sitemap, isIndex);
const sitemapId = await getService('core').saveSitemap('default', sitemap, isIndex);

if (cachingEnabled && autoGenerationEnabled) {
if (!cache) {
Expand Down

0 comments on commit 7c45e6d

Please sign in to comment.