Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new beforeDocContent, afterDocContent props for layout component #996

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/document/docs/en/guide/advanced/custom-theme.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ const Layout = () => (
beforeDoc={<div>beforeDoc</div>}
/* Doc page end */
afterDoc={<div>afterDoc</div>}
/* Doc content front */
beforeDocContent={<div>beforeDocContent</div>}
/* Doc content end */
afterDocContent={<div>afterDocContent</div>}
/* Before the nav bar */
beforeNav={<div>beforeNav</div>}
/* Before the title of the nav bar in the upper left corner */
Expand Down
4 changes: 4 additions & 0 deletions packages/document/docs/zh/guide/advanced/custom-theme.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ const Layout = () => (
beforeDoc={<div>beforeDoc</div>}
/* 正文页最后面 */
afterDoc={<div>afterDoc</div>}
/* 文档内容前面 */
beforeDocContent={<div>beforeDocContent</div>}
/* 文档内容后面 */
afterDocContent={<div>afterDocContent</div>}
/* 导航栏之前 */
beforeNav={<div>beforeNav</div>}
/* 左上角导航栏标题之前 */
Expand Down
16 changes: 14 additions & 2 deletions packages/theme-default/src/layout/DocLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export interface DocLayoutProps {
afterDocFooter?: React.ReactNode;
beforeDoc?: React.ReactNode;
afterDoc?: React.ReactNode;
beforeDocContent?: React.ReactNode;
afterDocContent?: React.ReactNode;
beforeOutline?: React.ReactNode;
afterOutline?: React.ReactNode;
uiSwitch?: UISwitchResult;
Expand All @@ -28,6 +30,8 @@ export function DocLayout(props: DocLayoutProps) {
afterDocFooter,
beforeDoc,
afterDoc,
beforeDocContent,
afterDocContent,
beforeOutline,
afterOutline,
beforeSidebar,
Expand Down Expand Up @@ -73,10 +77,18 @@ export function DocLayout(props: DocLayoutProps) {
>
<div className="w-full flex-1">
{isOverviewPage ? (
<Overview content={docContent} />
<>
{beforeDocContent}
<Overview content={docContent} />
{afterDocContent}
</>
) : (
<div>
<div className="rspress-doc">{docContent}</div>
<div className="rspress-doc">
{beforeDocContent}
{docContent}
{afterDocContent}
</div>
<div className="rspress-doc-footer">
{beforeDocFooter}
{uiSwitch.showDocFooter && <DocFooter />}
Expand Down
4 changes: 4 additions & 0 deletions packages/theme-default/src/layout/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const Layout: React.FC<LayoutProps> = props => {
afterDocFooter,
beforeDoc,
afterDoc,
beforeDocContent,
afterDocContent,
beforeSidebar,
afterSidebar,
beforeOutline,
Expand All @@ -42,6 +44,8 @@ export const Layout: React.FC<LayoutProps> = props => {
const docProps: DocLayoutProps = {
beforeDocFooter,
afterDocFooter,
beforeDocContent,
afterDocContent,
beforeDoc,
afterDoc,
beforeSidebar,
Expand Down
Loading