Skip to content

Commit

Permalink
fix(docusaurus-og): fix image meta elements selectors; closes #97
Browse files Browse the repository at this point in the history
  • Loading branch information
jeangovil committed Jul 11, 2023
1 parent a2fe4d5 commit 7a2701f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/docusaurus-og/src/server/document.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import * as fsp from 'fs/promises'
import { HTMLElement, parse as parseHTML } from 'node-html-parser'

const IMAGE_META_ELEMENTS: Array<[string, string]> = [
['name', 'image'],
['property', 'og:image'],
['name', 'twitter:image'],
]

export class Document {
root: HTMLElement
loaded = false
Expand All @@ -18,12 +24,11 @@ export class Document {
}

setImage = async (url: string) => {
this.updateMeta('property', 'og:image', {
content: url,
})
this.updateMeta('property', 'image', {
content: url,
})
IMAGE_META_ELEMENTS.forEach(([attr, value]) =>
this.updateMeta(attr, value, {
content: url,
}),
)
}

get head() {
Expand Down

0 comments on commit 7a2701f

Please sign in to comment.