feat: add shareable meme permalinks
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { feedJson, renderIndex, sitemapXml } from '../src/seo.js';
|
||||
|
||||
const id = 'a'.repeat(64);
|
||||
const meme = {
|
||||
id,
|
||||
createdAt: '2026-07-24T12:00:00.000Z',
|
||||
width: 1200,
|
||||
height: 900,
|
||||
moderationScore: 92
|
||||
};
|
||||
const template = [
|
||||
'<title>__SEO_TITLE__</title>',
|
||||
'<meta name="description" content="__SEO_DESCRIPTION__">',
|
||||
'<link rel="canonical" href="__SEO_CANONICAL__">',
|
||||
'<meta property="og:image" content="__SEO_IMAGE__">',
|
||||
'<script nonce="__CSP_NONCE__">__SEO_JSON_LD__</script>'
|
||||
].join('');
|
||||
|
||||
test('renders a meme permalink with meme-specific share metadata', () => {
|
||||
const html = renderIndex({
|
||||
template,
|
||||
baseUrl: 'https://memes.example',
|
||||
nonce: 'test-nonce',
|
||||
approvedCount: 1,
|
||||
meme
|
||||
});
|
||||
|
||||
assert.match(html, /<title>Meme 0xAAAA\.\.\.AAAA \| The Meme Protocol<\/title>/);
|
||||
assert.match(html, new RegExp(`canonical" href="https://memes\\.example/meme/${id}"`));
|
||||
assert.match(html, new RegExp(`og:image" content="https://memes\\.example/media/${id}"`));
|
||||
assert.match(html, /"@type":"ImageObject"/);
|
||||
assert.match(html, /nonce="test-nonce"/);
|
||||
});
|
||||
|
||||
test('discovery feeds point readers to viewer permalinks', () => {
|
||||
const feed = feedJson('https://memes.example', [meme]);
|
||||
const sitemap = sitemapXml('https://memes.example', [meme]);
|
||||
|
||||
assert.equal(feed.items[0].url, `https://memes.example/meme/${id}`);
|
||||
assert.equal(feed.items[0].image, `https://memes.example/media/${id}`);
|
||||
assert.match(sitemap, new RegExp(`https://memes\\.example/meme/${id}`));
|
||||
});
|
||||
Reference in New Issue
Block a user