Skip to content
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

8 generate an ogp image automatically 2 #13

Merged
merged 3 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions layouts/partials/meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<meta name="description" content="{{ .Summary }}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta name="twitter:card" content="summary_large_image">
{{- with .Site.Params.Social.twitter }}<meta name="twitter:site" content="@{{ . }}">{{ end }}
<!-- TODO: Add w/ better author support <meta name="twitter:creator" content="@.author" /> -->
{{ with .Site.Title }}<meta property="og:site_name" content="{{ . }}">{{ end }}
Expand All @@ -14,10 +13,13 @@
{{ $ogImagePathBase := printf "/img/og/%s.png" .File.BaseFileName }}
{{ $ogImagePathForCheckExists := printf "/static%s" $ogImagePathBase }}
{{ if fileExists $ogImagePathForCheckExists }}
<meta name="twitter:card" content="summary_large_image">
{{ $ogImagePath := printf "/blog%s" $ogImagePathBase }}
<meta property="og:image" content="{{ $ogImagePath | absURL }}">
{{ else }}
<meta property="og:image" content="{{ .Site.Params.intro.pic.src | absURL }}">
<meta name="twitter:card" content="summary">
{{ $ogImagePath := printf "/blog%s" .Site.Params.intro.pic.src }}
<meta property="og:image" content="{{ $ogImagePath | absURL }}">
{{ end }}
<meta property="og:image:alt" content="The Open Graph logo">

Expand Down
Binary file modified static/img/og/ogp-template.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.