Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | 10x 10x 5x 5x 10x 10x 5x 5x 10x 5x 10x 5x 5x 5x 5x 5x 5x 5x 5x 5x 50x | import React from "react"; import Link from "gatsby-link"; import lozad from "lozad"; import { isBrowser } from "@/utils"; import Card from "@/components/Card"; import Sidebar from "@/components/Sidebar"; import ShareBox from "@/components/ShareBox"; import * as style from "./index.module.scss"; import SEO from "@/components/SEO"; import config from "@/config/index.json"; const NavLinkText = ({ text, disabled = false, }: { text: string; disabled?: boolean; }) => { if (disabled) { return ( <div className={style.navlink + " " + style.disableLink} aria-disabled={true} > {text} </div> ); } else { return <div className={style.navlink + " " + style.activeLink}>{text}</div>; } }; const NavLink = ({ test, url, text, }: { test: boolean; url: string; text: string; }) => { if (!test) { return <NavLinkText text={text} disabled={true} />; } return ( <Link to={`${url}`}> <NavLinkText text={text} disabled={false} /> </Link> ); }; const PageNum = ({ page, all }: { page: number; all: number }) => ( <div className={style.pagenum}> {page}/{all} </div> ); type PageContext = { group: ReadonlyArray<GatsbyTypes.MarkdownRemarkEdge>; index: number; first: boolean; last: boolean; pathPrefix: string; pageCount: number; }; const Page = ({ pageContext, location, }: { pageContext: PageContext; location: Location; }) => { const { group, index, first, last, pathPrefix, pageCount } = pageContext; React.useEffect(() => { Eif (isBrowser()) { const observer = lozad(".lozad", { loaded(el) { el.classList.add("loaded"); }, }); observer.observe(); } }, []); const previousUrl = index - 1 === 1 ? "/" : `/${pathPrefix}/${index - 1}`; const nextUrl = `/${pathPrefix}/${index + 1}`; return ( <> <div className={style.rowHomepage + " row homepage"}> <Sidebar /> <main className="col-xl-6 col-lg-7 col-md-12 col-xs-12 order-2"> {group.map(({ node }, num) => ( <Card {...node.frontmatter} title={node.frontmatter?.title || ""} date={node.frontmatter?.date || ""} headerImage={node.frontmatter?.headerImage || ""} description={node.frontmatter?.description || ""} tags={node.frontmatter?.tags || []} url={ node.frontmatter?.slug ? node.frontmatter.slug : node.fields?.slug || "" } key={node.fields?.slug} index={num} /> ))} <div className={style.rowPager + " row pager"}> <div> <NavLink test={!first} url={previousUrl} text="Previous" /> </div> <div> <PageNum page={index} all={pageCount} /> </div> <div> <NavLink test={!last} url={nextUrl} text="Next" /> </div> </div> </main> <div className="col-xl-2 col-lg-1 order-3" /> </div> <ShareBox url={config.siteUrl + String(location.pathname)} hasCommentBox={false} /> <SEO title={config.siteTitle} url={config.siteUrl} siteTitleAlt={config.siteTitle} isPost={false} description={config.description} tag="" image={config.defaultImage} /> </> ); }; export default Page; |