mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Compare commits
2 commits
24ab3a2be0
...
358b2e8a53
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
358b2e8a53 | ||
|
|
4594f2dbeb |
4 changed files with 45 additions and 16 deletions
|
|
@ -1,4 +1,4 @@
|
|||
image: denoland/deno:2.2.2
|
||||
image: denoland/deno:2.3.1
|
||||
|
||||
default:
|
||||
interruptible: true
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
deno 2.2.2
|
||||
deno 2.3.1
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ export function contentToHtml(content: string, mentions: MastodonMention[], opts
|
|||
hashtag: ({ content }) => {
|
||||
const tag = content.replace(/^#/, '');
|
||||
const href = conf.local(`/tags/${tag}`);
|
||||
return html`<a class="mention hashtag" href="${href}" rel="tag"><span>#</span>${tag}</a>`;
|
||||
return html`
|
||||
<a class="mention hashtag" href="${href}" rel="tag"><span>#</span>${tag}</a>
|
||||
`;
|
||||
},
|
||||
url: ({ attributes, content }) => {
|
||||
try {
|
||||
|
|
@ -47,7 +49,10 @@ export function contentToHtml(content: string, mentions: MastodonMention[], opts
|
|||
const acct = mention?.acct ?? npub;
|
||||
const name = mention?.acct ?? npub.substring(0, 8);
|
||||
const href = mention?.url ?? conf.local(`/@${acct}`);
|
||||
return html`<span class="h-card"><a class="u-url mention" href="${href}" rel="ugc">@<span>${name}</span></a></span>${extra}`;
|
||||
return html`
|
||||
<span class="h-card"><a class="u-url mention" href="${href}" rel="ugc">@<span
|
||||
>${name}</span></a></span>${extra}
|
||||
`;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,34 +21,58 @@ export function renderMetadata(url: string, { account, status, instance }: Metad
|
|||
const height = attachment?.meta?.original?.height;
|
||||
|
||||
if (title) {
|
||||
tags.push(html`<title>${title}</title>`);
|
||||
tags.push(html`<meta property="og:title" content="${title}">`);
|
||||
tags.push(html`<meta name="twitter:title" content="${title}">`);
|
||||
tags.push(html`
|
||||
<title>${title}</title>
|
||||
`);
|
||||
tags.push(html`
|
||||
<meta property="og:title" content="${title}">
|
||||
`);
|
||||
tags.push(html`
|
||||
<meta name="twitter:title" content="${title}">
|
||||
`);
|
||||
}
|
||||
|
||||
if (description) {
|
||||
tags.push(html`<meta name="description" content="${description}">`);
|
||||
tags.push(html`<meta property="og:description" content="${description}">`);
|
||||
tags.push(html`<meta name="twitter:description" content="${description}">`);
|
||||
tags.push(html`
|
||||
<meta name="description" content="${description}">
|
||||
`);
|
||||
tags.push(html`
|
||||
<meta property="og:description" content="${description}">
|
||||
`);
|
||||
tags.push(html`
|
||||
<meta name="twitter:description" content="${description}">
|
||||
`);
|
||||
}
|
||||
|
||||
if (image) {
|
||||
tags.push(html`<meta property="og:image" content="${image}">`);
|
||||
tags.push(html`<meta name="twitter:image" content="${image}">`);
|
||||
tags.push(html`
|
||||
<meta property="og:image" content="${image}">
|
||||
`);
|
||||
tags.push(html`
|
||||
<meta name="twitter:image" content="${image}">
|
||||
`);
|
||||
}
|
||||
|
||||
if (typeof width === 'number' && typeof height === 'number') {
|
||||
tags.push(html`<meta property="og:image:width" content="${width}">`);
|
||||
tags.push(html`<meta property="og:image:height" content="${height}">`);
|
||||
tags.push(html`
|
||||
<meta property="og:image:width" content="${width}">
|
||||
`);
|
||||
tags.push(html`
|
||||
<meta property="og:image:height" content="${height}">
|
||||
`);
|
||||
}
|
||||
|
||||
if (siteName) {
|
||||
tags.push(html`<meta property="og:site_name" content="${siteName}">`);
|
||||
tags.push(html`
|
||||
<meta property="og:site_name" content="${siteName}">
|
||||
`);
|
||||
}
|
||||
|
||||
// Extra tags (always present if other tags exist).
|
||||
if (tags.length > 0) {
|
||||
tags.push(html`<meta property="og:url" content="${url}">`);
|
||||
tags.push(html`
|
||||
<meta property="og:url" content="${url}">
|
||||
`);
|
||||
tags.push('<meta property="og:type" content="website">');
|
||||
tags.push('<meta name="twitter:card" content="summary">');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue