-
Notifications
You must be signed in to change notification settings - Fork 121
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
Add Open Graph Support #964
Comments
|
This may actually require work in the Swift-DocC compiler to fully resolve issues where this data is not being rendered appropriately. Technically, Swift-DocC-Render already renders some basic open graph metadata (source), but it only does client-side rendering, which is why it may not always work as expected depending on how the page is shared. We would need to update DocC to add the related meta tags to individual HTML files that it generates for static file hosting solutions like GitHub Pages where there is no server-side logic that could do this. |
Filed an issue on swift-docc to track this. #658
Got it. |
Taking WWDC23's demo project - SlothCreator as an example. The generated gettingstarted.json from // GettingStarted.md
@Metadata {
@PageImage(purpose: card, source: "gettingStarted-card", alt: "The profile images for a regular sloth and an ice sloth.")
}will be So I think there is already enough information provided by swift-docc. We can update the logic from |
|
To clarify, I think we already have the right data to populate the meta tags needed for this—however, I think the logic will need to live in Swift-DocC since it would need to dynamically generate the right metadata in the individual HTML files that it produces as part of supporting static hosting environments. We can update the |
|
Got the point. We should do the logic when swift-docc produce the static HTML file if possible. |
|
For reference, I've just run into this issue as well with the WWDC Notes project. I've migrated the old site to DocC this year, but when I post session notes on social media (Twitter, Mastodon, etc.) there's no preview like it used to have on the old website. That's a bummer and if there's anything I can do to help get this done, let me know. See for example this tweet linking to this note. Note that I've decided to take screenshots of the site and attach that as there are no cards showing, which is annoying because I can't automate that. I'd like to post these tweets automatically when new notes have been added with a rich preview, if possible. Thank you for your consideration and hard work! DocC is awesome. 💪 |
|
@franklinsch I transferred this issue from the swift-docc-render repo to the swift-docc one, because this enhancement would have to be implemented in swift-docc itself. Swift-DocC-Render already dynamically updates this open graph metadata on the client-side, but it is more optimal for this metadata to be built into the HTML file at the server side or where the HTML is generated for pre-built content—which is the Swift-DocC compiler in this instance. Specifically, we would need to update the code that copies the |
Actually, I have created 2 issues at the beginning(One at swift-docc-render, one at swift-docc See context: #964 (comment)). Since you transferred the issue from swift-docc-render to swift-docc, I just closed the original issue on the repo due to a duplicate. |
|
Ah, whoops—my mistake. Thanks for clearing that up @Kyle-Ye |
Feature Name
Add Open Graph Support
Description
Currently when sharing a documentation(Article or Tutorial), the url is render as a pure title card.
If there is image information available, we should add
og:imageto html header to better render the doc link in other site.eg.
Metadata directive's PageImage parameterhttps://forums.swift.org/t/feature-suggestion-add-open-graph-support/65989
The text was updated successfully, but these errors were encountered: