Skip to content

Commit

Permalink
Add (custom) og img for sponsors page
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Jun 18, 2024
1 parent 3a41f8e commit d89ec12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/docs/src/components/Head.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Props } from '@astrojs/starlight/props';
const slug = Astro.props.slug;
const url = new URL(Astro.url);
url.pathname = `/og/docs${slug ? `/${slug}` : ''}.webp`;
url.searchParams.append('v', '2');
url.searchParams.append('v', '3');
---

<Default {...Astro.props} />
Expand Down
9 changes: 7 additions & 2 deletions packages/docs/src/pages/og/[...route].ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ const getPages = async () => {
const imagePath = filePath.replace(/^\/src\/content\//, '').replace(/(\/index)?\.(md|mdx)$/, '.webp');
pages[imagePath] = page;
}

pages['docs/sponsors.webp'] = {
frontmatter: { title: 'Become a sponsor!', description: 'Become a sponsor of Knip' },
};

return pages;
};

const S = ({ title }: { title: string; description: string[] }) => {
const renderSVG = ({ title }: { title: string; description: string[] }) => {
const titleText = breakText(title, 2, 45)
.map((text, i, texts) => {
const m = (texts.length === 1 ? 0 : -75) / 2;
Expand All @@ -64,7 +69,7 @@ export const GET = async ({ params }: { params: { route: string } }) => {
if (!pageEntry) return new Response('Page not found', { status: 404 });

const svgBuffer = Buffer.from(
S({
renderSVG({
// @ts-expect-error TODO type properly
title: pageEntry.frontmatter.hero?.tagline ?? pageEntry.frontmatter.title,
// @ts-expect-error TODO type properly
Expand Down

0 comments on commit d89ec12

Please sign in to comment.