feat: make the open graph tags dynamic based on the base64 and url query parameters#1122
feat: make the open graph tags dynamic based on the base64 and url query parameters#1122helios2003 wants to merge 4 commits intoasyncapi:masterfrom
base64 and url query parameters#1122Conversation
|
✅ Deploy Preview for modest-rosalind-098b67 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for asyncapi-studio-design-system ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for studio-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
apps/studio-next/next.config.js
Outdated
| async rewrites() { | ||
| return [ | ||
| { | ||
| source: '/:base64', |
There was a problem hiding this comment.
I think we can support URLs here as well, I mean when a user shares a file with url parameter.
There was a problem hiding this comment.
Yes, we should support both base64 and url use cases as stated in #224
There was a problem hiding this comment.
Yes sure, I will add it.
| import { Parser } from '@asyncapi/parser'; | ||
| import { DocumentInfo } from '@/types'; | ||
|
|
||
| export default async function parseURL(base64Document: string): Promise<DocumentInfo | null> { |
There was a problem hiding this comment.
We also have this parsing logic to parse the AsyncAPI file from base65 or a url in the studio as well, maybe we can re-use this functionality in both places.
There was a problem hiding this comment.
So do you recommend keeping the studio version, or using this code?
There was a problem hiding this comment.
They both serve the same purpose, so I guess you can look at both of them and combine them into a util function.
apps/studio-next/src/middleware.ts
Outdated
There was a problem hiding this comment.
The configuration and this middleware achieve the purpose, right? I don't understand why we are adding both.
|
Thank you for the review @KhudaDad414. I will add the suggested changes. |
|
Also, I had a few questions:
|
If you don't use a complete list of crawlers, you will end up facing issues like the one you mentioned:
This is happening most probably because you are not considering Whatsapp User-Agent(s).
AFAIK, indexer robots such as Google only follow links, meaning that unless there is a published link somewhere to a link such as |
Will that work in a Netlify setup? I mentioned an alternative in case it doesn't in #224. Additionally, I think we can include more statistics in the rendered image like # of operations |
Yes, it works. The service is currently hosted on Netlify: https://ogp-studio.netlify.app.
Okay, I will add it. |
base64 urlbase64 and url query parameters
|
Added modifications:
|
| <meta property="og:title" content="AsyncAPI Studio" /> | ||
| <meta property="og:description" content="Studio for AsyncAPI specification, where you can validate, view preview documentation, and generate templates from AsyncAPI document." /> | ||
| <meta property="og:url" content="https://studio-next.netlify.app" /> | ||
| <meta property="og:image" content="https://raw.githubusercontent.com/asyncapi/studio/master/apps/studio-next/public/img/meta-studio-og-image.jpeg" /> |
There was a problem hiding this comment.
Can those values be grabbed from
studio/apps/studio-next/src/app/page.tsx
Line 12 in a428b15
apps/studio-next/src/middleware.ts
Outdated
| export const config = { | ||
| matcher: ['/:base64', '/:url'], | ||
| } |
There was a problem hiding this comment.
Is this matcher configuration correct? I feel like it is matching to path parameters instead of query parameters that we use for url and base64.
There was a problem hiding this comment.
Oh yes, you are right, I didn't interpret the documentation correctly, I will make the changes.
| const websiteTitle = "AsyncAPI Studio"; | ||
| const websiteDescription = "Studio for AsyncAPI specification, where you can validate, view preview documentation, and generate templates from AsyncAPI document."; | ||
| const websiteUrl = "https://studio-next.netlify.app"; | ||
| const ogImage = "https://raw.githubusercontent.com/asyncapi/studio/master/apps/studio-next/public/img/meta-studio-og-image.jpeg"; |
There was a problem hiding this comment.
As I commented previously, those values are already present in the source code in
studio/apps/studio-next/src/app/page.tsx
Lines 4 to 25 in a8c8cb5
Please reuse them somehow instead of hardcoding them here again.
fd2de17 to
730df15
Compare
|
The PR is ready for review @KhudaDad414, @smoya. |
|
Also, I'm unsure if the middleware code I wrote is the best way to achieve this functionality. Any suggestions or improvements would be appreciated. |
| </head> | ||
| </html> | ||
| `; | ||
| console.log(crawlerInfo); |
There was a problem hiding this comment.
| console.log(crawlerInfo); |
|
@helios2003 Are you planning to move the OG Image generator service (Netlify Edge Function) into this PR? |
|
Maintainers, can you please review the PR? I have addressed all the comments above and included the unit tests. Additionally, I had to change the version of |
|
Some tests are still failing @helios2003 |
|
@Amzani the tests are failing in |
|
I suppose this can me merged as soon as the merging of studio and studio-next is done. |
KhudaDad414
left a comment
There was a problem hiding this comment.
tests are faliling since you are installing a newer version of jest-environment-jsdom on studio-next app explicitly.
to resolve install the older version in studio app.
pnpm install -D jest-environment-jsdom@27.5.1
|
|
Maintainers, the tests are passing now. PTAL at the PR. |
19858da to
e87ce69
Compare
|
|
|
@smoya @helios2003 any status on this? |
|
I will make changes to this PR, but I believe the sharing mechanism has changed a bit, so I need to adapt the code accordingly. |
|
This pull request has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation. There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
@helios2003 Any updates on this? |
|
This pull request has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation. There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |



This PR addresses the issue mentioned in #224. I have added the following features in this PR.
Features Added
api/crawler. This is done to serve minimal HTML when the crawler hits the page, reducing the chance of timeout.og:imageif there is an invalid base64 string provided.Todos
og:imagedoes not appear on site like Whatsapp.cc : @smoya