Skip to content

feat: support open graph protocol#2096

Merged
antfu merged 10 commits into
slidevjs:mainfrom
leochiu-a:feat/support-open-graph-protocol
Mar 31, 2025
Merged

feat: support open graph protocol#2096
antfu merged 10 commits into
slidevjs:mainfrom
leochiu-a:feat/support-open-graph-protocol

Conversation

@leochiu-a

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

Copy link
Copy Markdown
Contributor

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

@netlify

netlify Bot commented Mar 3, 2025

Copy link
Copy Markdown

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

antfu commented Mar 3, 2025

Copy link
Copy Markdown
Member

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

leochiu-a commented Mar 4, 2025

Copy link
Copy Markdown
Contributor Author

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

leochiu-a commented Mar 4, 2025

Copy link
Copy Markdown
Contributor Author

@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

antfu commented Mar 5, 2025

Copy link
Copy Markdown
Member

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

leochiu-a commented Mar 5, 2025

Copy link
Copy Markdown
Contributor Author

@antfu Because transformHtmlTemplate is supported by unhead@2.0.0-rc., 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

@ogadra ogadra left a comment

Copy link
Copy Markdown

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
Copy Markdown
Contributor Author

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

@antfu
antfu merged commit af4c25a into slidevjs:main Mar 31, 2025
@pkg-pr-new

pkg-pr-new Bot commented Mar 31, 2025

Copy link
Copy Markdown

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