Skip to content

fix open graph images #992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/static/og/try.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/Try.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ let default = props => {
let playground = React.createElement(lazyPlayground, {versions: props.versions})

<>
<Meta title="ReScript Playground" description="Try ReScript in the browser" />
<Meta
title="ReScript Playground"
description="Try ReScript in the browser"
ogImage="/static/og/try.png"
/>
<Next.Head>
<style> {React.string(`body { background-color: #010427; }`)} </style>
</Next.Head>
Expand Down
14 changes: 6 additions & 8 deletions src/components/Meta.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ let make = (
~ogSiteName=?,
~ogDescription=description,
~ogTitle=?,
~ogImage=?,
~ogImage="/static/Art-3-rescript-launch.jpg",
~version: option<Url.version>=?,
) => {
let ogImage = "https://rescript-lang.org" ++ ogImage

let title = switch title {
| None
| Some("") => siteName
Expand Down Expand Up @@ -55,19 +57,15 @@ let make = (
<meta key="og:locale" property="og:locale" content=ogLocale />
<meta key="og:title" property="og:title" content=ogTitle />
<meta key="og:description" property="og:description" content=ogDescription />
{switch ogImage {
| Some(ogImage) => <meta key="og:image" property="og:image" content=ogImage />
| None => React.null
}}
<meta key="og:image" property="og:image" content=ogImage />

/* Twitter Meta */
<meta key="twitter:title" name="twitter:title" content=title />
<meta key="twitter:description" name="twitter:description" content=description />
<meta key="twitter:site" name="twitter:site" content="@reasonml" />
<meta key="twitter:image" property="og:image" content=ogImage />
<meta key="twitter:creator" name="twitter:creator" content="@ReasonAssoc" />
<meta property="og:image:type" content="image/jpeg" />
<meta key="twitter:card" name="twitter:card" content="summary_large_image" />
/* TODO: Undo this later */
/* <meta key="twitter:image" property="twitter:image" content=ogImage /> */
<link rel="alternate" type_="application/rss+xml" title="ReScript Blog" href="/blog/feed.xml" />
// Docsearch meta tags
<meta
Expand Down