-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat: make the open graph tags dynamic based on the base64
and url
query parameters
#1122
base: master
Are you sure you want to change the base?
Conversation
|
✅ 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. |
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.
left some comments.
apps/studio-next/next.config.js
Outdated
async rewrites() { | ||
return [ | ||
{ | ||
source: '/:base64', |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should support both base64
and url
use cases as stated in #224
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So do you recommend keeping the studio
version, or using this 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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can those values be grabbed from
studio/apps/studio-next/src/app/page.tsx
Line 12 in a428b15
url: 'https://studio-next.netlify.app', |
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.
Done, @smoya
apps/studio-next/src/middleware.ts
Outdated
export const config = { | ||
matcher: ['/:base64', '/:url'], | ||
} |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
import ogImage from '@/img/meta-studio-og-image.jpeg'; | |
export const metadata: Metadata = { | |
metadataBase: new URL('https://studio-next.netlify.app'), | |
openGraph: { | |
type: 'website', | |
title: 'AsyncAPI Studio', | |
description: 'Studio for AsyncAPI specification, where you can validate, view preview documentation, and generate templates from AsyncAPI document.', | |
url: 'https://studio-next.netlify.app', | |
images: [ | |
{ | |
url: ogImage.src, | |
width: 800, | |
height: 600, | |
alt: 'AsyncAPI default image', | |
}, | |
] | |
}, | |
twitter: { | |
site: '@AsyncAPISpec', | |
} | |
} |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.
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 [email protected]
Quality Gate passedIssues Measures |
Maintainers, the tests are passing now. PTAL at the PR. |
19858da
to
e87ce69
Compare
Quality Gate passedIssues Measures |
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:image
if there is an invalid base64 string provided.Todos
og:image
does not appear on site like Whatsapp.cc : @smoya