Skip to content

Commit

Permalink
Fix seo
Browse files Browse the repository at this point in the history
- fix seo Title
- fix seo missing concatenated meta tags
  • Loading branch information
AdamQuadmon committed Mar 14, 2022
1 parent 2aeedc7 commit a27171e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
6 changes: 6 additions & 0 deletions themes/gatsby-theme-lucifero/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 2.0.12

### Patch Changes

- Fix seo

## 2.0.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion themes/gatsby-theme-lucifero/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adamquadmon/gatsby-theme-lucifero",
"version": "2.0.11",
"version": "2.0.12",
"author": "Luciano Amodio <gatsby@lucianoamodio.it> (@adamquadmon)",
"description": "Dark/Light Chakra UI theme with MDX and other suff",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions themes/gatsby-theme-lucifero/src/components/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ Image.defaultProps = {
export default Image

const addOgImageSettings = (image) => {
if (image.contentUrl) image = image.contentUrl
if (image.indexOf('?') > -1) return image
return `${image}?w=1200&h=630&fit=crop&crop=edges&auto=compress,format`
const imageSrc = image.contentUrl ? image.contentUrl : image
if (imageSrc.indexOf('?') > -1) return imageSrc
return `${imageSrc}?w=1200&h=630&fit=crop&crop=edges&auto=compress,format`
}

export { ImageLink, addOgImageSettings }
26 changes: 13 additions & 13 deletions themes/gatsby-theme-lucifero/src/components/Seo/Seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const Seo = ({ site, page, crumbs }) => {
.concat(getOgMeta(site, page))
.concat(getTwitterMeta(page))

const { headline } = page
const { headline, type } = page

const titleTemplate = site.website.titleTemplate
const titleTemplate = 'home' === type ? null : site.website.titleTemplate

return (
<>
Expand All @@ -37,29 +37,29 @@ const getLink = (site, page) => {
} = site
const { url } = page

const link = [
let link = [
{ rel: 'shortcut icon', type: 'image/png', href: icon },
// { rel: "icon", type: "image/png", sizes: "16x16", href: favicon16x16 },
// { rel: "icon", type: "image/png", sizes: "32x32", href: favicon32x32 },
]
if (url) {
link.concat([{ rel: 'canonical', href: url }])
link = link.concat([{ rel: 'canonical', href: url }])
}
return link
}

const getBaseMeta = (page) => {
const { tags, author, datePublished, dateModified, description, image } = page

const metaTags = [
let metaTags = [
{
name: `description`,
content: description,
},
]

if (image) {
metaTags.concat([
metaTags = metaTags.concat([
{
name: `image`,
content: addOgImageSettings(image),
Expand All @@ -68,7 +68,7 @@ const getBaseMeta = (page) => {
}

if (datePublished) {
metaTags.concat([
metaTags = metaTags.concat([
{
name: 'article:published_time',
content: datePublished,
Expand All @@ -77,7 +77,7 @@ const getBaseMeta = (page) => {
}

if (dateModified) {
metaTags.concat([
metaTags = metaTags.concat([
{
name: 'article:modified_time',
content: dateModified,
Expand All @@ -86,7 +86,7 @@ const getBaseMeta = (page) => {
}

if (author) {
metaTags.concat([
metaTags = metaTags.concat([
{
name: 'article:author',
content: author,
Expand All @@ -95,7 +95,7 @@ const getBaseMeta = (page) => {
}

if (tags.length > 0) {
metaTags.concat([
metaTags = metaTags.concat([
{
name: 'keywords',
content: tags.join(', '),
Expand Down Expand Up @@ -155,9 +155,9 @@ const getOgMeta = (site, page) => {
// - use types: https://ogp.me/#types
// - mind that not all tipes are suited for Google Structured Data
// - use this to render diferent schemas
const ogType = type === 'website' ? type : 'article'
const ogType = ['home', 'web'].includes(type) ? 'website' : 'article'

const metaTags = [
let metaTags = [
{
property: `og:url`,
content: url,
Expand All @@ -184,7 +184,7 @@ const getOgMeta = (site, page) => {
},
]
if (image) {
metaTags.concat([
metaTags = metaTags.concat([
{
property: `og:image`,
content: addOgImageSettings(image),
Expand Down

0 comments on commit a27171e

Please sign in to comment.