diff --git a/gatsby-config.js b/gatsby-config.js index 2364d82..d058e69 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -55,6 +55,12 @@ module.exports = { 'gatsby-plugin-catch-links', 'gatsby-plugin-sharp', 'gatsby-transformer-sharp', + { + resolve: 'gatsby-plugin-canonical-urls', + options: { + siteUrl: 'https://studentersamfundet.no', + }, + }, // { // resolve: 'gatsby-plugin-purgecss', // options: { diff --git a/package.json b/package.json index 92c34d3..3323ac1 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "gatsby": "^2.13.31", "gatsby-awesome-pagination": "^0.3.3", "gatsby-image": "^2.2.6", + "gatsby-plugin-canonical-urls": "^2.1.10", "gatsby-plugin-catch-links": "^2.1.2", "gatsby-plugin-google-analytics": "^2.1.6", "gatsby-plugin-lodash": "^3.0.1", diff --git a/src/components/Meta.js b/src/components/Meta.js index af93f6f..e10d387 100644 --- a/src/components/Meta.js +++ b/src/components/Meta.js @@ -2,31 +2,26 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Helmet } from 'react-helmet'; -const Meta = ({ title, description, image, pathname, article }) => { - const imageUrl = image && image.localFile && image.localFile.url - const meta = { - title: title, - description: description, - image: imageUrl, - url: pathname, - } +const Meta = props => { + const { title, description, article, pathname: url, image: imageObj } = props + const image = imageObj && imageObj.localFile && imageObj.localFile.url return ( - {meta.description && } - {meta.image && } - {meta.url && } + {description && } + {image && } + {url && } {(article ? true : null) && ( )} - {meta.title && } - {meta.description && ( - + {title && } + {description && ( + )} - {meta.image && } + {image && } ) } diff --git a/yarn.lock b/yarn.lock index 7eb5564..552ce43 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5664,6 +5664,13 @@ gatsby-page-utils@^0.0.24: micromatch "^3.1.10" slash "^3.0.0" +gatsby-plugin-canonical-urls@^2.1.10: + version "2.1.10" + resolved "https://registry.yarnpkg.com/gatsby-plugin-canonical-urls/-/gatsby-plugin-canonical-urls-2.1.10.tgz#39221ae3741a5bf9def45cbc2d9710582e12381a" + integrity sha512-STSaQcZTAj1xtT1/1q/ujfyq481BCpX89h+beQ+X/+Jr76eIk6y0r7IwwANIzGnParx++OGan2gBi3CStIS8YQ== + dependencies: + "@babel/runtime" "^7.6.2" + gatsby-plugin-catch-links@^2.1.2: version "2.1.12" resolved "https://registry.yarnpkg.com/gatsby-plugin-catch-links/-/gatsby-plugin-catch-links-2.1.12.tgz#aaf55c1387f6ee4e3afdc808879b9ff11fe57dc2"