refactor: move RecentDocs from footer to sidebar
RecentDocs now appears at the bottom of the sidebar instead of the page footer, making it more accessible during navigation. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
4900daa7bc
commit
53c3e2f60f
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import Link from '@docusaurus/Link';
|
||||
import { useLocation } from '@docusaurus/router';
|
||||
import { useAllDocsData } from '@docusaurus/plugin-content-docs/client';
|
||||
|
|
@ -87,7 +87,7 @@ export default function RecentDocs() {
|
|||
// Read-only display (no tracking)
|
||||
const displayItems = items.length > 0 ? items : getStored();
|
||||
|
||||
// Don't show on homepage (intro)
|
||||
// Don't show on homepage (intro) or empty state
|
||||
if (displayItems.length < 2) return null;
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
.container {
|
||||
margin-top: 1.5rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid var(--ifm-color-emphasis-200);
|
||||
/* Separator is handled by parent .recentSection */
|
||||
}
|
||||
|
||||
.heading {
|
||||
font-size: 0.82rem;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
color: var(--ifm-color-emphasis-600);
|
||||
margin-bottom: 0.6rem;
|
||||
letter-spacing: 0.03em;
|
||||
color: var(--ifm-color-emphasis-500);
|
||||
margin-bottom: 0.35rem;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
padding: 0 0.25rem;
|
||||
}
|
||||
|
||||
.list {
|
||||
|
|
@ -17,8 +17,8 @@
|
|||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.35rem;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
}
|
||||
|
||||
.item {
|
||||
|
|
@ -26,40 +26,39 @@
|
|||
}
|
||||
|
||||
.link {
|
||||
display: inline-flex;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
padding: 0.3rem 0.65rem;
|
||||
border: 1px solid var(--ifm-color-emphasis-300);
|
||||
border-radius: 6px;
|
||||
font-size: 0.82rem;
|
||||
justify-content: space-between;
|
||||
gap: 0.3rem;
|
||||
padding: 0.3rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.8rem;
|
||||
text-decoration: none !important;
|
||||
color: var(--ifm-font-color-base);
|
||||
transition: all 0.15s ease;
|
||||
background: var(--ifm-card-background-color);
|
||||
transition: all 0.12s ease;
|
||||
}
|
||||
|
||||
.link:hover {
|
||||
border-color: var(--ifm-color-primary);
|
||||
color: var(--ifm-color-primary);
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
|
||||
background: var(--ifm-menu-color-background-hover);
|
||||
color: var(--ifm-menu-color-active);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
max-width: 160px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 0.72rem;
|
||||
font-size: 0.68rem;
|
||||
color: var(--ifm-color-emphasis-400);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.link:hover .time {
|
||||
color: var(--ifm-color-primary-light);
|
||||
color: var(--ifm-color-emphasis-600);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import Footer from '@theme-original/DocItem/Footer';
|
|||
import type FooterType from '@theme/DocItem/Footer';
|
||||
import type {WrapperProps} from '@docusaurus/types';
|
||||
import DocFeedback from '../../../components/DocFeedback';
|
||||
import RecentDocs from '../../../components/RecentDocs';
|
||||
|
||||
type Props = WrapperProps<typeof FooterType>;
|
||||
|
||||
|
|
@ -12,7 +11,6 @@ export default function FooterWrapper(props: Props): ReactNode {
|
|||
<>
|
||||
<Footer {...props} />
|
||||
<DocFeedback />
|
||||
<RecentDocs />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
import React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import {useThemeConfig} from '@docusaurus/theme-common';
|
||||
import Logo from '@theme/Logo';
|
||||
import CollapseButton from '@theme/DocSidebar/Desktop/CollapseButton';
|
||||
import Content from '@theme/DocSidebar/Desktop/Content';
|
||||
import type {Props} from '@theme/DocSidebar/Desktop';
|
||||
import RecentDocs from '../../../components/RecentDocs';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
|
||||
function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}: Props) {
|
||||
const {
|
||||
navbar: {hideOnScroll},
|
||||
docs: {
|
||||
sidebar: {hideable},
|
||||
},
|
||||
} = useThemeConfig();
|
||||
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
styles.sidebar,
|
||||
hideOnScroll && styles.sidebarWithHideableNavbar,
|
||||
isHidden && styles.sidebarHidden,
|
||||
)}>
|
||||
{hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
|
||||
<Content path={path} sidebar={sidebar} />
|
||||
<div className={styles.recentSection}>
|
||||
<RecentDocs />
|
||||
</div>
|
||||
{hideable && <CollapseButton onClick={onCollapse} />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(DocSidebarDesktop);
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
@media (min-width: 997px) {
|
||||
.sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
padding-top: var(--ifm-navbar-height);
|
||||
width: var(--doc-sidebar-width);
|
||||
}
|
||||
|
||||
.sidebarWithHideableNavbar {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.sidebarHidden {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.sidebarLogo {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
margin: 0 var(--ifm-navbar-padding-horizontal);
|
||||
min-height: var(--ifm-navbar-height);
|
||||
max-height: var(--ifm-navbar-height);
|
||||
color: inherit !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.sidebarLogo img {
|
||||
margin-right: 0.5rem;
|
||||
height: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebarLogo {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.recentSection {
|
||||
flex-shrink: 0;
|
||||
border-top: 1px solid var(--ifm-color-emphasis-200);
|
||||
padding: 0.35rem 0.5rem 0.25rem;
|
||||
background: var(--ifm-background-color);
|
||||
}
|
||||
Loading…
Reference in New Issue