Skip to content

Commit b1847f0

Browse files
committed
add DoNotLike tag page and link in myTags
1 parent 4af0222 commit b1847f0

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

explorer/components/DrawingPage/DrawingPage.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
DateLink,
1717
TagList,
1818
Tag,
19+
MyTagListHeading,
1920
} from './styles'
2021
import { getPreviousSlug, getNextSlug } from '../../lib/drawings'
2122
import { useRouter } from 'next/router'
@@ -57,15 +58,20 @@ export const DrawingPage: React.FC<{ drawing: Drawing, year: number }> = ({ draw
5758
{tags.length > 0 && (
5859
<TagList>
5960
{tags.map(tag => (
60-
<Tag key={tag}>
61-
<Link href='/tag/[id]' as={`/tag/${getTagSlug(tag)}`}>
62-
<a>{tag}</a>
63-
</Link>
64-
</Tag>
61+
<Tag key={tag}><Link href={`/tag/${getTagSlug(tag)}`}><a>{tag}</a></Link></Tag>
6562
))}
6663
</TagList>
6764
)}
68-
{myTags.length > 0 && <TagList>{myTags.map(tag => <Tag key={tag}>{tag}</Tag>)}</TagList>}
65+
{myTags.length > 0 && (
66+
<>
67+
<MyTagListHeading>myTags</MyTagListHeading>
68+
<TagList>
69+
{myTags.map(tag => (
70+
<Tag key={tag}><Link href={`/tag/${getTagSlug(tag)}`}><a>{tag}</a></Link></Tag>
71+
))}
72+
</TagList>
73+
</>
74+
)}
6975
<NavBar>
7076
<Link href="/drawing/[id]" as={`/drawing/${getPreviousSlug(drawing.slug)}`}>
7177
<ArrowButton title='Previous'><LeftArrow /></ArrowButton>

explorer/components/DrawingPage/styles.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,11 @@ export const Tag = styled.li.attrs({ classNames: 'Explorer__DrawingPage__Tag'})`
114114
display: none;
115115
}
116116
`
117+
118+
export const MyTagListHeading = styled.h5.attrs({ className: 'Explorer__DrawingPage__MyTagListHeding' })`
119+
font-size: 10px;
120+
font-weight: 200;
121+
margin: -2px 0 -4px;
122+
text-align: center;
123+
opacity: 0.2;
124+
`

explorer/lib/tags.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import { Drawing, TagDrawingSets } from '../types'
2-
import {
3-
tagDrawingSets as fixtureTagDrawingSets,
4-
tags as fixtureTags,
5-
} from '../__fixtures__'
2+
import { allTags, tagDrawingSets, tags } from '../__fixtures__'
63

74
export function getTagsForDrawing(drawing: Drawing): string[] {
8-
return fixtureTags.filter(tag => drawingHasTag(drawing, tag))
5+
return tags.filter(tag => drawingHasTag(drawing, tag))
96
}
107

118
export function drawingHasTag(drawing: Drawing, tag: string): boolean {
12-
const drawings: Drawing[] = fixtureTagDrawingSets[tag] ?? []
9+
const drawings: Drawing[] = tagDrawingSets[tag] ?? []
1310
return drawings.some(o => o.id === drawing.id)
1411
}
1512

@@ -30,5 +27,5 @@ export function getTagSlug(tag: string): string {
3027
}
3128

3229
export function getTagFromSlug(slug: string): string | undefined {
33-
return fixtureTags.find(tag => getTagSlug(tag) === slug)
30+
return allTags.find(tag => getTagSlug(tag) === slug)
3431
}

explorer/pages/tag/[id].tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { TagPage } from '../../components/TagPage'
22
import { GetStaticProps, GetStaticPaths } from 'next'
3-
import { tags } from '../../__fixtures__'
3+
import { allTags } from '../../__fixtures__'
44
import { singleQueryParamValue } from '../../lib/next'
55
import { getTagSlug, getTagFromSlug } from '../../lib/tags'
66

77
export default TagPage
88

99
export const getStaticPaths: GetStaticPaths = async () => {
10-
const paths = tags.map(tag => ({ params: { id: getTagSlug(tag) }}))
10+
const paths = allTags.map(tag => ({ params: { id: getTagSlug(tag) }}))
1111
return { paths, fallback: false }
1212
}
1313

0 commit comments

Comments
 (0)