-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e72c55
commit ca2df06
Showing
17 changed files
with
180 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from "react" | ||
import {Link} from "gatsby" | ||
import PropType from "prop-types" | ||
|
||
const Tags = ({tags}) => { | ||
return ( | ||
<ul> | ||
{tags.map((tag, index) => { | ||
return ( | ||
<li key={index}> | ||
<Link to={`/tags/${tag}`}>{tag}</Link> | ||
</li> | ||
) | ||
})} | ||
</ul> | ||
) | ||
} | ||
|
||
Tags.propTypes = { | ||
tags: PropType.arrayOf(PropType.string).isRequired, | ||
} | ||
|
||
export default Tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {useStaticQuery, graphql} from "gatsby" | ||
|
||
const useTags = ({limit = 0} = {}) => { | ||
const query = graphql` | ||
{ | ||
allMarkdownRemark( | ||
filter: {fileAbsolutePath: {regex: "/content/posts/"}} | ||
) { | ||
group(field: frontmatter___tags) { | ||
fieldValue | ||
} | ||
} | ||
} | ||
` | ||
|
||
const data = useStaticQuery(query) | ||
|
||
let tags = data.allMarkdownRemark.group.map(member => member.fieldValue) | ||
|
||
if (limit) { | ||
tags = tags.slice(0, limit) | ||
} | ||
|
||
return tags | ||
} | ||
|
||
export default useTags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from "react" | ||
import {useTags} from "../hooks" | ||
import Tags from "../components/Tags" | ||
import Container from "../styles/Container" | ||
import {Meta, Twitter, Facebook} from "../components/SEO" | ||
|
||
const TagsPage = () => { | ||
const tags = useTags() | ||
|
||
return ( | ||
<Container> | ||
<Meta title="blog" /> | ||
<Facebook /> | ||
<Twitter /> | ||
|
||
<h1>tags</h1> | ||
<Tags tags={tags} /> | ||
</Container> | ||
) | ||
} | ||
|
||
export default TagsPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from "react" | ||
import {graphql} from "gatsby" | ||
import PropTypes from "prop-types" | ||
import Posts from "../components/Posts" | ||
import Container from "../styles/Container" | ||
import {Meta, Twitter, Facebook} from "../components/SEO" | ||
|
||
const TagTemplate = ({data, pageContext}) => { | ||
const {tag} = pageContext | ||
const posts = data.allMarkdownRemark.nodes | ||
|
||
return ( | ||
<Container> | ||
<Meta title="post" /> | ||
<Facebook /> | ||
<Twitter /> | ||
|
||
<h1>tag: {tag}</h1> | ||
<Posts posts={posts} /> | ||
</Container> | ||
) | ||
} | ||
|
||
TagTemplate.propTypes = { | ||
data: PropTypes.object.isRequired, | ||
pageContext: PropTypes.object.isRequired, | ||
} | ||
|
||
const query = graphql` | ||
query($tag: [String]!) { | ||
allMarkdownRemark(filter: {frontmatter: {tags: {in: $tag}}}) { | ||
nodes { | ||
frontmatter { | ||
slug | ||
} | ||
} | ||
} | ||
} | ||
` | ||
|
||
export default TagTemplate | ||
export {query} |