-
Notifications
You must be signed in to change notification settings - Fork 10k
Update: Tutorials Generate Dynamic OG Images Using Workers - Replaced Bun with Npm #19854
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
Conversation
| return { data, name: font, style, weight }; | ||
| } | ||
|
|
||
| // ... other font loading strategies available in the full source code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any code required to create a fully functional app should be visible in the tutorial. If there are code blocks that are optional to finish the app you can include them in the tutorial under a dropdown, but otherwise should be displayed in a code block up front.
|
Hey @mohdlatif, is the tutorial ready for review? I see there is a comment still pending. Can you please address that, so that we can move to the review and it updated? Thank you! |
This should be done today. Thank you for reminding me. |
Including missing source code `Any code required to create a fully functional app should be visible in the tutorial`
|
Hi @harshil1712 @db-cloudflare @kodster28, |
lauragift21
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mohdlatif, I’ve gone through the tutorial and left some feedback. Let me know if you need any clarifications
| <PackageManagers | ||
| type="create" | ||
| pkg="cloudflare@latest" | ||
| args="og-image-generator --template cloudflare-workers --pm npm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that the command currently used here results in an error. If you intend to create a Hono app, you can use the --framework flag. The correct command should be:
npm create cloudflare@latest -- og-image-generator --framework=hono --experimental
| <PackageManagers | ||
| type="create" | ||
| pkg="cloudflare@latest" | ||
| args="og-image-generator --template cloudflare-workers --pm npm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| args="og-image-generator --template cloudflare-workers --pm npm" | |
| args="og-image-generator --framework=hono --experimental" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
|
|
||
| Generate OG images by making `GET` requests: | ||
|
|
||
| ```txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example request does not include footerText, but it's required in the API. Either make footerText optional in the implementation or update the example to include it.
|  | ||
|
|
||
| ```txt | ||
| /og?style=3&mainText=Company%20Update&description=Q4%20Results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example request does not include footerText, but it's required in the API. Either make footerText optional in the implementation or update the example to include it.
Oxyjun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PCX review
|
|
||
| import { PackageManagers, Render, Tabs, TabItem, WranglerConfig } from "~/components"; | ||
|
|
||
| Social media thrives on compelling visuals. With Cloudflare Workers, you can effortlessly generate dynamic Open Graph (OG) images that grab attention and boost platform performance. In this tutorial, you'll learn how to create a customizable OG image generator powered by serverless edge computing. Cloudflare Workers enable you to deliver blazing-fast visuals globally, ensuring a seamless experience for your users. Let's dive in to see how you can take your OG images to the next level with Cloudflare Workers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Social media thrives on compelling visuals. With Cloudflare Workers, you can effortlessly generate dynamic Open Graph (OG) images that grab attention and boost platform performance. In this tutorial, you'll learn how to create a customizable OG image generator powered by serverless edge computing. Cloudflare Workers enable you to deliver blazing-fast visuals globally, ensuring a seamless experience for your users. Let's dive in to see how you can take your OG images to the next level with Cloudflare Workers. | |
| Social media thrives on compelling visuals. With Cloudflare Workers, you can effortlessly generate dynamic Open Graph (OG) images that grab attention and boost platform performance. In this tutorial, you will learn how to create a customizable OG image generator powered by serverless edge computing. Cloudflare Workers enable you to deliver blazing-fast visuals globally, ensuring a seamless experience for your users. Dive in to see how you can take your OG images to the next level with Cloudflare Workers. |
Avoiding contractions
| - Global Reach: Deliver your images with ultra-low latency, no matter where your users are located. | ||
| - Serverless Simplicity: Focus on building features, not managing infrastructure. | ||
| - Unparalleled Performance: Process and serve requests at the edge for blazing-fast load times. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - Global Reach: Deliver your images with ultra-low latency, no matter where your users are located. | |
| - Serverless Simplicity: Focus on building features, not managing infrastructure. | |
| - Unparalleled Performance: Process and serve requests at the edge for blazing-fast load times. | |
| - **Global reach**: Deliver your images with ultra-low latency, no matter where your users are located. | |
| - **Serverless simplicity**: Focus on building features, not managing infrastructure. | |
| - **Unparalleled performance**: Process and serve requests at the edge for blazing-fast load times. |
| - Serverless Simplicity: Focus on building features, not managing infrastructure. | ||
| - Unparalleled Performance: Process and serve requests at the edge for blazing-fast load times. | ||
|
|
||
| By leveraging Cloudflare Workers, you get a serverless edge-computing environment that is not only cost-efficient but also perfectly optimized for modern web applications. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| By leveraging Cloudflare Workers, you get a serverless edge-computing environment that is not only cost-efficient but also perfectly optimized for modern web applications. | |
| By leveraging Cloudflare Workers, you get a serverless edge-computing environment that is not only cost-efficient, but also perfectly optimized for modern web applications. |
| 1. Request Received: A URL with parameters is sent to a Cloudflare Worker. | ||
| 2. Content Processed: The Worker extracts text, style, and font configurations from the URL. | ||
| 3. Font Loaded: Fonts are retrieved using one of four methods, like Google Fonts or local files. | ||
| 4. Image Generated: The image is built using React components styled with Tailwind CSS. | ||
| 5. Response Cached: The final image is returned and cached for future requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 1. Request Received: A URL with parameters is sent to a Cloudflare Worker. | |
| 2. Content Processed: The Worker extracts text, style, and font configurations from the URL. | |
| 3. Font Loaded: Fonts are retrieved using one of four methods, like Google Fonts or local files. | |
| 4. Image Generated: The image is built using React components styled with Tailwind CSS. | |
| 5. Response Cached: The final image is returned and cached for future requests. | |
| 1. Receives request: A Cloudflare Worker receives a URL with parameters. | |
| 2. Processes content: The Worker extracts text, style, and font configurations from the URL. | |
| 3. Loads font: The Worker retrieves fonts using one of four methods, like Google Fonts or local files. | |
| 4. Generates image: The Worker builds the image using React components styled with Tailwind CSS. | |
| 5. Caches response: The Worker returns the final image and caches it for future requests. |
Using active voice.
| - **Edge computing**: Generates images at the edge using Cloudflare Workers | ||
| - **Modern rendering**: Utilizes Vercel's Satori library for high-quality image generation | ||
| - **Flexible styling**: Supports both Tailwind CSS and inline styles | ||
| - **Font versatility**: Multiple font loading strategies for different use cases | ||
| - **Performance optimized**: Built-in caching and optimization | ||
| - **Customizable**: Easy to extend with new styles and font configurations | ||
| - **Developer friendly**: TypeScript support and modular architecture |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - **Edge computing**: Generates images at the edge using Cloudflare Workers | |
| - **Modern rendering**: Utilizes Vercel's Satori library for high-quality image generation | |
| - **Flexible styling**: Supports both Tailwind CSS and inline styles | |
| - **Font versatility**: Multiple font loading strategies for different use cases | |
| - **Performance optimized**: Built-in caching and optimization | |
| - **Customizable**: Easy to extend with new styles and font configurations | |
| - **Developer friendly**: TypeScript support and modular architecture | |
| - **Edge computing**: Generates images at the edge using Cloudflare Workers | |
| - **Modern rendering**: Utilizes Vercel's Satori library for high-quality image generation | |
| - **Flexible styling**: Supports both Tailwind CSS and inline styles | |
| - **Font versatility**: Allows multiple font loading strategies for different use cases | |
| - **Performance**: Uses built-in caching and optimization | |
| - **Customizable**: Scales easily with new styles and font configurations | |
| - **Developer friendly**: Offers TypeScript support and modular architecture |
Using active voice.
| - Decrease origin server load | ||
| - Provide consistent performance | ||
|
|
||
| Here's how to implement caching with customizable durations: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Here's how to implement caching with customizable durations: | |
| To implement caching with customizable durations: |
|
|
||
| ## Set up TypeScript type definitions | ||
|
|
||
| Let's create our type definitions to ensure smooth TypeScript integration. Create a new file `src/type.d.ts`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Let's create our type definitions to ensure smooth TypeScript integration. Create a new file `src/type.d.ts`: | |
| Create type definitions to ensure smooth TypeScript integration. Create a new file `src/type.d.ts`: |
| Make sure to configure appropriate cache durations based on your application's needs. The example uses a 24-hour cache duration. | ||
| ::: | ||
|
|
||
| ## Set up TypeScript type definitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ## Set up TypeScript type definitions | |
| ## 9. Set up TypeScript type definitions |
Should this be step 9?
|
|
||
| With these definitions in place, you will get full TypeScript support and autocompletion throughout your project. This makes development smoother and helps catch potential issues early. | ||
|
|
||
| ## 9. Deploy your Worker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ## 9. Deploy your Worker | |
| ## 10. Deploy your Worker |
| - GitHub avatar integration | ||
| - Perfect for developer profiles | ||
|
|
||
| :::tip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| :::tip | |
| :::note |
Not 100% sure we support tip, will find out and edit
|
This PR has been sitting for quite a while without any updates (or response to the comments dropped by @Oxyjun). Going to close it out for now. If you want to continue with the work, you'll need to make a new one. |
No description provided.