Skip to content

Commit

Permalink
Add twitter card metadata (#459)
Browse files Browse the repository at this point in the history
* added og:type tag

* added Twitter meta tags for Twitter Summary Card with Image

* updated twitter card type to summary_large_image

* added twitter meta tags to shared chat
  • Loading branch information
rjwignar committed Feb 16, 2024
1 parent 2208ad2 commit ca5ef70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
<meta name="og:site_name" content="chatcraft.org" />
<meta property="og:image" content="https://chatcraft.org/favicon-32x32.png" />
<meta property="og:url" content="https://chatcraft.org" />
<meta property="og:type" content="website" />
<meta property="og:title" content="chatcraft.org" />
<meta property="og:description" content="Web-based AI Assistant for Software Developers" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="chatcraft.org" />
<meta name="twitter:description" content="Web-based AI Assistant for Software Developers" />
<meta name="twitter:image" content="https://chatcraft.org/favicon-32x32.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
Expand Down
11 changes: 11 additions & 0 deletions src/lib/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,18 @@ function generateSharingHTML(chat: ChatCraftChat, user: User) {
// Set various types of titles/summaries
setMetaContent(clonedDocument, "property", "og:title", chat.summary);
setMetaContent(clonedDocument, "property", "og:url", createShareUrl(chat, user));
setMetaContent(clonedDocument, "property", "og:type", "website");
setMetaContent(clonedDocument, "name", "description", chat.summary);
setMetaContent(clonedDocument, "name", "twitter:card", "summary_large_image");
setMetaContent(clonedDocument, "name", "twitter:title", "chatcraft.org");
setMetaContent(clonedDocument, "name", "twitter:description", chat.summary);
setMetaContent(
clonedDocument,
"name",
"twitter:image",
"https://chatcraft.org/favicon-32x32.png"
);

setDocumentTitle(clonedDocument, chat.summary);
// Set OG bulk text to be that of last message
if (lastMessageText) {
Expand Down

0 comments on commit ca5ef70

Please sign in to comment.