diff --git a/.lintstagedrc.json b/.lintstagedrc.json index b3430d6a4..6bafc1f42 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,7 +1,9 @@ { "linters": { "ui/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"], - "lbrytv/component/*.{js,jsx,scss,json}": ["prettier --write", "git add"], - "ui/**/*.{js,jsx}": ["eslint", "flow focus-check --color always", "git add"] - } + "lbrytv/**/*.{js,jsx,scss,json}": ["prettier --write", "git add"], + "ui/**/*.{js,jsx}": ["eslint", "flow focus-check --color always", "git add"], + "lbrytv/**/*.{js,jsx,scss,json}": ["eslint", "git add"] + }, + "ignore": ["node_modules", "dist", "package-lock.json"] } diff --git a/lbrytv/src/html.js b/lbrytv/src/html.js index adbfb927c..c3ed63345 100644 --- a/lbrytv/src/html.js +++ b/lbrytv/src/html.js @@ -32,7 +32,7 @@ function escapeHtmlProperty(property) { // // Normal metadata with option to override certain values -// +// function buildOgMetadata(overrideOptions = {}) { const { title, description } = overrideOptions; const head = @@ -53,10 +53,10 @@ function buildOgMetadata(overrideOptions = {}) { // // Metadata used for urls that need claim information // Also has option to override defaults -// +// function buildClaimOgMetadata(uri, claim, overrideOptions = {}) { // Initial setup for claim based og metadata - const { isChannel, claimName } = parseURI(uri); + const { claimName } = parseURI(uri); const claimTitle = escapeHtmlProperty(claim.title ? claim.title : claimName); const claimDescription = claim.description && claim.description.length > 0 @@ -64,12 +64,11 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}) { : `Watch ${claimTitle} on LBRY.tv`; const claimLanguage = escapeHtmlProperty(claim.language) || 'en_US'; const claimThumbnail = escapeHtmlProperty(claim.thumbnail_url) || `${URL}/og.png`; - const defaultClaimTitle = - claim.channel && !isChannel ? `${claimTitle} from ${claim.channel} on LBRY.tv` : `${claimTitle} on LBRY.tv`; // Allow for ovverriding default claim based og metadata const title = overrideOptions.title || claimTitle; const description = overrideOptions.description || claimDescription; + const embedPlayer = overrideOptions.embedPlayer; let head = ''; @@ -95,9 +94,12 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}) { head += ``; head += ``; head += ``; + head += ``; if (claim.frame_width && claim.frame_height) { head += ``; head += ``; + head += ``; + head += ``; } } @@ -126,6 +128,8 @@ module.exports.getHtml = async function getHtml(ctx) { } const invitePath = `/$/${PAGES.INVITE}/`; + const embedPath = `/$/${PAGES.EMBED}/`; + const embedPlayer = URL + path; if (path.includes(invitePath)) { const inviteChannel = path.slice(invitePath.length).replace(/:/g, '#'); @@ -151,6 +155,18 @@ module.exports.getHtml = async function getHtml(ctx) { } } + if (path.includes(embedPath)) { + const claimUri = path.replace(embedPath, '').replace(/:/g, '#'); + const claim = await getClaimFromChainquery(claimUri); + + if (claim) { + const ogMetadata = buildClaimOgMetadata(claimUri, claim, { embedPlayer: embedPlayer}); + return insertToHead(html, ogMetadata); + } + + return insertToHead(html); + } + if (!path.includes('$')) { const claimUri = path.slice(1).replace(/:/g, '#'); const claim = await getClaimFromChainquery(claimUri);