mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 09:07:29 +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' {
|
declare module '@docusaurus/plugin-content-docs' {
|
||||||
import type {RemarkAndRehypePluginOptions} from '@docusaurus/mdx-loader';
|
import type {RemarkAndRehypePluginOptions} from '@docusaurus/mdx-loader';
|
||||||
|
|
||||||
|
export interface Assets {
|
||||||
|
image?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export type NumberPrefixParser = (filename: string) => {
|
export type NumberPrefixParser = (filename: string) => {
|
||||||
filename: string;
|
filename: string;
|
||||||
numberPrefix?: number;
|
numberPrefix?: number;
|
||||||
|
@ -159,6 +163,7 @@ declare module '@theme/DocItem' {
|
||||||
import type {
|
import type {
|
||||||
PropNavigationLink,
|
PropNavigationLink,
|
||||||
PropVersionMetadata,
|
PropVersionMetadata,
|
||||||
|
Assets,
|
||||||
} from '@docusaurus/plugin-content-docs';
|
} from '@docusaurus/plugin-content-docs';
|
||||||
|
|
||||||
export type DocumentRoute = {
|
export type DocumentRoute = {
|
||||||
|
@ -204,6 +209,7 @@ declare module '@theme/DocItem' {
|
||||||
readonly metadata: Metadata;
|
readonly metadata: Metadata;
|
||||||
readonly toc: readonly TOCItem[];
|
readonly toc: readonly TOCItem[];
|
||||||
readonly contentTitle: string | undefined;
|
readonly contentTitle: string | undefined;
|
||||||
|
readonly assets: Assets;
|
||||||
(): JSX.Element;
|
(): JSX.Element;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,8 @@ import DocBreadcrumbs from '@theme/DocBreadcrumbs';
|
||||||
|
|
||||||
export default function DocItem(props: Props): JSX.Element {
|
export default function DocItem(props: Props): JSX.Element {
|
||||||
const {content: DocContent} = props;
|
const {content: DocContent} = props;
|
||||||
const {metadata, frontMatter} = DocContent;
|
const {metadata, frontMatter, assets} = DocContent;
|
||||||
const {
|
const {
|
||||||
image,
|
|
||||||
keywords,
|
keywords,
|
||||||
hide_title: hideTitle,
|
hide_title: hideTitle,
|
||||||
hide_table_of_contents: hideTableOfContents,
|
hide_table_of_contents: hideTableOfContents,
|
||||||
|
@ -32,6 +31,7 @@ export default function DocItem(props: Props): JSX.Element {
|
||||||
toc_max_heading_level: tocMaxHeadingLevel,
|
toc_max_heading_level: tocMaxHeadingLevel,
|
||||||
} = frontMatter;
|
} = frontMatter;
|
||||||
const {description, title} = metadata;
|
const {description, title} = metadata;
|
||||||
|
const image = assets.image ?? frontMatter.image;
|
||||||
|
|
||||||
// We only add a title if:
|
// We only add a title if:
|
||||||
// - user asks to hide it with front matter
|
// - user asks to hide it with front matter
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
---
|
||||||
|
image: ./img/oss_logo.png
|
||||||
|
---
|
||||||
|
|
||||||
# Image tests
|
# Image tests
|
||||||
|
|
||||||
import Image from '@theme/IdealImage';
|
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