Skip to content

feat: support open graph protocol #2096

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

Merged
merged 10 commits into from
Mar 31, 2025

Conversation

leochiu-a
Copy link
Contributor

@leochiu-a leochiu-a commented Mar 3, 2025

Description

Support Open Graph Protocol in the headmatter. Only adding support for the following attributes:

seoMeta:
  ogTitle: Slidev Starter Template
  ogDescription: Presentation slides for developers
  ogImage: https://cover.sli.dev
  ogUrl: https://example.com
  twitterCard: summary_large_image
  twitterTitle: Slidev Starter Template
  twitterDescription: Presentation slides for developers
  twitterImage: https://cover.sli.dev
  twitterSite: username
  twitterUrl: https://example.com

Test Plans

  • The SEO meta tag should be visible in the view source page.

Related issue

Copy link

netlify bot commented Mar 3, 2025

Deploy Preview for slidev failed.

Name Link
🔨 Latest commit 149975c
🔍 Latest deploy log https://app.netlify.com/sites/slidev/deploys/67ea14cd6d673700087a9701

@leochiu-a leochiu-a force-pushed the feat/support-open-graph-protocol branch from a0e9240 to 1bd92b3 Compare March 3, 2025 09:54
@antfu
Copy link
Member

antfu commented Mar 3, 2025

I wonder if we should use something more comprehensive like https://unhead.unjs.io to support more tags other than only og

@leochiu-a leochiu-a force-pushed the feat/support-open-graph-protocol branch from 1bd92b3 to 290e2dc Compare March 4, 2025 12:36
@leochiu-a
Copy link
Contributor Author

leochiu-a commented Mar 4, 2025

I wonder if we should use something more comprehensive like https://unhead.unjs.io to support more tags other than only og

It sounds like a good idea. I can implement it.

@leochiu-a
Copy link
Contributor Author

leochiu-a commented Mar 4, 2025

@antfu Do you think we need to implement all Open Graph attributes using useSeoMeta, or should we provide only the essential tags, such as the following?

  • og:title
  • og:desription
  • og:image
  • og:url
  • twitter:card
  • twitter:site
  • twitter:title
  • twitter:description
  • twitter:image
  • twitter:url

Then, we can provide a seoMeta attribute on headmatter which extends the MetaFlat type from unhead.

It would be like the following.

seoMeta:
  ogTitle: Slidev Starter Template
  ogDescription: Presentation slides for developers
  ogImage: https://cover.sli.dev
  ogUrl: https://example.com
  twitterCard: summary_large_image
  twitterSite: @username

@antfu
Copy link
Member

antfu commented Mar 5, 2025

Yeah that looks great, thanks!

@leochiu-a leochiu-a force-pushed the feat/support-open-graph-protocol branch from cfa4cad to 8e8102f Compare March 5, 2025 09:38
@leochiu-a
Copy link
Contributor Author

leochiu-a commented Mar 5, 2025

@antfu Because transformHtmlTemplate is supported by [email protected]., I installed it in packages/slidev. What do you think? Or, should we use stable version unhead?

@leochiu-a leochiu-a force-pushed the feat/support-open-graph-protocol branch 3 times, most recently from ddcda87 to dc220b2 Compare March 5, 2025 14:06
@leochiu-a leochiu-a force-pushed the feat/support-open-graph-protocol branch from dc220b2 to 1cbdb3b Compare March 13, 2025 02:04
@ogadra ogadra mentioned this pull request Mar 15, 2025
Copy link

@ogadra ogadra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for developing this! I would love to have this feature as soon as possible!

It seems difficult to implement without using transformHtmlTemplate, so I’m okay with using an unstable version of unhead if necessary.

@leochiu-a
Copy link
Contributor Author

Hi, @antfu. Could you take a look when you have time?

@antfu antfu merged commit af4c25a into slidevjs:main Mar 31, 2025
6 of 11 checks passed
Copy link

pkg-pr-new bot commented Mar 31, 2025

Open in Stackblitz

@slidev/client

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2096

create-slidev

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@2096

create-slidev-theme

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2096

@slidev/parser

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2096

@slidev/cli

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2096

@slidev/types

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/types@2096

commit: 149975c

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

Successfully merging this pull request may close these issues.

3 participants