Move Category Metadata to homepages-repo
Requires: 1309 of the homepages-repo Ticket: 1302
This commit is contained in:
parent
3f1417a412
commit
e8e1655a2d
2 changed files with 32 additions and 91 deletions
|
@ -1,81 +0,0 @@
|
||||||
const PAGES = require('../../ui/constants/pages');
|
|
||||||
|
|
||||||
// Uncomment as you add metadata
|
|
||||||
|
|
||||||
module.exports.CATEGORY_METADATA = {
|
|
||||||
// [PAGES.ARTISTS]: {
|
|
||||||
// title: 'Artists',
|
|
||||||
// description: "", <------ FILL
|
|
||||||
// image: '', <------ FILL
|
|
||||||
// },
|
|
||||||
[PAGES.CREATIVE_ARTS]: {
|
|
||||||
title: 'The Arts',
|
|
||||||
description: `Odysee's home for art, animation, comedy, and everything inbetween`,
|
|
||||||
image: '',
|
|
||||||
},
|
|
||||||
[PAGES.EDUCATION]: {
|
|
||||||
title: 'Education',
|
|
||||||
description: `Who needs school when there's Odysee?`,
|
|
||||||
image: '',
|
|
||||||
},
|
|
||||||
[PAGES.FEATURED]: {
|
|
||||||
title: 'Featured',
|
|
||||||
description: 'Showcasing some of the best content Odysee has to offer',
|
|
||||||
image: '',
|
|
||||||
},
|
|
||||||
[PAGES.FINANCE]: {
|
|
||||||
title: 'Finance 2.0',
|
|
||||||
description: 'Crypto, Money, Economics, Markets on Odysee',
|
|
||||||
image: 'https://player.odycdn.com/speech/category-finance:c.jpg',
|
|
||||||
},
|
|
||||||
[PAGES.GAMING]: {
|
|
||||||
title: 'Gaming',
|
|
||||||
description: 'Pew pew bzzz gaming on Odysee',
|
|
||||||
image: 'https://player.odycdn.com/speech/category-gaming:5.jpg',
|
|
||||||
},
|
|
||||||
[PAGES.GENERAL]: {
|
|
||||||
title: 'Cheese',
|
|
||||||
description: 'Cheese is the answer to life, the universe, and everything. We have primo cheese on Odysee',
|
|
||||||
image: 'https://player.odycdn.com/speech/category-primary1:5.jpg',
|
|
||||||
},
|
|
||||||
[PAGES.LAB]: {
|
|
||||||
title: 'Lab',
|
|
||||||
description: 'Science - the real kind, on Odysee',
|
|
||||||
image: '',
|
|
||||||
},
|
|
||||||
[PAGES.NEWS]: {
|
|
||||||
title: 'News & Politics',
|
|
||||||
description: `Stay up to date with all that's happening around the world on Odysee`,
|
|
||||||
image: '',
|
|
||||||
},
|
|
||||||
[PAGES.MOVIES]: {
|
|
||||||
title: 'Movies',
|
|
||||||
description: `Do you love B rated movies? We've got you covered on Odysee`,
|
|
||||||
image: 'https://player.odycdn.com/speech/category-movies:2.jpg',
|
|
||||||
},
|
|
||||||
[PAGES.MUSIC]: {
|
|
||||||
title: 'Music',
|
|
||||||
description: 'Get your groove on with Odysee',
|
|
||||||
image: 'https://player.odycdn.com/speech/category-music:8.jpg',
|
|
||||||
},
|
|
||||||
[PAGES.POP_CULTURE]: {
|
|
||||||
title: 'Big Hits',
|
|
||||||
description: 'Animation, pop culture, comedy, and all the other weird on Odysee',
|
|
||||||
image: '',
|
|
||||||
},
|
|
||||||
[PAGES.TECH]: {
|
|
||||||
title: 'Tech',
|
|
||||||
description: 'Hardware, software, startups, photography on Odysee',
|
|
||||||
image: '',
|
|
||||||
},
|
|
||||||
[PAGES.UNIVERSE]: {
|
|
||||||
title: 'Universe',
|
|
||||||
description: 'Podcasts, life, learning, and everything else on Odysee',
|
|
||||||
image: '',
|
|
||||||
},
|
|
||||||
[PAGES.WILD_WEST]: {
|
|
||||||
title: 'Wild West',
|
|
||||||
description: 'Boosted by user credits, this is what the community promotes on Odysee',
|
|
||||||
image: 'https://player.odycdn.com/speech/category-wildwest:1.jpg',
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -11,7 +11,6 @@ const {
|
||||||
URL,
|
URL,
|
||||||
} = require('../../config.js');
|
} = require('../../config.js');
|
||||||
|
|
||||||
const { CATEGORY_METADATA } = require('./category-metadata');
|
|
||||||
const {
|
const {
|
||||||
generateDirectUrl,
|
generateDirectUrl,
|
||||||
generateEmbedUrl,
|
generateEmbedUrl,
|
||||||
|
@ -23,6 +22,7 @@ const {
|
||||||
} = require('../../ui/util/web');
|
} = require('../../ui/util/web');
|
||||||
const { getJsBundleId } = require('../bundle-id.js');
|
const { getJsBundleId } = require('../bundle-id.js');
|
||||||
const { lbryProxy: Lbry } = require('../lbry');
|
const { lbryProxy: Lbry } = require('../lbry');
|
||||||
|
const { getHomepageJSON } = require('./getHomepageJSON');
|
||||||
const { buildURI, parseURI, normalizeClaimUrl } = require('./lbryURI');
|
const { buildURI, parseURI, normalizeClaimUrl } = require('./lbryURI');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
@ -61,8 +61,26 @@ function truncateDescription(description, maxChars = 200) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCategoryMeta(path) {
|
function getCategoryMeta(path) {
|
||||||
const page = Object.keys(CATEGORY_METADATA).find((x) => path === `/$/${x}` || path === `/$/${x}/`);
|
const homepage = getHomepageJSON();
|
||||||
return CATEGORY_METADATA[page];
|
|
||||||
|
if (path === `/$/${PAGES.WILD_WEST}` || path === `/$/${PAGES.WILD_WEST}/`) {
|
||||||
|
return {
|
||||||
|
title: 'Wild West',
|
||||||
|
description: 'Boosted by user credits, this is what the community promotes on Odysee',
|
||||||
|
image: 'https://player.odycdn.com/speech/category-wildwest:1.jpg',
|
||||||
|
};
|
||||||
|
} else if (homepage && homepage.en) {
|
||||||
|
const data = Object.values(homepage.en).find((x) => path === `/$/${x.name}` || path === `/$/${x.name}/`);
|
||||||
|
if (data) {
|
||||||
|
return {
|
||||||
|
title: data.label,
|
||||||
|
description: data.description,
|
||||||
|
image: data.image,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -318,6 +336,16 @@ function buildSearchPageHead(html, requestPath, queryStr) {
|
||||||
return insertToHead(html, searchPageMetadata);
|
return insertToHead(html, searchPageMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildCategoryPageHead(html, requestPath, categoryMeta) {
|
||||||
|
const categoryPageMetadata = buildOgMetadata({
|
||||||
|
title: categoryMeta.title,
|
||||||
|
description: categoryMeta.description,
|
||||||
|
image: categoryMeta.image,
|
||||||
|
path: requestPath,
|
||||||
|
});
|
||||||
|
return insertToHead(html, categoryPageMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
async function resolveClaimOrRedirect(ctx, url, ignoreRedirect = false) {
|
async function resolveClaimOrRedirect(ctx, url, ignoreRedirect = false) {
|
||||||
let claim;
|
let claim;
|
||||||
try {
|
try {
|
||||||
|
@ -396,13 +424,7 @@ async function getHtml(ctx) {
|
||||||
|
|
||||||
const categoryMeta = getCategoryMeta(requestPath);
|
const categoryMeta = getCategoryMeta(requestPath);
|
||||||
if (categoryMeta) {
|
if (categoryMeta) {
|
||||||
const categoryPageMetadata = buildOgMetadata({
|
return buildCategoryPageHead(html, requestPath, categoryMeta);
|
||||||
title: categoryMeta.title,
|
|
||||||
description: categoryMeta.description,
|
|
||||||
image: categoryMeta.image,
|
|
||||||
path: requestPath,
|
|
||||||
});
|
|
||||||
return insertToHead(html, categoryPageMetadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestPath === `/$/${PAGES.SEARCH}` || requestPath === `/$/${PAGES.SEARCH}/`) {
|
if (requestPath === `/$/${PAGES.SEARCH}` || requestPath === `/$/${PAGES.SEARCH}/`) {
|
||||||
|
|
Loading…
Reference in a new issue