Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
chore(meta): better twitter meta support
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmarrec committed Nov 17, 2022
1 parent fe1b47d commit b40c401
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export default defineNuxtModule<PWAOptions>({
ogUrl: true,
twitterCard: undefined,
twitterSite: undefined,
twitterTitle: undefined,
twitterDescription: undefined,
twitterImage: undefined,
twitterCreator: undefined,
},
workbox: {
Expand Down
12 changes: 12 additions & 0 deletions src/parts/meta/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ export default (pwa: PWAContext) => {
if (options.twitterSite)
head.meta.push({ name: 'twitter:site', content: options.twitterSite })

// twitter:title
if (options.twitterTitle)
head.meta.push({ name: 'twitter:title', content: options.twitterTitle })

// twitter:description
if (options.twitterDescription)
head.meta.push({ name: 'twitter:description', content: options.twitterDescription })

// twitter:image
if (options.twitterImage)
head.meta.push({ name: 'twitter:image', content: joinURL(nuxt.options.app.baseURL, options.twitterImage) })

// twitter:creator
if (options.twitterCreator)
head.meta.push({ name: 'twitter:creator', content: options.twitterCreator })
Expand Down
5 changes: 4 additions & 1 deletion src/parts/meta/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export interface MetaOptions {
ogImage: string | boolean | { path: string; width?: number; height?: number; type?: string }
ogHost: string | undefined
ogUrl: string | boolean
twitterCard: string | undefined
twitterCard: 'summary' | 'summary_large_image' | 'app' | 'player' | undefined
twitterSite: string | undefined
twitterTitle: string | undefined
twitterDescription: string | undefined
twitterImage: string | undefined
twitterCreator: string | undefined
}

0 comments on commit b40c401

Please sign in to comment.