Add: 記事ページにバナー画像をヒーロー表示 (DocItem swizzle)
All checks were successful
Deploy Docusaurus Site / deploy (push) Successful in 29s
All checks were successful
Deploy Docusaurus Site / deploy (push) Successful in 29s
This commit is contained in:
parent
8c109a1d9a
commit
be647e96d2
35
src/theme/DocItem/Layout/index.tsx
Normal file
35
src/theme/DocItem/Layout/index.tsx
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import React, {type ReactNode} from 'react';
|
||||||
|
import Layout from '@theme-original/DocItem/Layout';
|
||||||
|
import type LayoutType from '@theme/DocItem/Layout';
|
||||||
|
import type {WrapperProps} from '@docusaurus/types';
|
||||||
|
import {useDoc} from '@docusaurus/plugin-content-docs/client';
|
||||||
|
|
||||||
|
type Props = WrapperProps<typeof LayoutType>;
|
||||||
|
|
||||||
|
export default function LayoutWrapper(props: Props): ReactNode {
|
||||||
|
const {frontMatter} = useDoc();
|
||||||
|
const image = (frontMatter as any).image as string | undefined;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{image && (
|
||||||
|
<div style={{
|
||||||
|
marginBottom: '1.5rem',
|
||||||
|
borderRadius: '12px',
|
||||||
|
overflow: 'hidden',
|
||||||
|
boxShadow: '0 4px 12px rgba(0,0,0,0.15)',
|
||||||
|
}}>
|
||||||
|
<img
|
||||||
|
src={image}
|
||||||
|
alt=""
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
display: 'block',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<Layout {...props} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user