Skip to content

Commit 1c92824

Browse files
committed
Implement dynamic OpenGraph image url support for crate pages
1 parent 1b6924a commit 1c92824

File tree

9 files changed

+337
-24
lines changed

9 files changed

+337
-24
lines changed

.env.sample

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,15 @@ export GH_CLIENT_SECRET=
8686
# Credentials for connecting to the Sentry error reporting service.
8787
# export SENTRY_DSN_API=
8888
export SENTRY_ENV_API=local
89+
90+
# If set the server serves the frontend `index.html` for all
91+
# non-API requests using the Jinja template at the given path.
92+
# Setting this parameter requires setting
93+
# INDEX_HTML_TEMPLATE_PATH as well.
94+
export INDEX_HTML_TEMPLATE_PATH=dist/index.html
95+
96+
# Base URL for the service from which the OpenGraph images
97+
# for crates are loaded. Required if
98+
# INDEX_HTML_TEMPLATE_PATH is set. Make sure the URL ends
99+
# with a `/`.
100+
export OG_IMAGE_BASE_URL="http://localhost:3000/og/"

Cargo.lock

Lines changed: 179 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ ipnetwork = "=0.21.1"
9292
json-subscriber = "=0.2.4"
9393
krata-tokio-tar = "=0.4.2"
9494
lettre = { version = "=0.11.11", default-features = false, features = ["file-transport", "smtp-transport", "hostname", "builder", "tokio1", "tokio1-native-tls"] }
95-
minijinja = "=2.6.0"
95+
minijinja = { version = "=2.6.0", features = ["loader"] }
9696
mockall = "=0.13.1"
97+
moka = { version = "=0.12.10", default-features = false, features = ["future"] }
9798
native-tls = "=0.2.13"
9899
oauth2 = "=5.0.0"
99100
object_store = { version = "=0.11.2", features = ["aws"] }

app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<meta name="google" content="notranslate" />
2525

26-
<meta property="og:image" content="https://crates.io/assets/og-image.png">
26+
<meta property="og:image" content="{{og_image_url}}">
2727
<meta name="twitter:card" content="summary_large_image">
2828
</head>
2929
<body>

0 commit comments

Comments
 (0)