mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 08:37:25 +02:00
fix(content-docs): properly display collocated social card image (#6744)
* fix(content-docs): properly display collocated social card image * oops
This commit is contained in:
parent
ddad9713e6
commit
051380aa4b
4 changed files with 12 additions and 2 deletions
|
@ -8,6 +8,10 @@
|
|||
declare module '@docusaurus/plugin-content-docs' {
|
||||
import type {RemarkAndRehypePluginOptions} from '@docusaurus/mdx-loader';
|
||||
|
||||
export interface Assets {
|
||||
image?: string;
|
||||
}
|
||||
|
||||
export type NumberPrefixParser = (filename: string) => {
|
||||
filename: string;
|
||||
numberPrefix?: number;
|
||||
|
@ -159,6 +163,7 @@ declare module '@theme/DocItem' {
|
|||
import type {
|
||||
PropNavigationLink,
|
||||
PropVersionMetadata,
|
||||
Assets,
|
||||
} from '@docusaurus/plugin-content-docs';
|
||||
|
||||
export type DocumentRoute = {
|
||||
|
@ -204,6 +209,7 @@ declare module '@theme/DocItem' {
|
|||
readonly metadata: Metadata;
|
||||
readonly toc: readonly TOCItem[];
|
||||
readonly contentTitle: string | undefined;
|
||||
readonly assets: Assets;
|
||||
(): JSX.Element;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -22,9 +22,8 @@ import DocBreadcrumbs from '@theme/DocBreadcrumbs';
|
|||
|
||||
export default function DocItem(props: Props): JSX.Element {
|
||||
const {content: DocContent} = props;
|
||||
const {metadata, frontMatter} = DocContent;
|
||||
const {metadata, frontMatter, assets} = DocContent;
|
||||
const {
|
||||
image,
|
||||
keywords,
|
||||
hide_title: hideTitle,
|
||||
hide_table_of_contents: hideTableOfContents,
|
||||
|
@ -32,6 +31,7 @@ export default function DocItem(props: Props): JSX.Element {
|
|||
toc_max_heading_level: tocMaxHeadingLevel,
|
||||
} = frontMatter;
|
||||
const {description, title} = metadata;
|
||||
const image = assets.image ?? frontMatter.image;
|
||||
|
||||
// We only add a title if:
|
||||
// - user asks to hide it with front matter
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
---
|
||||
image: ./img/oss_logo.png
|
||||
---
|
||||
|
||||
# Image tests
|
||||
|
||||
import Image from '@theme/IdealImage';
|
||||
|
|
BIN
website/_dogfooding/_docs tests/tests/img/oss_logo.png
Normal file
BIN
website/_dogfooding/_docs tests/tests/img/oss_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
Loading…
Add table
Add a link
Reference in a new issue