Remove markdown from og and description header tags

This commit is contained in:
Franco Montenegro 2021-01-27 16:27:59 -03:00 committed by Sean Yesmunt
parent 9bd9b5c121
commit d7f9d7ef7f
3 changed files with 14 additions and 5 deletions

View file

@ -53,7 +53,8 @@
"electron-updater": "^4.2.4",
"express": "^4.17.1",
"if-env": "^1.0.4",
"remark-breaks": "^2.0.1",
"remark-breaks": "^2.0.1",
"remove-markdown": "^0.3.0",
"tempy": "^0.6.0",
"videojs-logo": "^2.1.4"
},

View file

@ -14,6 +14,7 @@ const { getClaim } = require('./chainquery');
const { parseURI } = require('lbry-redux');
const fs = require('fs');
const path = require('path');
const removeMd = require('remove-markdown');
const { getJsBundleId } = require('../bundle-id.js');
const jsBundleId = getJsBundleId();
@ -47,18 +48,19 @@ function escapeHtmlProperty(property) {
//
function buildOgMetadata(overrideOptions = {}) {
const { title, description } = overrideOptions;
const cleanDescription = removeMd(description || SITE_DESCRIPTION);
const head =
`<title>${SITE_TITLE}</title>\n` +
`<meta property="og:url" content="${URL}" />\n` +
`<meta property="og:title" content="${title || OG_HOMEPAGE_TITLE || SITE_TITLE}" />\n` +
`<meta property="og:site_name" content="${SITE_NAME || SITE_TITLE}"/>\n` +
`<meta property="og:description" content="${description || SITE_DESCRIPTION}" />\n` +
`<meta property="og:description" content="${cleanDescription}" />\n` +
`<meta property="og:image" content="${OG_IMAGE_URL || `${URL}/public/v2-og.png`}" />\n` +
'<meta name="twitter:card" content="summary_large_image"/>\n' +
`<meta name="twitter:title" content="${(title && title + OG_TITLE_SUFFIX) ||
OG_HOMEPAGE_TITLE ||
SITE_TITLE}" />\n` +
`<meta name="twitter:description" content="${description || SITE_DESCRIPTION}" />\n` +
`<meta name="twitter:description" content="${cleanDescription}" />\n` +
`<meta name="twitter:image" content="${OG_IMAGE_URL || `${URL}/public/v2-og.png`}"/>\n` +
`<meta name="twitter:url" content="${URL}" />\n` +
'<meta property="fb:app_id" content="1673146449633983" />\n' +
@ -97,18 +99,19 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}) {
// Allow for ovverriding default claim based og metadata
const title = overrideOptions.title || claimTitle;
const description = overrideOptions.description || claimDescription;
const cleanDescription = removeMd(description);
let head = '';
head += '<meta charset="utf8"/>';
head += `<title>${title}</title>`;
head += `<meta name="description" content="${description}"/>`;
head += `<meta name="description" content="${cleanDescription}"/>`;
if (claim.tags) {
head += `<meta name="keywords" content="${claim.tags.toString()}"/>`;
}
head += `<meta name="twitter:image" content="${claimThumbnail}"/>`;
head += `<meta property="og:description" content="${description}"/>`;
head += `<meta property="og:description" content="${cleanDescription}"/>`;
head += `<meta property="og:image" content="${claimThumbnail}"/>`;
head += `<meta property="og:locale" content="${claimLanguage}"/>`;
head += `<meta property="og:site_name" content="${SITE_NAME}"/>`;

View file

@ -9673,6 +9673,11 @@ remark@^9.0.0:
remark-stringify "^5.0.0"
unified "^6.0.0"
remove-markdown@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/remove-markdown/-/remove-markdown-0.3.0.tgz#5e4b667493a93579728f3d52ecc1db9ca505dc98"
integrity sha1-XktmdJOpNXlyjz1S7MHbnKUF3Jg=
remove-trailing-separator@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"