From d7f9d7ef7f6b5e9540413e528842d095b2f8a196 Mon Sep 17 00:00:00 2001 From: Franco Montenegro Date: Wed, 27 Jan 2021 16:27:59 -0300 Subject: [PATCH] Remove markdown from og and description header tags --- package.json | 3 ++- web/src/html.js | 11 +++++++---- yarn.lock | 5 +++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9781528cd..7437dae0e 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/web/src/html.js b/web/src/html.js index fffe7a33a..663f1fb00 100644 --- a/web/src/html.js +++ b/web/src/html.js @@ -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 = `${SITE_TITLE}\n` + `\n` + `\n` + `\n` + - `\n` + + `\n` + `\n` + '\n' + `\n` + - `\n` + + `\n` + `\n` + `\n` + '\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 += ''; head += `${title}`; - head += ``; + head += ``; if (claim.tags) { head += ``; } head += ``; - head += ``; + head += ``; head += ``; head += ``; head += ``; diff --git a/yarn.lock b/yarn.lock index 5a01dd6fe..742019551 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"