Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hreflang #426

Merged
merged 29 commits into from
Dec 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
const
  • Loading branch information
basecode committed Dec 14, 2023
commit 3b1660108cabc37b9223878d15da836a33a5bccf
7 changes: 4 additions & 3 deletions tools/sitemap/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import fs from 'fs/promises';
import convert from 'xml-js';
import path from 'path';

const url = 'https://www.bitdefender.com.au/solutions/query-index.json';
const QUERY_INDEX_URL = 'https://www.bitdefender.com.au/solutions/query-index.json';
const LOCALE_URL = 'https://www.bitdefender.com.au';

const hreflangMap = [
['en-ro', { baseUrl: 'https://www.bitdefender.ro', pageType: '.html' }],
Expand All @@ -26,7 +27,7 @@ const hreflangMap = [
];

try {
const response = await fetch(url);
const response = await fetch(QUERY_INDEX_URL);
const json = await response.json();
const sitemapPath = path.join(process.cwd(), '../../solutions/sitemap.xml');

Expand All @@ -37,7 +38,7 @@ try {
xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9',
},
url: json?.data.map((row) => ({
loc: `https://www.bitdefender.com.au${row.path}`,
loc: `${LOCALE_URL}${row.path}`,
'xhtml:link': Object.keys(hreflangMap).map((key) => {
const hreflang = hreflangMap[key][0];
const href = `${hreflangMap[key][1].baseUrl}${row.path}${hreflangMap[key][1].pageType}`;
Expand Down