-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default function ConfigureSite() { | ||
return ( | ||
<h2>configure-site</h2> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/runtime/theme-default/components/DocFooter/index.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.prev, | ||
.next { | ||
width: 50%; | ||
} | ||
|
||
.pager-link { | ||
display: block; | ||
border: 1px solid var(--island-c-divider-light); | ||
border-radius: 8px; | ||
padding: 8px 16px 8px; | ||
width: 100%; | ||
height: 100%; | ||
transition: border-color 0.25s; | ||
} | ||
|
||
.pager-link:hover { | ||
border-color: var(--island-c-brand); | ||
} | ||
|
||
.pager-link:hover .title { | ||
color: var(--island-c-brand-dark); | ||
} | ||
|
||
.pager-link.next { | ||
margin-left: auto; | ||
text-align: right; | ||
} | ||
|
||
.desc { | ||
display: block; | ||
line-height: 20px; | ||
font-size: 12px; | ||
font-weight: 500; | ||
color: var(--island-c-text-2); | ||
} | ||
|
||
.title { | ||
display: block; | ||
line-height: 20px; | ||
font-size: 14px; | ||
font-weight: 500; | ||
color: var(--island-c-brand); | ||
transition: color 0.25s; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { usePrevNextPage } from '../../utils/usePrevNextPage' | ||
import styles from './index.module.scss' | ||
|
||
export function DocFooter() { | ||
const { prevPage, nextPage } = usePrevNextPage() | ||
return ( | ||
<footer mt="8"> | ||
<div flex="~" gap="2" divider-top="~" pt="6"> | ||
<div flex="~ col" className={styles.prev}> | ||
{prevPage && ( | ||
<a href={prevPage.link} className={styles.pagerLink}> | ||
<span className={styles.desc}>上一页</span> | ||
<span className={styles.title}>{prevPage.text}</span> | ||
</a> | ||
)} | ||
</div> | ||
<div flex="~ col" className={styles.next}> | ||
{nextPage && ( | ||
<a | ||
href={nextPage.link} | ||
className={`${styles.pagerLink} ${styles.next}`} | ||
> | ||
<span className={styles.desc}>下一页</span> | ||
<span className={styles.title}>{nextPage.text}</span> | ||
</a> | ||
)} | ||
</div> | ||
</div> | ||
</footer> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useMemo } from 'react' | ||
import { useLocation } from 'react-router-dom' | ||
import { usePageData } from '../../' | ||
import type { SidebarItem } from 'shared/types' | ||
|
||
export function usePrevNextPage() { | ||
const { pathname } = useLocation() | ||
const { siteData } = usePageData() | ||
const sidebar = siteData.themeConfig?.sidebar || {} | ||
|
||
const flattenTitles = useMemo(() => { | ||
const res: SidebarItem[] = [] | ||
// 遍历 Sidebar 数据,收集所有的文章信息,并平铺到一个数组里面 | ||
Object.keys(sidebar).forEach((key) => { | ||
const groups = sidebar[key] || [] | ||
groups.forEach((group) => { | ||
group.items.forEach((item) => { | ||
res.push(item) | ||
}) | ||
}) | ||
}) | ||
return res | ||
}, [sidebar]) | ||
|
||
const pageIndex = flattenTitles.findIndex((item) => item.link === pathname) | ||
|
||
const prevPage = flattenTitles[pageIndex - 1] || null | ||
const nextPage = flattenTitles[pageIndex + 1] || null | ||
|
||
return { | ||
prevPage, | ||
nextPage, | ||
} | ||
} |