Skip to content

Commit 06a14bb

Browse files
committed
Add Glossary
1 parent 99ed1de commit 06a14bb

File tree

6 files changed

+138
-0
lines changed

6 files changed

+138
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "Vulnerability Disclosure"
3+
path: "/glossary/vulnerability-disclosure"
4+
---
5+
6+
Example text

gatsby-node.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exports.createPages = ({ boundActionCreators, graphql }) => {
66
const programsTemplate = path.resolve('./src/templates/programs.js');
77
const hackersTemplate = path.resolve('./src/templates/hackers.js');
88
const changelogTemplate = path.resolve('./src/templates/changelog.js');
9+
const glossaryTemplate = path.resolve('./src/templates/glossary.js');
910

1011
return graphql(`
1112
{
@@ -37,6 +38,8 @@ exports.createPages = ({ boundActionCreators, graphql }) => {
3738
template = hackersTemplate;
3839
} else if (node.frontmatter.path.includes("/changelog")) {
3940
template = changelogTemplate;
41+
} else if (node.frontmatter.path.includes("/glossary")) {
42+
template = glossaryTemplate;
4043
}
4144

4245
createPage({

src/components/navigation/navigation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default ({ pathname }) => {
3333
<ul className="navigation__list">
3434
<NavItem linkTo="/hackers.html" title="Hackers" />
3535
<NavItem linkTo="/programs.html" title="Programs" />
36+
<NavItem linkTo="/glossary" title="Glossary" />
3637
<li className="navigation__item">
3738
<a
3839
className="navigation__link"

src/pages/glossary/glossary.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@import '../../css/variables';
2+
3+
.glossary {
4+
h4 {
5+
margin-bottom: 0;
6+
}
7+
}
8+
9+
.glossary__wrapper {
10+
border-top: 1px solid $daisy-whisper;
11+
padding-top: 24px;
12+
position: relative;
13+
}
14+
15+
.glossary__anchor {
16+
position: absolute;
17+
top: -60px;
18+
left: 0;
19+
height: 1px;
20+
width: 1px;
21+
}

src/pages/glossary/index.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import React from 'react'
2+
import Helmet from 'react-helmet'
3+
import Link from 'gatsby-link'
4+
import slugify from 'slugify'
5+
import GatsbyConfig from '../../../gatsby-config'
6+
7+
import './glossary.scss'
8+
9+
class IndexRoute extends React.Component {
10+
render() {
11+
const { edges } = this.props.data.allMarkdownRemark
12+
13+
return (
14+
<div className="glossary article">
15+
<Helmet title={`Glossary | ${GatsbyConfig.siteMetadata.title}`} />
16+
<div className="sidebar">
17+
<div className="sidebar__wrapper">
18+
<div className="sidebar__body">
19+
<ul className="sidebar__items sidebar__items--active">
20+
{edges.map((item, index) => {
21+
return (
22+
<li className="sidebar__item">
23+
<a href={`#${slugify(item.node.frontmatter.path)}`}>
24+
{item.node.frontmatter.title}
25+
</a>
26+
</li>
27+
)
28+
})}
29+
</ul>
30+
</div>
31+
</div>
32+
</div>
33+
34+
<div className="article__inner">
35+
<h1>Changelog</h1>
36+
<p>
37+
See what's changed or new in HackerOne.
38+
</p>
39+
{edges.map((item, index) => {
40+
return (
41+
<div className="glossary__wrapper">
42+
<div
43+
className="glossary__anchor"
44+
id={slugify(item.node.frontmatter.path)}
45+
/>
46+
<h2>{item.node.frontmatter.title}</h2>
47+
<div dangerouslySetInnerHTML={{ __html: item.node.html }} />
48+
</div>
49+
)
50+
})}
51+
</div>
52+
</div>
53+
)
54+
}
55+
}
56+
57+
export default IndexRoute
58+
59+
export const pageQuery = graphql`
60+
query glossaryIndexQuery {
61+
allMarkdownRemark(
62+
filter: { frontmatter: { path: { regex: "/glossary/" } } }
63+
sort: { order: DESC, fields: [frontmatter___date] }
64+
limit: 1000
65+
) {
66+
edges {
67+
node {
68+
html
69+
frontmatter {
70+
path
71+
title
72+
date
73+
}
74+
}
75+
}
76+
}
77+
}
78+
`

src/templates/glossary.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react'
2+
import Helmet from 'react-helmet'
3+
import Link from 'gatsby-link'
4+
import GatsbyConfig from '../../gatsby-config'
5+
6+
export default function Template({ data }) {
7+
const { markdownRemark } = data
8+
return (
9+
<div className="article">
10+
<Helmet title={`${markdownRemark.frontmatter.title} | ${GatsbyConfig.siteMetadata.title}`} />
11+
<div>
12+
<h1>{markdownRemark.frontmatter.title}</h1>
13+
<div dangerouslySetInnerHTML={{ __html: markdownRemark.html }} />
14+
</div>
15+
</div>
16+
)
17+
}
18+
19+
export const pageQuery = graphql`
20+
query GlossaryByPath($path: String!) {
21+
markdownRemark(frontmatter: { path: { eq: $path } }) {
22+
html
23+
frontmatter {
24+
path
25+
title
26+
}
27+
}
28+
}
29+
`

0 commit comments

Comments
 (0)