Restore metadata back to simple objects
The fn version was only needed for Search Page, and that was making it hard to move the metadata to the homepage repo. Revert back to original, then handle Search separately.
This commit is contained in:
parent
e9214be2c1
commit
3f1417a412
2 changed files with 62 additions and 45 deletions
|
@ -3,90 +3,79 @@ const PAGES = require('../../ui/constants/pages');
|
||||||
// Uncomment as you add metadata
|
// Uncomment as you add metadata
|
||||||
|
|
||||||
module.exports.CATEGORY_METADATA = {
|
module.exports.CATEGORY_METADATA = {
|
||||||
// [PAGES.ARTISTS]: () => ({
|
// [PAGES.ARTISTS]: {
|
||||||
// title: 'Artists',
|
// title: 'Artists',
|
||||||
// description: "", <------ FILL
|
// description: "", <------ FILL
|
||||||
// image: '', <------ FILL
|
// image: '', <------ FILL
|
||||||
// }),
|
// },
|
||||||
[PAGES.CREATIVE_ARTS]: () => ({
|
[PAGES.CREATIVE_ARTS]: {
|
||||||
title: 'The Arts',
|
title: 'The Arts',
|
||||||
description: `Odysee's home for art, animation, comedy, and everything inbetween`,
|
description: `Odysee's home for art, animation, comedy, and everything inbetween`,
|
||||||
image: '',
|
image: '',
|
||||||
}),
|
},
|
||||||
[PAGES.EDUCATION]: () => ({
|
[PAGES.EDUCATION]: {
|
||||||
title: 'Education',
|
title: 'Education',
|
||||||
description: `Who needs school when there's Odysee?`,
|
description: `Who needs school when there's Odysee?`,
|
||||||
image: '',
|
image: '',
|
||||||
}),
|
},
|
||||||
[PAGES.FEATURED]: () => ({
|
[PAGES.FEATURED]: {
|
||||||
title: 'Featured',
|
title: 'Featured',
|
||||||
description: 'Showcasing some of the best content Odysee has to offer',
|
description: 'Showcasing some of the best content Odysee has to offer',
|
||||||
image: '',
|
image: '',
|
||||||
}),
|
},
|
||||||
[PAGES.FINANCE]: () => ({
|
[PAGES.FINANCE]: {
|
||||||
title: 'Finance 2.0',
|
title: 'Finance 2.0',
|
||||||
description: 'Crypto, Money, Economics, Markets on Odysee',
|
description: 'Crypto, Money, Economics, Markets on Odysee',
|
||||||
image: 'https://player.odycdn.com/speech/category-finance:c.jpg',
|
image: 'https://player.odycdn.com/speech/category-finance:c.jpg',
|
||||||
}),
|
},
|
||||||
[PAGES.GAMING]: () => ({
|
[PAGES.GAMING]: {
|
||||||
title: 'Gaming',
|
title: 'Gaming',
|
||||||
description: 'Pew pew bzzz gaming on Odysee',
|
description: 'Pew pew bzzz gaming on Odysee',
|
||||||
image: 'https://player.odycdn.com/speech/category-gaming:5.jpg',
|
image: 'https://player.odycdn.com/speech/category-gaming:5.jpg',
|
||||||
}),
|
},
|
||||||
[PAGES.GENERAL]: () => ({
|
[PAGES.GENERAL]: {
|
||||||
title: 'Cheese',
|
title: 'Cheese',
|
||||||
description: 'Cheese is the answer to life, the universe, and everything. We have primo cheese on Odysee',
|
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',
|
image: 'https://player.odycdn.com/speech/category-primary1:5.jpg',
|
||||||
}),
|
},
|
||||||
[PAGES.LAB]: () => ({
|
[PAGES.LAB]: {
|
||||||
title: 'Lab',
|
title: 'Lab',
|
||||||
description: 'Science - the real kind, on Odysee',
|
description: 'Science - the real kind, on Odysee',
|
||||||
image: '',
|
image: '',
|
||||||
}),
|
},
|
||||||
[PAGES.NEWS]: () => ({
|
[PAGES.NEWS]: {
|
||||||
title: 'News & Politics',
|
title: 'News & Politics',
|
||||||
description: `Stay up to date with all that's happening around the world on Odysee`,
|
description: `Stay up to date with all that's happening around the world on Odysee`,
|
||||||
image: '',
|
image: '',
|
||||||
}),
|
},
|
||||||
[PAGES.MOVIES]: () => ({
|
[PAGES.MOVIES]: {
|
||||||
title: 'Movies',
|
title: 'Movies',
|
||||||
description: `Do you love B rated movies? We've got you covered on Odysee`,
|
description: `Do you love B rated movies? We've got you covered on Odysee`,
|
||||||
image: 'https://player.odycdn.com/speech/category-movies:2.jpg',
|
image: 'https://player.odycdn.com/speech/category-movies:2.jpg',
|
||||||
}),
|
},
|
||||||
[PAGES.MUSIC]: () => ({
|
[PAGES.MUSIC]: {
|
||||||
title: 'Music',
|
title: 'Music',
|
||||||
description: 'Get your groove on with Odysee',
|
description: 'Get your groove on with Odysee',
|
||||||
image: 'https://player.odycdn.com/speech/category-music:8.jpg',
|
image: 'https://player.odycdn.com/speech/category-music:8.jpg',
|
||||||
}),
|
},
|
||||||
[PAGES.POP_CULTURE]: () => ({
|
[PAGES.POP_CULTURE]: {
|
||||||
title: 'Big Hits',
|
title: 'Big Hits',
|
||||||
description: 'Animation, pop culture, comedy, and all the other weird on Odysee',
|
description: 'Animation, pop culture, comedy, and all the other weird on Odysee',
|
||||||
image: '',
|
image: '',
|
||||||
}),
|
|
||||||
[PAGES.SEARCH]: ({ q = '' }) => {
|
|
||||||
if (!q) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
title: `"${q}" Search Results`,
|
|
||||||
description: `Find the best "${q}" content on Odysee`,
|
|
||||||
urlQueryString: `q=${q}`,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
[PAGES.TECH]: () => ({
|
[PAGES.TECH]: {
|
||||||
title: 'Tech',
|
title: 'Tech',
|
||||||
description: 'Hardware, software, startups, photography on Odysee',
|
description: 'Hardware, software, startups, photography on Odysee',
|
||||||
image: '',
|
image: '',
|
||||||
}),
|
},
|
||||||
[PAGES.UNIVERSE]: () => ({
|
[PAGES.UNIVERSE]: {
|
||||||
title: 'Universe',
|
title: 'Universe',
|
||||||
description: 'Podcasts, life, learning, and everything else on Odysee',
|
description: 'Podcasts, life, learning, and everything else on Odysee',
|
||||||
image: '',
|
image: '',
|
||||||
}),
|
},
|
||||||
[PAGES.WILD_WEST]: () => ({
|
[PAGES.WILD_WEST]: {
|
||||||
title: 'Wild West',
|
title: 'Wild West',
|
||||||
description: 'Boosted by user credits, this is what the community promotes on Odysee',
|
description: 'Boosted by user credits, this is what the community promotes on Odysee',
|
||||||
image: 'https://player.odycdn.com/speech/category-wildwest:1.jpg',
|
image: 'https://player.odycdn.com/speech/category-wildwest:1.jpg',
|
||||||
}),
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,6 +36,10 @@ Lbry.setDaemonConnectionString(PROXY_URL);
|
||||||
const BEGIN_STR = '<!-- VARIABLE_HEAD_BEGIN -->';
|
const BEGIN_STR = '<!-- VARIABLE_HEAD_BEGIN -->';
|
||||||
const FINAL_STR = '<!-- VARIABLE_HEAD_END -->';
|
const FINAL_STR = '<!-- VARIABLE_HEAD_END -->';
|
||||||
|
|
||||||
|
// ****************************************************************************
|
||||||
|
// Helpers
|
||||||
|
// ****************************************************************************
|
||||||
|
|
||||||
function insertToHead(fullHtml, htmlToInsert) {
|
function insertToHead(fullHtml, htmlToInsert) {
|
||||||
const beginIndex = fullHtml.indexOf(BEGIN_STR);
|
const beginIndex = fullHtml.indexOf(BEGIN_STR);
|
||||||
const finalIndex = fullHtml.indexOf(FINAL_STR);
|
const finalIndex = fullHtml.indexOf(FINAL_STR);
|
||||||
|
@ -56,7 +60,7 @@ function truncateDescription(description, maxChars = 200) {
|
||||||
return chars.length > maxChars ? truncated + '...' : truncated;
|
return chars.length > maxChars ? truncated + '...' : truncated;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCategoryMetaRenderFn(path) {
|
function getCategoryMeta(path) {
|
||||||
const page = Object.keys(CATEGORY_METADATA).find((x) => path === `/$/${x}` || path === `/$/${x}/`);
|
const page = Object.keys(CATEGORY_METADATA).find((x) => path === `/$/${x}` || path === `/$/${x}/`);
|
||||||
return CATEGORY_METADATA[page];
|
return CATEGORY_METADATA[page];
|
||||||
}
|
}
|
||||||
|
@ -299,6 +303,21 @@ function buildGoogleVideoMetadata(uri, claim) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildSearchPageHead(html, requestPath, queryStr) {
|
||||||
|
const searchPageMetadata = buildOgMetadata({
|
||||||
|
...(queryStr
|
||||||
|
? {
|
||||||
|
title: `"${queryStr}" Search Results`,
|
||||||
|
description: `Find the best "${queryStr}" content on Odysee`,
|
||||||
|
image: '', // TODO: get Search Page image
|
||||||
|
urlQueryString: `q=${queryStr}`,
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
path: requestPath,
|
||||||
|
});
|
||||||
|
return insertToHead(html, searchPageMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
async function resolveClaimOrRedirect(ctx, url, ignoreRedirect = false) {
|
async function resolveClaimOrRedirect(ctx, url, ignoreRedirect = false) {
|
||||||
let claim;
|
let claim;
|
||||||
try {
|
try {
|
||||||
|
@ -315,6 +334,10 @@ async function resolveClaimOrRedirect(ctx, url, ignoreRedirect = false) {
|
||||||
return claim;
|
return claim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ****************************************************************************
|
||||||
|
// getHtml
|
||||||
|
// ****************************************************************************
|
||||||
|
|
||||||
let html;
|
let html;
|
||||||
async function getHtml(ctx) {
|
async function getHtml(ctx) {
|
||||||
if (!html) {
|
if (!html) {
|
||||||
|
@ -371,16 +394,21 @@ async function getHtml(ctx) {
|
||||||
return insertToHead(html);
|
return insertToHead(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
const categoryMetaFn = getCategoryMetaRenderFn(requestPath);
|
const categoryMeta = getCategoryMeta(requestPath);
|
||||||
if (categoryMetaFn) {
|
if (categoryMeta) {
|
||||||
const categoryMeta = categoryMetaFn(query);
|
|
||||||
const categoryPageMetadata = buildOgMetadata({
|
const categoryPageMetadata = buildOgMetadata({
|
||||||
...categoryMeta,
|
title: categoryMeta.title,
|
||||||
|
description: categoryMeta.description,
|
||||||
|
image: categoryMeta.image,
|
||||||
path: requestPath,
|
path: requestPath,
|
||||||
});
|
});
|
||||||
return insertToHead(html, categoryPageMetadata);
|
return insertToHead(html, categoryPageMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requestPath === `/$/${PAGES.SEARCH}` || requestPath === `/$/${PAGES.SEARCH}/`) {
|
||||||
|
return buildSearchPageHead(html, requestPath, query.q);
|
||||||
|
}
|
||||||
|
|
||||||
if (!requestPath.includes('$')) {
|
if (!requestPath.includes('$')) {
|
||||||
const parsedUri = parseURI(normalizeClaimUrl(requestPath.slice(1)));
|
const parsedUri = parseURI(normalizeClaimUrl(requestPath.slice(1)));
|
||||||
const claimUri = buildURI({ ...parsedUri, startTime: undefined });
|
const claimUri = buildURI({ ...parsedUri, startTime: undefined });
|
||||||
|
|
Loading…
Reference in a new issue