mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-22 18:00:06 +01:00
manual menu
This commit is contained in:
parent
f1cfb20d27
commit
f12cb6d1d9
5
content/menu.yml
Normal file
5
content/menu.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
- title: Photos
|
||||||
|
link: /photos
|
||||||
|
|
||||||
|
- title: Goodies
|
||||||
|
link: /tag/goodies
|
@ -6,12 +6,11 @@ import styles from './Menu.module.scss'
|
|||||||
|
|
||||||
const query = graphql`
|
const query = graphql`
|
||||||
query {
|
query {
|
||||||
allMarkdownRemark(sort: { fields: [fields___date], order: DESC }) {
|
allMenuYaml {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
frontmatter {
|
title
|
||||||
type
|
link
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,21 +39,12 @@ export default class Menu extends PureComponent {
|
|||||||
<StaticQuery
|
<StaticQuery
|
||||||
query={query}
|
query={query}
|
||||||
render={data => {
|
render={data => {
|
||||||
const posts = data.allMarkdownRemark.edges
|
const { edges } = data.allMenuYaml
|
||||||
const typeSet = new Set()
|
|
||||||
|
|
||||||
posts.forEach(post => {
|
const MenuItems = edges.map(({ node }) => (
|
||||||
if (post.node.frontmatter.type) {
|
<li key={node.title}>
|
||||||
typeSet.add(post.node.frontmatter.type)
|
<Link onClick={this.toggleMenu} to={node.link}>
|
||||||
}
|
{node.title}
|
||||||
})
|
|
||||||
|
|
||||||
const typeList = Array.from(typeSet)
|
|
||||||
|
|
||||||
const Types = typeList.map(type => (
|
|
||||||
<li key={type}>
|
|
||||||
<Link onClick={this.toggleMenu} to={`/${type}s/`}>
|
|
||||||
{type}s
|
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))
|
))
|
||||||
@ -62,7 +52,7 @@ export default class Menu extends PureComponent {
|
|||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Hamburger onClick={this.toggleMenu} />
|
<Hamburger onClick={this.toggleMenu} />
|
||||||
<ul className={styles.menu}>{Types}</ul>
|
<ul className={styles.menu}>{MenuItems}</ul>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
|
@ -2,11 +2,16 @@
|
|||||||
@import 'mixins';
|
@import 'mixins';
|
||||||
|
|
||||||
.menu {
|
.menu {
|
||||||
|
@include divider-top;
|
||||||
|
|
||||||
|
margin-top: 0;
|
||||||
|
padding-top: $spacer / 2;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(100% + #{$spacer});
|
top: calc(100% + #{$spacer / 2});
|
||||||
left: 0;
|
left: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
li {
|
li {
|
||||||
|
Loading…
Reference in New Issue
Block a user