Skip to content

Commit

Permalink
feat(workers): auto-generated social thumbnails
Browse files Browse the repository at this point in the history
set the value of og:image per page
  • Loading branch information
urish committed Apr 3, 2022
1 parent b5ca97a commit 547eb7f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion workers/auto-locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,18 @@ async function handleRequest(request) {
}
}

return fetch(request);
/* Per-page social thumbnails (og:image) */
const response = await fetch(request);
if (response.headers.get('Content-type').startsWith('text/html')) {
const text = await response.text();
return new Response(
text.replaceAll(
'https://docs.wokwi.com/img/wokwi-book.jpg',
`https://thumbs.wokwi.com/docs${pathname}/thumbnail.png`,
),
response,
);
}

return response;
}

1 comment on commit 547eb7f

@vercel
Copy link

@vercel vercel bot commented on 547eb7f Apr 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.