Skip to content

Commit

Permalink
[Blog Migration] Topics URL 404s on lang pages (#985)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgclayton authored Jul 25, 2023
1 parent 34e1e61 commit 9aa7b91
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions libs/scripts/taxonomy.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,19 @@ function parseTaxonomyJson(data, root) {
: LEVEL_INDEX.level1);

const name = level3 || level2 || level1;

const category = row[TAXONOMY_FIELDS.type]?.trim().toLowerCase() || INTERNALS;

// skip duplicates
if (!isProduct(category) && taxonomy.topics[name]) return taxonomy;
if (isProduct(category) && taxonomy.products[name]) return taxonomy;

const link = [row[TAXONOMY_FIELDS.link]].reduce((_url) => {
if (_url) {
const u = new URL(_url);
const current = new URL(window.location.href);
return `${current.origin}${u.pathname}`;
}

return `${root}/${generateUri(name)}`;
}, null);

const taxLink = row[TAXONOMY_FIELDS.link]
? new URL([row[TAXONOMY_FIELDS.link]])
: generateUri(name);
const path = taxLink.pathname
? taxLink.pathname?.replace('.html', '').split('/topics/').pop()
: taxLink;
const link = `${root}/${path}`;
const hidden = !!row[TAXONOMY_FIELDS.hidden]?.trim();
const skipMeta = !!row[TAXONOMY_FIELDS.excludeFromMetadata]?.trim();

Expand Down Expand Up @@ -178,16 +174,9 @@ export default async (config, route, target) => {
NO_INTERLINKS,

lookup(topic) {
// might be a product (product would have priori)
let t = this.get(topic, PRODUCTS);
if (!t) {
// might be a product without the leading Adobe
t = this.get(topic.replace('Adobe ', ''), PRODUCTS);
if (!t) {
t = this.get(topic);
}
}
return t;
return this.get(topic, PRODUCTS)
|| this.get(topic.replace('Adobe ', ''), PRODUCTS)
|| this.get(topic);
},

get(topic, cat) {
Expand Down

0 comments on commit 9aa7b91

Please sign in to comment.