-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix multi render issue on breadcrumb
Finished breadcrumb (still not perfect but works) Cleanup
- Loading branch information
Marvin Heilemann
committed
Oct 2, 2019
1 parent
4047160
commit 785f2f6
Showing
29 changed files
with
198 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/_old | ||
/tmp | ||
.env.* | ||
|
||
# Logs | ||
logs | ||
|
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,8 @@ | ||
# Open issues that affect this project | ||
|
||
- [PostCss plugin is not executed when using Scss](#postcss-plugin-is-not-executed-when-using-scss) | ||
|
||
## PostCss plugin is not executed when using Scss | ||
|
||
- https://github.com/gatsbyjs/gatsby/issues/17887 | ||
- https://github.com/larsenwork/postcss-easing-gradients/issues/11 |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,71 +1,47 @@ | ||
import React, { useContext } from 'react' | ||
import { useStaticQuery, graphql, Link } from 'gatsby' | ||
import { GlobalContext } from '../context' | ||
import { Link } from 'gatsby' | ||
import { GlobalContext } from '@app/context' | ||
import { useSiteMetadata } from '@hooks/use-site-metadata' | ||
|
||
const Breadcrumb = ({ location: { pathname } }) => { | ||
const { | ||
site: { siteMetadata }, | ||
} = useStaticQuery(query) | ||
const siteMetadata = useSiteMetadata() | ||
const [state] = useContext(GlobalContext) | ||
|
||
const fragments = pathname.split('/') | ||
fragments.shift() | ||
fragments.pop() | ||
|
||
const menuLinks = siteMetadata.menuLinks | ||
// const menuLinks = [ | ||
// { | ||
// name: 'Projects', | ||
// link: '/projects', | ||
// }, | ||
// { | ||
// name: 'Demo', | ||
// link: '/projects/demo', | ||
// }, | ||
// ] | ||
|
||
console.log(state) | ||
console.log(menuLinks) | ||
console.log(fragments) | ||
|
||
const path = menuLinks.filter(({ name, link }) => { | ||
const path = menuLinks.filter(({ name, external }) => { | ||
if (external) return false // ignore | ||
const menuIndex = fragments.indexOf(name.toLowerCase()) | ||
if (menuIndex > -1) { | ||
const menu = menuLinks[menuIndex] | ||
console.log(menu) | ||
return menu | ||
return menuLinks[menuIndex] | ||
} | ||
return false | ||
}) | ||
|
||
console.log(path) | ||
console.log(path.length) | ||
|
||
return state.title ? ( | ||
<div id="back"> | ||
<span>/ </span> | ||
<div id="breadcrumb"> | ||
<span className="breadcrumb__divider" key="BCB"> | ||
/{' '} | ||
</span> | ||
{path.map(({ name, link }, index) => ( | ||
<> | ||
<Link to={link}>{name}</Link> | ||
{index < path.length ? <span> / </span> : ''} | ||
</> | ||
<span key={`BCI${index}`}> | ||
<Link to={link} className="breadcrumb__link"> | ||
{name} | ||
</Link> | ||
<span className="breadcrumb__divider"> | ||
{index < path.length ? ' / ' : null} | ||
</span> | ||
</span> | ||
))} | ||
<span>{state.title}</span> | ||
<span className="breadcrumb__active" key="BCA"> | ||
{state.title} | ||
</span> | ||
</div> | ||
) : null | ||
} | ||
|
||
const query = graphql` | ||
{ | ||
site { | ||
siteMetadata { | ||
menuLinks { | ||
name | ||
link | ||
} | ||
} | ||
} | ||
} | ||
` | ||
|
||
export default Breadcrumb |
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
File renamed without changes.
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,25 @@ | ||
import { useStaticQuery, graphql } from 'gatsby' | ||
|
||
export const useSiteMetadata = () => { | ||
const { site } = useStaticQuery( | ||
graphql` | ||
query SiteMetaData { | ||
site { | ||
siteMetadata { | ||
title | ||
author | ||
description | ||
siteUrl | ||
keywords | ||
menuLinks { | ||
name | ||
link | ||
} | ||
} | ||
} | ||
} | ||
` | ||
) | ||
|
||
return site.siteMetadata | ||
} |
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,39 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
export default function HTML(props) { | ||
return ( | ||
<html lang="en" {...props.htmlAttributes}> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta httpEquiv="x-ua-compatible" content="ie=edge" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover" | ||
/> | ||
{props.headComponents} | ||
</head> | ||
<body {...props.bodyAttributes}> | ||
{props.preBodyComponents} | ||
<noscript key="noscript" id="gatsby-noscript"> | ||
This app works best with JavaScript enabled. | ||
</noscript> | ||
<div | ||
key={`body`} | ||
id="___gatsby" | ||
dangerouslySetInnerHTML={{ __html: props.body }} | ||
/> | ||
{props.postBodyComponents} | ||
</body> | ||
</html> | ||
) | ||
} | ||
|
||
HTML.propTypes = { | ||
htmlAttributes: PropTypes.object, | ||
headComponents: PropTypes.array, | ||
bodyAttributes: PropTypes.object, | ||
preBodyComponents: PropTypes.array, | ||
body: PropTypes.string, | ||
postBodyComponents: PropTypes.array, | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.