|
1 | 1 | import Image from 'next/image';
|
2 | 2 | import React from 'react';
|
| 3 | +import Link from 'next/link'; |
3 | 4 |
|
4 |
| -export default function NextPrevButton({ prev, next }: any) { |
| 5 | +/* |
| 6 | +To use this component: |
| 7 | +1) Add prev and next metadata to the markdown page following this format: |
| 8 | +
|
| 9 | +--- |
| 10 | +title: Creating your first schema |
| 11 | +section: docs |
| 12 | +prev: |
| 13 | + label: prev |
| 14 | + url: '#1' |
| 15 | +next: |
| 16 | + label: Miscellaneous examples |
| 17 | + url: '#2' |
| 18 | +--- |
| 19 | +
|
| 20 | +2) Add the component to the typescript page: |
| 21 | +
|
| 22 | +import NextPrevButton from '~/components/NextPrevButton'; |
| 23 | +
|
| 24 | +3) Add the component to the body of the page: |
| 25 | +
|
| 26 | +<NextPrevButton prevLabel={frontmatter.prev.label} prevURL={frontmatter.prev.url} nextLabel={frontmatter.next.label} nextURL={frontmatter.next.url} /> |
| 27 | +*/ |
| 28 | + |
| 29 | +export default function NextPrevButton({ |
| 30 | + prevLabel, |
| 31 | + prevURL, |
| 32 | + nextLabel, |
| 33 | + nextURL, |
| 34 | +}: any) { |
5 | 35 | return (
|
6 | 36 | <div className='mb-4 flex flex-row gap-4'>
|
7 | 37 | <div className='h-auto w-1/2'>
|
8 | 38 | <div
|
9 | 39 | className='cursor-pointer rounded border border-gray-200 p-4 text-center shadow-md transition-all duration-300 ease-in-out hover:border-gray-300 hover:shadow-lg dark:shadow-xl dark:hover:shadow-2xl dark:drop-shadow-lg
|
10 | 40 | lg:text-left'
|
11 | 41 | >
|
12 |
| - <div className='text-primary dark:text-slate-300 flex flex-row gap-5 text-[18px]'> |
13 |
| - <Image |
14 |
| - src={'/icons/arrow.svg'} |
15 |
| - height={10} |
16 |
| - width={10} |
17 |
| - alt='prev icon' |
18 |
| - className='rotate-180 w-5 ' |
19 |
| - /> |
20 |
| - <div className='my-auto inline font-bold uppercase '>Go Back</div> |
21 |
| - </div> |
22 |
| - <div className='my-2 text-base font-medium text-slate-600 dark:text-slate-300'> |
23 |
| - {prev} |
24 |
| - </div> |
| 42 | + <Link href={prevURL}> |
| 43 | + <div className='text-primary dark:text-slate-300 flex flex-row gap-5 text-[18px]'> |
| 44 | + <Image |
| 45 | + src={'/icons/arrow.svg'} |
| 46 | + height={10} |
| 47 | + width={10} |
| 48 | + alt='prev icon' |
| 49 | + className='rotate-180 w-5 ' |
| 50 | + /> |
| 51 | + <div className='my-auto inline font-bold uppercase '>Go Back</div> |
| 52 | + </div> |
| 53 | + <div className='my-2 text-base font-medium text-slate-600 dark:text-slate-300'> |
| 54 | + {prevLabel} |
| 55 | + </div> |
| 56 | + </Link> |
25 | 57 | </div>
|
26 | 58 | </div>
|
| 59 | + |
27 | 60 | <div className='h-auto w-1/2'>
|
28 | 61 | <div className='h-full cursor-pointer rounded border border-gray-200 p-4 text-center shadow-md transition-all duration-300 ease-in-out hover:border-gray-300 hover:shadow-lg dark:shadow-xl dark:drop-shadow-lg dark:hover:shadow-2xl lg:text-right'>
|
29 |
| - <div className='text-primary dark:text-slate-300 flex flex-row-reverse gap-5 text-[18px]'> |
30 |
| - <Image |
31 |
| - src={'/icons/arrow.svg'} |
32 |
| - height={10} |
33 |
| - width={10} |
34 |
| - alt='next icon ' |
35 |
| - className='w-5' |
36 |
| - /> |
37 |
| - <div className='my-auto inline font-bold uppercase '>Up Next</div> |
38 |
| - </div> |
39 |
| - <div className='my-2 text-base font-medium text-slate-600 dark:text-slate-300'> |
40 |
| - {next} |
41 |
| - </div> |
| 62 | + <Link href={nextURL}> |
| 63 | + <div className='text-primary dark:text-slate-300 flex flex-row-reverse gap-5 text-[18px]'> |
| 64 | + <Image |
| 65 | + src={'/icons/arrow.svg'} |
| 66 | + height={10} |
| 67 | + width={10} |
| 68 | + alt='next icon ' |
| 69 | + className='w-5' |
| 70 | + /> |
| 71 | + <div className='my-auto inline font-bold uppercase '>Up Next</div> |
| 72 | + </div> |
| 73 | + <div className='my-2 text-base font-medium text-slate-600 dark:text-slate-300'> |
| 74 | + {nextLabel} |
| 75 | + </div> |
| 76 | + </Link> |
42 | 77 | </div>
|
43 | 78 | </div>
|
44 | 79 | </div>
|
|
0 commit comments