facebook / facebook/docusaurus

A hook for PageMetadata

Ouverte
#8,658 4 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
feature
Langage dominant
TypeScript
Étoiles
66.2k
Forks
10k
Merge moyen
1 j 3 h
PR mergées (30 j)
52

Description

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#issues).

### Description

Consider the `PageMetadata` component:

https://github.com/facebook/docusaurus/blob/6b618bc9e5fcc9d52d3aa49a9d447f4d7ea76d41/packages/docusaurus-theme-common/src/utils/metadataUtils.tsx#L27-L62

There's no way to hook into this and make adjustments. It would be cool if there was.

### Has this been requested on Canny?

No

### Motivation

I recently built a plugin which allows users to use Cloudinary as a CDN for images:

https://johnnyreilly.com/docusaurus-image-cloudinary-rehype-plugin

Whilst I'm able to use this to flip to Cloudinary for general image serving, I cannot for `og:image` / `twitter:image` which is surfaced in the `PageMetadata` component. And interestingly, images there get hardcoded with the baseUrl of the site (which doesn't work for image CDNs)

It would be cool if it were possible to control this somehow.

### API design

I'm not quite sure what makes sense, possibly a hook that cook be supplied in the `docusaurus.config.js` which would have current parameters as inputs, and new parameters as outputs. Not really sure.

Open to suggestions.

### Have you tried building it?

No

### Self-service

- [X] I'd be willing to contribute this feature to Docusaurus myself.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.