diff --git a/ui/constants/pages.js b/ui/constants/pages.js index 3a55e58a3..ea38aa973 100644 --- a/ui/constants/pages.js +++ b/ui/constants/pages.js @@ -7,6 +7,18 @@ exports.AUTH_WALLET_PASSWORD = 'walletpassword'; exports.BACKUP = 'backup'; exports.CHANNEL = 'channel'; exports.DISCOVER = 'discover'; +exports.BIG_HITS = 'big_hits'; +exports.COMMUNITY = 'community'; +exports.ENLIGHTENMENT = 'enlightenment'; +exports.FINANCE = 'finance'; +exports.GAMING = 'gaming'; +exports.GENERAL = 'general'; +exports.LAB = 'lab'; +exports.NEWS = 'news'; +exports.RABBIT_HOLE = 'rabbithole'; +exports.SCIENCE = 'science'; +exports.TECHNOLOGY = 'technology'; +exports.WILD_WEST = 'wildwest'; exports.HOME = 'home'; exports.HELP = 'help'; exports.LIBRARY = 'library'; diff --git a/web/src/category-metadata.js b/web/src/category-metadata.js new file mode 100644 index 000000000..600a660a0 --- /dev/null +++ b/web/src/category-metadata.js @@ -0,0 +1,64 @@ +const PAGES = require('../../ui/constants/pages'); + +module.exports.CATEGORY_METADATA = { + [PAGES.BIG_HITS]: { + title: '', + description: '', + image: '', + }, + [PAGES.COMMUNITY]: { + title: '', + description: '', + image: '', + }, + [PAGES.ENLIGHTENMENT]: { + title: '', + description: '', + image: '', + }, + [PAGES.FINANCE]: { + title: '', + description: '', + image: '', + }, + [PAGES.GAMING]: { + title: '', + description: '', + image: '', + }, + [PAGES.GENERAL]: { + title: '', + description: '', + image: '', + }, + [PAGES.LAB]: { + title: '', + description: '', + image: '', + }, + [PAGES.NEWS]: { + title: '', + description: '', + image: '', + }, + [PAGES.RABBIT_HOLE]: { + title: '', + description: '', + image: '', + }, + [PAGES.SCIENCE]: { + title: '', + description: '', + image: '', + }, + [PAGES.TECHNOLOGY]: { + title: '', + description: '', + image: '', + }, + [PAGES.WILD_WEST]: { + title: '', + description: '', + image: '', + }, +}; diff --git a/web/src/html.js b/web/src/html.js index 663f1fb00..5b9260c19 100644 --- a/web/src/html.js +++ b/web/src/html.js @@ -10,6 +10,7 @@ const { } = require('../../config.js'); const { generateEmbedUrl, generateStreamUrl } = require('../../ui/util/web'); const PAGES = require('../../ui/constants/pages'); +const { CATEGORY_METADATA } = require('./category-metadata'); const { getClaim } = require('./chainquery'); const { parseURI } = require('lbry-redux'); const fs = require('fs'); @@ -43,6 +44,11 @@ function escapeHtmlProperty(property) { : ''; } +function getCategoryMeta(path) { + const page = Object.keys(CATEGORY_METADATA).find((x) => path.endsWith(x) || path.endsWith(`${x}/`)); + return CATEGORY_METADATA[page]; +} + // // Normal metadata with option to override certain values // @@ -57,16 +63,17 @@ function buildOgMetadata(overrideOptions = {}) { `\n` + `\n` + '\n' + - `\n` + + `\n` + `\n` + `\n` + `\n` + '\n' + `` + - ``; + ``; return head; } @@ -229,6 +236,16 @@ async function getHtml(ctx) { return insertToHead(html); } + const categoryMeta = getCategoryMeta(requestPath); + if (categoryMeta) { + const categoryPageMetadata = buildOgMetadata({ + title: categoryMeta.title, + description: categoryMeta.description, + image: categoryMeta.image, + }); + return insertToHead(html, categoryPageMetadata); + } + if (!requestPath.includes('$')) { const claimUri = requestPath.slice(1).replace(/:/g, '#'); const claim = await getClaimFromChainqueryOrRedirect(ctx, claimUri);