Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Revert publication name handling
Browse files Browse the repository at this point in the history
  • Loading branch information
zarathustra323 committed Jun 10, 2021
1 parent f59fb15 commit 1f3b2ff
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions services/sitemaps/src/routes/google-news.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,17 @@ const createPublication = (name, language) => {
return `<news:publication>${parts.join('')}</news:publication>`;
};

const createUrl = (website, url, publicationName) => {
const {
loc,
title,
published,
publication,
images,
} = url;
const name = publicationName || publication.name;
const createUrl = (website, {
loc,
title,
published,
publication,
images,
}) => {
// News requires a publication, a published date and a title.
if (!name || !published || !title) return null;
if (!publication || !published || !title) return null;
const parts = [
createPublication(name, website.language.primaryCode),
createPublication(publication.name, website.language.primaryCode),
`<news:publication_date>${moment(published).toISOString()}</news:publication_date>`,
`<news:title>${xml.encode(title)}</news:title>`,
];
Expand All @@ -66,7 +64,6 @@ const createUrl = (website, url, publicationName) => {

module.exports = asyncRoute(async (req, res) => {
const input = parseJson(req.get('x-google-news-input') || '{}');
const publicationName = req.get('x-google-news-publication-name');
const variables = input ? { input } : undefined;

const { apollo, websiteContext: website } = res.locals;
Expand All @@ -80,7 +77,7 @@ module.exports = asyncRoute(async (req, res) => {
.setAttr('xmlns:image', 'http://www.google.com/schemas/sitemap-image/1.1')
.setAttr('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance')
.setAttr('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-news/0.9 http://www.google.com/schemas/sitemap-news/0.9/sitemap-news.xsd')
.setUrls(contentSitemapNewsUrls.map(url => createUrl(website, url, publicationName)));
.setUrls(contentSitemapNewsUrls.map(url => createUrl(website, url)));

res.end(urlset.build());
});

0 comments on commit 1f3b2ff

Please sign in to comment.