|
1 | 1 | import styles from './index.module.scss';
|
2 | 2 | import { usePageData } from 'island/client';
|
| 3 | +import { useEditLink, usePrevNextPage } from '../../logic'; |
| 4 | +import { normalizeHref } from '../../logic/index'; |
3 | 5 |
|
4 | 6 | export function DocFooter() {
|
5 |
| - const { siteData } = usePageData(); |
6 |
| - const { editLink } = siteData?.themeConfig || {}; |
| 7 | + const { siteData, relativePagePath } = usePageData(); |
| 8 | + const { prevPage, nextPage } = usePrevNextPage(siteData); |
| 9 | + const { editLink: rawEditLink } = siteData.themeConfig; |
| 10 | + const editLink = useEditLink(rawEditLink!, relativePagePath); |
| 11 | + |
7 | 12 | return (
|
8 | 13 | <footer className={styles.footer}>
|
9 | 14 | <div className={styles.editInfo}>
|
10 |
| - <div className={styles.editLink}> |
11 |
| - <button className={styles.editLinkButton}>Edit Link</button> |
12 |
| - </div> |
13 |
| - <div className={styles.lastUpdated}> |
14 |
| - {editLink ? ( |
| 15 | + {editLink ? ( |
| 16 | + <div className={styles.editLink}> |
| 17 | + <a className={styles.editLinkButton} href={editLink.link}> |
| 18 | + {editLink.text} |
| 19 | + </a> |
| 20 | + </div> |
| 21 | + ) : null} |
| 22 | + |
| 23 | + {/* TODO */} |
| 24 | + {/* <div className={styles.lastUpdated}> |
| 25 | + {lastUpdatedText ? ( |
15 | 26 | <>
|
16 | 27 | <p className={styles.lastUpdated}>
|
17 | 28 | {editLink?.text || 'Last Updated: '}
|
18 | 29 | </p>
|
19 |
| - <span>{editLink?.pattern}</span> |
| 30 | + <span>{}</span> |
20 | 31 | </>
|
21 | 32 | ) : null}
|
22 |
| - </div> |
| 33 | + </div> */} |
23 | 34 | </div>
|
24 | 35 |
|
25 | 36 | <div className={styles.prevNext}>
|
26 | 37 | <div className={styles.pager}>
|
27 |
| - <a href="/" className={`${styles.pagerLink} ${styles.prev}`}> |
28 |
| - <span className={styles.desc}>Previous Page</span> |
29 |
| - </a> |
| 38 | + {prevPage ? ( |
| 39 | + <a |
| 40 | + href={normalizeHref(prevPage.link)} |
| 41 | + className={`${styles.pagerLink} ${styles.prev}`} |
| 42 | + > |
| 43 | + <span className={styles.desc}>Previous Page</span> |
| 44 | + <span className={styles.title}>{prevPage.text}</span> |
| 45 | + </a> |
| 46 | + ) : null} |
30 | 47 | </div>
|
31 |
| - <div className={`${styles.pager} ${styles.hasNext}`}> |
32 |
| - <a href="/" className={`${styles.pagerLink} ${styles.next}`}> |
33 |
| - <span className={styles.desc}>Next Page</span> |
34 |
| - </a> |
| 48 | + <div className={styles.pager}> |
| 49 | + {nextPage ? ( |
| 50 | + <div className={`${styles.hasNext}`}> |
| 51 | + <a |
| 52 | + href={normalizeHref(nextPage.link)} |
| 53 | + className={`${styles.pagerLink} ${styles.next}`} |
| 54 | + > |
| 55 | + <span className={styles.desc}>Next Page</span> |
| 56 | + <span className={styles.title}>{nextPage.text}</span> |
| 57 | + </a> |
| 58 | + </div> |
| 59 | + ) : null} |
35 | 60 | </div>
|
36 | 61 | </div>
|
37 | 62 | </footer>
|
|
0 commit comments