Skip to content

Commit

Permalink
feat: link to a pre-fixed tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Won committed Sep 12, 2020
1 parent fc16351 commit efe5497
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/components/Reference.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import * as React from 'react';
import { Link, Text } from '@chakra-ui/core';
import NextLink from 'next/link';
import { resolveHref } from 'next/dist/next-server/lib/router/router';

export interface IReferenceProps {
children?;
link?: ILink;
}

export interface ILink {
href: string;
query?: { [any: string]: string };
external?: boolean;
}

export default function Reference({ children, link }: IReferenceProps) {
const color = 'blue.500';

return link ? (
link.external ? (
<Link
href={link.href}
href={link.href ? link.href : link.href}
fontWeight="semibold"
color={color}
textDecoration="underline"
>
{children}
</Link>
) : (
<NextLink href={link.href}>
<NextLink href={{ pathname: link.href, query: link.query }}>
<Link fontWeight="semibold" color={color} textDecoration="underline">
{children}
</Link>
Expand Down
11 changes: 8 additions & 3 deletions src/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export default function Home(props: IHomeProps) {
Hello world!
</Heading>

<Text>
<Box>
I'm <Reference>Tim</Reference> and welcome to my site.
</Text>
</Box>
</Flex>
</Flex>
<Divider my="2rem" backgroundColor="gray" width="100%" />
Expand Down Expand Up @@ -103,7 +103,12 @@ export default function Home(props: IHomeProps) {
</Heading>
<Text fontSize="sm">
A bunch of new things centered around well-being, learning, and{' '}
<Reference link={{ href: '/blog' }}>creating things</Reference>.
<Reference
link={{ href: '/blog', query: { tags: 'projects' } }}
>
creating things
</Reference>
.
</Text>
</Box>
</Flex>
Expand Down

0 comments on commit efe5497

Please sign in to comment.