1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2025-02-14 21:10:41 +01:00

package updates, put StaticQuery queries into variables

This commit is contained in:
Matthias Kretschmann 2018-09-06 11:34:50 +02:00
parent fe64ed75cb
commit 593a4bd26d
Signed by: m
GPG Key ID: 606EEEF3C479A91F
13 changed files with 166 additions and 153 deletions

View File

@ -1,5 +0,0 @@
version: "2"
checks:
method-lines:
config:
threshold: 50 # Gatsby's StaticQuery makes render functions pretty long

View File

@ -21,11 +21,11 @@
}, },
"dependencies": { "dependencies": {
"file-saver": "^1.3.8", "file-saver": "^1.3.8",
"gatsby": "^2.0.0-rc.11", "gatsby": "^2.0.0-rc.13",
"gatsby-image": "^2.0.0-rc.1", "gatsby-image": "^2.0.0-rc.1",
"gatsby-plugin-manifest": "^2.0.2-rc.1", "gatsby-plugin-manifest": "^2.0.2-rc.1",
"gatsby-plugin-matomo": "^0.5.0", "gatsby-plugin-matomo": "^0.5.0",
"gatsby-plugin-offline": "^2.0.0-rc.3", "gatsby-plugin-offline": "^2.0.0-rc.4",
"gatsby-plugin-react-helmet": "^3.0.0-rc.1", "gatsby-plugin-react-helmet": "^3.0.0-rc.1",
"gatsby-plugin-sass": "^2.0.0-rc.2", "gatsby-plugin-sass": "^2.0.0-rc.2",
"gatsby-plugin-sharp": "^2.0.0-rc.3", "gatsby-plugin-sharp": "^2.0.0-rc.3",

View File

@ -4,6 +4,15 @@ import { StaticQuery, graphql } from 'gatsby'
import Logo from '../svg/Logo' import Logo from '../svg/Logo'
import styles from './LogoUnit.module.scss' import styles from './LogoUnit.module.scss'
const query = graphql`
query {
dataYaml {
title
tagline
}
}
`
class LogoUnit extends PureComponent { class LogoUnit extends PureComponent {
constructor(props) { constructor(props) {
super(props) super(props)
@ -28,14 +37,7 @@ class LogoUnit extends PureComponent {
render() { render() {
return ( return (
<StaticQuery <StaticQuery
query={graphql` query={query}
query {
dataYaml {
title
tagline
}
}
`}
render={data => { render={data => {
const meta = data.dataYaml const meta = data.dataYaml
const { minimal } = this.state const { minimal } = this.state

View File

@ -15,35 +15,37 @@ function truncate(n, useWordBoundary) {
) )
} }
const SEO = ({ project }) => ( const query = graphql`
<StaticQuery query {
query={graphql` dataYaml {
query { title
dataYaml { tagline
title description
tagline url
description email
url img {
email childImageSharp {
img { resize(width: 980) {
childImageSharp { src
resize(width: 980) {
src
}
}
} }
social {
Email
Blog
Twitter
GitHub
Dribbble
}
gpg
addressbook
} }
} }
`} social {
Email
Blog
Twitter
GitHub
Dribbble
}
gpg
addressbook
}
}
`
const SEO = ({ project }) => (
<StaticQuery
query={query}
render={data => { render={data => {
const meta = data.dataYaml const meta = data.dataYaml

View File

@ -17,15 +17,17 @@ const TypekitScript = typekitID => (
</script> </script>
) )
const query = graphql`
query {
dataYaml {
typekitID
}
}
`
const Typekit = () => ( const Typekit = () => (
<StaticQuery <StaticQuery
query={graphql` query={query}
query {
dataYaml {
typekitID
}
}
`}
render={data => { render={data => {
const { typekitID } = data.dataYaml const { typekitID } = data.dataYaml

View File

@ -3,35 +3,37 @@ import { StaticQuery, graphql } from 'gatsby'
import FileSaver from 'file-saver' import FileSaver from 'file-saver'
import vCard from 'vcf' import vCard from 'vcf'
const Vcard = () => ( const query = graphql`
<StaticQuery query {
query={graphql` dataYaml {
query { title
dataYaml { tagline
title description
tagline url
description email
url avatar {
email childImageSharp {
avatar { original: resize {
childImageSharp { src
original: resize {
src
}
}
} }
social {
Email
Blog
Twitter
GitHub
Dribbble
}
gpg
addressbook
} }
} }
`} social {
Email
Blog
Twitter
GitHub
Dribbble
}
gpg
addressbook
}
}
`
const Vcard = () => (
<StaticQuery
query={query}
render={data => { render={data => {
const meta = data.dataYaml const meta = data.dataYaml

View File

@ -4,6 +4,18 @@ import { StaticQuery, graphql } from 'gatsby'
import { MoveIn } from '../atoms/Animations' import { MoveIn } from '../atoms/Animations'
import styles from './Availability.module.scss' import styles from './Availability.module.scss'
const query = graphql`
query {
dataYaml {
availability {
status
available
unavailable
}
}
}
`
class Availability extends PureComponent { class Availability extends PureComponent {
constructor(props) { constructor(props) {
super(props) super(props)
@ -12,17 +24,7 @@ class Availability extends PureComponent {
render() { render() {
return ( return (
<StaticQuery <StaticQuery
query={graphql` query={query}
query {
dataYaml {
availability {
status
available
unavailable
}
}
}
`}
render={data => { render={data => {
const { availability } = data.dataYaml const { availability } = data.dataYaml
const { status, available, unavailable } = availability const { status, available, unavailable } = availability

View File

@ -4,16 +4,18 @@ import { StaticQuery, graphql } from 'gatsby'
import SEO from '../atoms/SEO' import SEO from '../atoms/SEO'
import Typekit from '../atoms/Typekit' import Typekit from '../atoms/Typekit'
const query = graphql`
query {
dataYaml {
title
tagline
}
}
`
const Head = () => ( const Head = () => (
<StaticQuery <StaticQuery
query={graphql` query={query}
query {
dataYaml {
title
tagline
}
}
`}
render={data => { render={data => {
const { title, tagline } = data.dataYaml const { title, tagline } = data.dataYaml

View File

@ -12,6 +12,20 @@ import Dribbble from '../svg/Dribbble'
import icons from '../atoms/Icons.module.scss' import icons from '../atoms/Icons.module.scss'
import styles from './Networks.module.scss' import styles from './Networks.module.scss'
const query = graphql`
query {
dataYaml {
social {
Email
Blog
Twitter
GitHub
Dribbble
}
}
}
`
const NetworkIcon = props => { const NetworkIcon = props => {
switch (props.title) { switch (props.title) {
case 'Email': case 'Email':
@ -57,19 +71,7 @@ class Network extends PureComponent {
render() { render() {
return ( return (
<StaticQuery <StaticQuery
query={graphql` query={query}
query {
dataYaml {
social {
Email
Blog
Twitter
GitHub
Dribbble
}
}
}
`}
render={data => { render={data => {
const meta = data.dataYaml const meta = data.dataYaml

View File

@ -5,6 +5,26 @@ import Img from 'gatsby-image'
import FullWidth from '../atoms/FullWidth' import FullWidth from '../atoms/FullWidth'
import styles from './ProjectNav.module.scss' import styles from './ProjectNav.module.scss'
const query = graphql`
query {
allProjectsYaml {
edges {
node {
title
slug
img {
childImageSharp {
fluid(maxWidth: 500, quality: 85) {
...GatsbyImageSharpFluid_noBase64
}
}
}
}
}
}
}
`
const ProjectLink = ({ node }) => ( const ProjectLink = ({ node }) => (
<Link className={styles.link} to={node.slug}> <Link className={styles.link} to={node.slug}>
<Img <Img
@ -54,25 +74,7 @@ class ProjectNav extends Component {
return ( return (
<StaticQuery <StaticQuery
query={graphql` query={query}
query {
allProjectsYaml {
edges {
node {
title
slug
img {
childImageSharp {
fluid(maxWidth: 500, quality: 85) {
...GatsbyImageSharpFluid_noBase64
}
}
}
}
}
}
}
`}
render={data => { render={data => {
const projects = data.allProjectsYaml.edges const projects = data.allProjectsYaml.edges

View File

@ -5,6 +5,23 @@ import LogoUnit from '../atoms/LogoUnit'
import Networks from '../molecules/Networks' import Networks from '../molecules/Networks'
import styles from './Footer.module.scss' import styles from './Footer.module.scss'
const query = graphql`
query {
# the package.json file
portfolioJson {
name
homepage
repository
bugs
}
dataYaml {
title
gpg
}
}
`
class Footer extends PureComponent { class Footer extends PureComponent {
constructor(props) { constructor(props) {
super(props) super(props)
@ -15,22 +32,7 @@ class Footer extends PureComponent {
render() { render() {
return ( return (
<StaticQuery <StaticQuery
query={graphql` query={query}
query {
# the package.json file
portfolioJson {
name
homepage
repository
bugs
}
dataYaml {
title
gpg
}
}
`}
render={data => { render={data => {
const pkg = data.portfolioJson const pkg = data.portfolioJson
const meta = data.dataYaml const meta = data.dataYaml

View File

@ -7,6 +7,16 @@ import ThemeSwitch from '../molecules/ThemeSwitch'
import LogoUnit from '../atoms/LogoUnit' import LogoUnit from '../atoms/LogoUnit'
import styles from './Header.module.scss' import styles from './Header.module.scss'
const query = graphql`
query {
dataYaml {
availability {
status
}
}
}
`
class Header extends PureComponent { class Header extends PureComponent {
constructor(props) { constructor(props) {
super(props) super(props)
@ -34,15 +44,7 @@ class Header extends PureComponent {
return ( return (
<StaticQuery <StaticQuery
query={graphql` query={query}
query {
dataYaml {
availability {
status
}
}
}
`}
render={data => { render={data => {
const meta = data.dataYaml const meta = data.dataYaml

View File

@ -16,8 +16,6 @@ class NotFound extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { gif: '' } this.state = { gif: '' }
this.handleClick = this.handleClick.bind(this)
} }
componentDidMount() { componentDidMount() {
@ -36,7 +34,7 @@ class NotFound extends Component {
}) })
} }
handleClick(e) { handleClick = e => {
e.preventDefault() e.preventDefault()
this.getRandomGif() this.getRandomGif()
} }