Skip to content

Commit

Permalink
Merge pull request #64 from fabmob/imaginaires-tag
Browse files Browse the repository at this point in the history
Imaginaires tag
  • Loading branch information
laem authored Apr 8, 2021
2 parents 1cf511c + 271b1e2 commit cce9a8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 12 additions & 2 deletions code/Articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ const Header = () => (
)
export default ({ year }) => {
let year2 = year || useParams().year
let tag = useParams().tag
return (
<div>
<Header />
<section>
<YearMenu year2={year2} />
<Link
to="/tag/imaginaires"
to="/blog/tag/imaginaires"
css={`
background: ${couleurImaginaires};
color: white;
Expand Down Expand Up @@ -96,7 +97,16 @@ export default ({ year }) => {
? -1
: 1
)
.filter((a) => new Date(a.attributes.date).getFullYear() == year2)
.filter((a) => {
const date = a.attributes.date,
goodDate = new Date(date).getFullYear() == year2

const tags = a.attributes.tags || [],
goodTag = tags.includes(tag)

return tag ? goodTag : !tags.includes('imaginaires') && goodDate
})

.map((a) => (
<li key={a.id}>
<ArticleVignette {...a} />
Expand Down
3 changes: 3 additions & 0 deletions code/Blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export default ({}) => (
<Route path="/blog/année/:year">
<Articles />
</Route>
<Route path="/blog/tag/:tag">
<Articles />
</Route>
<Route path="/blog/">
<Articles year="2021" />
</Route>
Expand Down

0 comments on commit cce9a8d

Please sign in to comment.