|
| 1 | +import Image from 'next/image'; |
| 2 | +import React from 'react'; |
| 3 | +import Link from 'next/link'; |
| 4 | + |
| 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) { |
| 35 | + return ( |
| 36 | + <div className='mb-4 flex flex-row gap-4'> |
| 37 | + {prevURL && prevLabel ? ( |
| 38 | + <div className='h-auto w-1/2'> |
| 39 | + <div |
| 40 | + 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 |
| 41 | + lg:text-left' |
| 42 | + > |
| 43 | + <Link href={prevURL}> |
| 44 | + <div className='text-primary dark:text-slate-300 flex flex-row gap-5 text-[18px]'> |
| 45 | + <Image |
| 46 | + src={'/icons/arrow.svg'} |
| 47 | + height={10} |
| 48 | + width={10} |
| 49 | + alt='prev icon' |
| 50 | + className='rotate-180 w-5 ' |
| 51 | + /> |
| 52 | + <div className='my-auto inline font-bold uppercase'> |
| 53 | + Go Back |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + <div className='my-2 text-base font-medium text-slate-600 dark:text-slate-300'> |
| 57 | + {prevLabel} |
| 58 | + </div> |
| 59 | + </Link> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + ) : ( |
| 63 | + <div className='h-auto w-1/2'></div> |
| 64 | + )} |
| 65 | + |
| 66 | + {nextURL && nextLabel ? ( |
| 67 | + <div className='h-auto w-1/2'> |
| 68 | + <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'> |
| 69 | + <Link href={nextURL}> |
| 70 | + <div className='text-primary dark:text-slate-300 flex flex-row-reverse gap-5 text-[18px]'> |
| 71 | + <Image |
| 72 | + src={'/icons/arrow.svg'} |
| 73 | + height={10} |
| 74 | + width={10} |
| 75 | + alt='next icon ' |
| 76 | + className='w-5' |
| 77 | + /> |
| 78 | + <div className='my-auto inline font-bold uppercase '> |
| 79 | + Up Next |
| 80 | + </div> |
| 81 | + </div> |
| 82 | + <div className='my-2 text-base font-medium text-slate-600 dark:text-slate-300'> |
| 83 | + {nextLabel} |
| 84 | + </div> |
| 85 | + </Link> |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + ) : ( |
| 89 | + <div className='h-auto w-1/2'></div> |
| 90 | + )} |
| 91 | + </div> |
| 92 | + ); |
| 93 | +} |
0 commit comments