Skip to content

Commit 3293516

Browse files
authored
Merge pull request #166 from ilnytskyi/patch-1
Allow core.js customisation
2 parents 1563f75 + 9f7c16b commit 3293516

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

server/services/core.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const getLanguageLinks = async (config, page, contentType, defaultURL) => {
7777

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

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

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

@@ -294,7 +294,7 @@ const createSitemap = async (cache, invalidationObject) => {
294294
const {
295295
sitemapEntries,
296296
cacheEntries,
297-
} = await createSitemapEntries(invalidationObject);
297+
} = await getService('core').createSitemapEntries(invalidationObject);
298298
// Format cache to regular entries
299299
const formattedCache = formatCache(cache, invalidationObject);
300300

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

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

320320
if (cachingEnabled && autoGenerationEnabled) {
321321
if (!cache) {
@@ -334,6 +334,7 @@ const createSitemap = async (cache, invalidationObject) => {
334334
};
335335

336336
module.exports = () => ({
337+
getDefaultLanguageLink,
337338
getLanguageLinks,
338339
getSitemapPageData,
339340
createSitemapEntries,

0 commit comments

Comments
 (0)