feat: blog improves

This commit is contained in:
Nazareno Oviedo 2022-04-20 13:06:43 -03:00
parent 445e067d15
commit d5243f5f13
7 changed files with 27 additions and 23 deletions

View File

@ -21,7 +21,14 @@ const HeaderMobile = React.forwardRef<
>(({ className, ...props }, ref) => {
const router = useRouter()
const isActive = (href: string) => router.pathname === href
const isActive = (href: string) => {
const slug = router.query.slug as string
if (slug) {
return router.pathname.replace('/[slug]', '') === href
} else {
return router.pathname === href
}
}
return (
<div {...props} className={clsx(s['header__mobile'], className)} ref={ref}>
<ul className="items">
@ -69,7 +76,14 @@ export const Header = () => {
const router = useRouter()
const [ref, bounds] = useMeasure()
const isActive = (href: string) => router.pathname === href
const isActive = (href: string) => {
const slug = router.query.slug as string
if (slug) {
return router.pathname.replace('/[slug]', '') === href
} else {
return router.pathname === href
}
}
React.useEffect(() => {
const handleRouteChange = () => {

View File

@ -14,7 +14,7 @@ interface HeroProps {
const Hero = ({ data }: HeroProps) => {
return (
<Section className={s['section']}>
<Section className={s['section']} disableFadeIn>
<span className={s.date}>{formatDate(data.date)}</span>
<Heading as="h1" variant="xl" centered>
{data.title}

View File

@ -30,7 +30,7 @@ export const getStaticProps = async () => {
heroBlogPost
} ?? null
},
revalidate: 1
revalidate: 60
}
}

View File

@ -18,34 +18,26 @@ import Related from '~/components/sections/about/related'
import Content from '~/components/sections/blog/post-content'
import Hero from '~/components/sections/blog/post-hero'
import Shares from '~/components/sections/blog/shares'
import { siteOrigin } from '~/lib/constants'
const BlogPost = ({
latestPosts,
post
}: InferGetStaticPropsType<typeof getStaticProps>) => {
const router = useRouter()
const completeUrl = `${siteOrigin}${router.asPath}`
if (!post) {
return <Error statusCode={404} />
}
const router = useRouter()
// `${location.origin}${router.asPath}`
const completeUrl = `https://laconic.com${router.asPath}`
return (
<PageLayout>
<Meta />
<Hero data={post} />
<Content data={post} />
<Shares url={completeUrl} />
{/* <PostsGrid title="Related articles">
{latestPosts.map((relatedPost: BlogPostFragment, index: Key) => {
return (
<div key={index}>
<BlogCard data={relatedPost} />
</div>
)
})}
</PostsGrid> */}
<Related isInPost data={latestPosts} />
</PageLayout>
)
@ -83,7 +75,7 @@ export const getStaticProps: GetStaticProps = async (
latestPosts: relatedPosts.slice(0, 3),
post: post
},
revalidate: 1
revalidate: 60
}
} catch (error) {
return { notFound: true }

View File

@ -192,7 +192,7 @@ export const getStaticProps = async () => {
heroBlogPost
} ?? null
},
revalidate: 1
revalidate: 60
}
}

View File

@ -31,7 +31,7 @@ export const getStaticProps = async () => {
heroBlogPost
} ?? null
},
revalidate: 1
revalidate: 60
}
}

View File

@ -12,7 +12,6 @@ import Hero from '~/components/sections/products/hero'
import Network from '~/components/sections/products/network'
import Stack from '~/components/sections/products/stack'
import Token from '~/components/sections/products/token'
// import Partners from '~/components/sections/products/partners'
import Watchers from '~/components/sections/products/watchers'
export const getStaticProps = async () => {
@ -35,7 +34,7 @@ export const getStaticProps = async () => {
heroBlogPost
} ?? null
},
revalidate: 1
revalidate: 60
}
}
@ -52,7 +51,6 @@ const Products = ({
<AppSection />
<Token />
<Related data={initialBlogPosts?.data} />
{/* <Partners /> */}
</PageLayout>
)
}