fix: remove description from custom rich link previews (#7142)
* fix: remove description from custom rich link previews * add static assets to prepare for prep * remove added assets
This commit is contained in:
parent
6cd1f04584
commit
b98e62cac8
@ -7,6 +7,7 @@ export const onRequest: PagesFunction = async ({ request, next }) => {
|
|||||||
title: 'Uniswap Interface',
|
title: 'Uniswap Interface',
|
||||||
image: imageUri,
|
image: imageUri,
|
||||||
url: request.url,
|
url: request.url,
|
||||||
|
description: 'Swap or provide liquidity on the Uniswap Protocol',
|
||||||
}
|
}
|
||||||
const res = next()
|
const res = next()
|
||||||
try {
|
try {
|
||||||
|
@ -2,6 +2,7 @@ type MetaTagInjectorInput = {
|
|||||||
title: string
|
title: string
|
||||||
image?: string
|
image?: string
|
||||||
url: string
|
url: string
|
||||||
|
description?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,6 +19,9 @@ export class MetaTagInjector implements HTMLRewriterElementContentHandlers {
|
|||||||
element(element: Element) {
|
element(element: Element) {
|
||||||
//Open Graph Tags
|
//Open Graph Tags
|
||||||
this.append(element, 'og:title', this.input.title)
|
this.append(element, 'og:title', this.input.title)
|
||||||
|
if (this.input.description) {
|
||||||
|
this.append(element, 'og:description', this.input.description)
|
||||||
|
}
|
||||||
if (this.input.image) {
|
if (this.input.image) {
|
||||||
this.append(element, 'og:image', this.input.image)
|
this.append(element, 'og:image', this.input.image)
|
||||||
this.append(element, 'og:image:width', '1200')
|
this.append(element, 'og:image:width', '1200')
|
||||||
|
@ -3,6 +3,9 @@ const defaultUrls = ['http://127.0.0.1:3000/', 'http://127.0.0.1:3000/swap', 'ht
|
|||||||
test.each(defaultUrls)('should inject metadata for valid collections', async (defaultUrl) => {
|
test.each(defaultUrls)('should inject metadata for valid collections', async (defaultUrl) => {
|
||||||
const body = await fetch(new Request(defaultUrl)).then((res) => res.text())
|
const body = await fetch(new Request(defaultUrl)).then((res) => res.text())
|
||||||
expect(body).toContain(`<meta property="og:title" content="Uniswap Interface"/>`)
|
expect(body).toContain(`<meta property="og:title" content="Uniswap Interface"/>`)
|
||||||
|
expect(body).toContain(
|
||||||
|
`<meta property="og:description" content="Swap or provide liquidity on the Uniswap Protocol"/>`
|
||||||
|
)
|
||||||
expect(body).toContain(
|
expect(body).toContain(
|
||||||
`<meta property="og:image" content="http://127.0.0.1:3000/images/1200x630_Rich_Link_Preview_Image.png"/>`
|
`<meta property="og:image" content="http://127.0.0.1:3000/images/1200x630_Rich_Link_Preview_Image.png"/>`
|
||||||
)
|
)
|
||||||
|
@ -7,7 +7,6 @@ exports[`should inject metadata for valid assets 1`] = `
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
will be replaced with the URL of the \`public\` folder during build.
|
will be replaced with the URL of the \`public\` folder during build.
|
||||||
@ -139,7 +138,6 @@ exports[`should inject metadata for valid assets 2`] = `
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
will be replaced with the URL of the \`public\` folder during build.
|
will be replaced with the URL of the \`public\` folder during build.
|
||||||
@ -271,7 +269,6 @@ exports[`should inject metadata for valid assets 3`] = `
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
will be replaced with the URL of the \`public\` folder during build.
|
will be replaced with the URL of the \`public\` folder during build.
|
||||||
|
@ -24,6 +24,7 @@ test.each(assets)('should inject metadata for valid assets', async (nft) => {
|
|||||||
const body = await fetch(new Request(url)).then((res) => res.text())
|
const body = await fetch(new Request(url)).then((res) => res.text())
|
||||||
expect(body).toMatchSnapshot()
|
expect(body).toMatchSnapshot()
|
||||||
expect(body).toContain(`<meta property="og:title" content="${nft.collectionName} #${nft.assetId}"/>`)
|
expect(body).toContain(`<meta property="og:title" content="${nft.collectionName} #${nft.assetId}"/>`)
|
||||||
|
expect(body).not.toContain(`<meta property="og:description"`)
|
||||||
expect(body).toContain(`<meta property="og:image" content="${nft.image}"/>`)
|
expect(body).toContain(`<meta property="og:image" content="${nft.image}"/>`)
|
||||||
expect(body).toContain(`<meta property="og:image:width" content="1200"/>`)
|
expect(body).toContain(`<meta property="og:image:width" content="1200"/>`)
|
||||||
expect(body).toContain(`<meta property="og:image:height" content="630"/>`)
|
expect(body).toContain(`<meta property="og:image:height" content="630"/>`)
|
||||||
|
@ -7,7 +7,6 @@ exports[`should inject metadata for valid collections 1`] = `
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
will be replaced with the URL of the \`public\` folder during build.
|
will be replaced with the URL of the \`public\` folder during build.
|
||||||
@ -139,7 +138,6 @@ exports[`should inject metadata for valid collections 2`] = `
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
will be replaced with the URL of the \`public\` folder during build.
|
will be replaced with the URL of the \`public\` folder during build.
|
||||||
@ -271,7 +269,6 @@ exports[`should inject metadata for valid collections 3`] = `
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
will be replaced with the URL of the \`public\` folder during build.
|
will be replaced with the URL of the \`public\` folder during build.
|
||||||
|
@ -21,6 +21,7 @@ test.each(collections)('should inject metadata for valid collections', async (co
|
|||||||
const body = await fetch(new Request(url)).then((res) => res.text())
|
const body = await fetch(new Request(url)).then((res) => res.text())
|
||||||
expect(body).toMatchSnapshot()
|
expect(body).toMatchSnapshot()
|
||||||
expect(body).toContain(`<meta property="og:title" content="${collection.collectionName} on Uniswap"/>`)
|
expect(body).toContain(`<meta property="og:title" content="${collection.collectionName} on Uniswap"/>`)
|
||||||
|
expect(body).not.toContain(`<meta property="og:description"`)
|
||||||
expect(body).toContain(`<meta property="og:image" content="${collection.image}"/>`)
|
expect(body).toContain(`<meta property="og:image" content="${collection.image}"/>`)
|
||||||
expect(body).toContain(`<meta property="og:image:width" content="1200"/>`)
|
expect(body).toContain(`<meta property="og:image:width" content="1200"/>`)
|
||||||
expect(body).toContain(`<meta property="og:image:height" content="630"/>`)
|
expect(body).toContain(`<meta property="og:image:height" content="630"/>`)
|
||||||
|
@ -7,7 +7,6 @@ exports[`should inject metadata for valid tokens 1`] = `
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
will be replaced with the URL of the \`public\` folder during build.
|
will be replaced with the URL of the \`public\` folder during build.
|
||||||
@ -139,7 +138,6 @@ exports[`should inject metadata for valid tokens 2`] = `
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
will be replaced with the URL of the \`public\` folder during build.
|
will be replaced with the URL of the \`public\` folder during build.
|
||||||
@ -271,7 +269,6 @@ exports[`should inject metadata for valid tokens 3`] = `
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
will be replaced with the URL of the \`public\` folder during build.
|
will be replaced with the URL of the \`public\` folder during build.
|
||||||
@ -403,7 +400,6 @@ exports[`should inject metadata for valid tokens 4`] = `
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
will be replaced with the URL of the \`public\` folder during build.
|
will be replaced with the URL of the \`public\` folder during build.
|
||||||
|
@ -30,6 +30,7 @@ test.each(tokens)('should inject metadata for valid tokens', async (token) => {
|
|||||||
const body = await fetch(new Request(url)).then((res) => res.text())
|
const body = await fetch(new Request(url)).then((res) => res.text())
|
||||||
expect(body).toMatchSnapshot()
|
expect(body).toMatchSnapshot()
|
||||||
expect(body).toContain(`<meta property="og:title" content="Get ${token.symbol} on Uniswap"/>`)
|
expect(body).toContain(`<meta property="og:title" content="Get ${token.symbol} on Uniswap"/>`)
|
||||||
|
expect(body).not.toContain(`<meta property="og:description"`)
|
||||||
expect(body).toContain(`<meta property="og:image" content="${token.image}"/>`)
|
expect(body).toContain(`<meta property="og:image" content="${token.image}"/>`)
|
||||||
expect(body).toContain(`<meta property="og:image:width" content="1200"/>`)
|
expect(body).toContain(`<meta property="og:image:width" content="1200"/>`)
|
||||||
expect(body).toContain(`<meta property="og:image:height" content="630"/>`)
|
expect(body).toContain(`<meta property="og:image:height" content="630"/>`)
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>Uniswap Interface</title>
|
<title>Uniswap Interface</title>
|
||||||
<meta name="description" content="Swap or provide liquidity on the Uniswap Protocol" />
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
%PUBLIC_URL% will be replaced with the URL of the `public` folder during build.
|
%PUBLIC_URL% will be replaced with the URL of the `public` folder during build.
|
||||||
|
Loading…
Reference in New Issue
Block a user