Skip to content
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

Fetch and render OG images for links on pages #29

Open
MrCoder opened this issue Nov 13, 2023 · 2 comments
Open

Fetch and render OG images for links on pages #29

MrCoder opened this issue Nov 13, 2023 · 2 comments

Comments

@MrCoder
Copy link
Contributor

MrCoder commented Nov 13, 2023

It is an idea that we develop a plugin for DocuSaurus that automatically fetches and renders Open Graph (OG) images from external links included in markdown files.

Use case

Content is critical for our SEO and overall marketing success. A convenient way to include existing sequence diagram on pages/articles is useful.

We have said we will support one way to include diagram which is using code block like below:

```
A.method
```

With this one, it is easy to compose.

This proposal is for a different use case - to include an existing diagram from our diagram gallery. The extra benefit is that it can link back to the original diagram on our site which is useful to build an SEO network.

Proposed Functionality

  1. Link Scanning: Automatically scan markdown files for links from our gallery during the build process.
  2. OG Image Fetching: For each link, make an HTTP request to fetch the HTML content and parse it to extract the OG image URL (from og:image meta tags).
  3. Image Storage: Download these images and include them in the build artifacts.
  4. Image Rendering: Modify the page rendering logic to display these images alongside their respective links.
  5. Performance Optimization: Implement caching mechanisms to prevent repeated downloads of the same image and consider image optimization for faster loading.
  6. Error Handling: Robust error handling for scenarios where an OG image is not available or cannot be fetched.
@MrCoder MrCoder changed the title Fetch and render OG images for pages Fetch and render OG images for links on pages Nov 13, 2023
@unimu-cic
Copy link
Contributor

unimu-cic commented Nov 13, 2023

Do we need to store these images? Because the OG image is dynamically generated by LaraSite. We can do something like this to improve SEO:

md:
[![ZenUML | Diagram Title](http://zenuml.com/sequence-diagram/diagrams/1/og-image.jpg)](https://zenuml.com/sequence-diagram/diagrams/1)

render to👇

html:
<a href="https://zenuml.com/sequence-diagram/diagrams/1">
  <img alt="ZenUML | Diagram Title" src="http://zenuml.com/sequence-diagram/diagrams/1/og-image.jpg" />
</a>

So, we only need to care about:

  • How to generate the image link for each code block, and the Editor also can reuse the diagram on the doc site
  • Performance Optimization
  • Error Handling

@MrCoder
Copy link
Contributor Author

MrCoder commented Nov 21, 2023

Is OG image always regenerated? We have added salt to the URL so that we always get the right OG image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants