-
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.
Merge pull request #46 from blerchin/pre-rendered-seo
Pre-rendered seo
- Loading branch information
Showing
22 changed files
with
1,925 additions
and
798 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// https://github.com/stereobooster/react-snap/blob/master/doc/recipes.md | ||
// From https://github.com/stereobooster/an-almost-static-stack/blob/react-snap/src/components/Seo.js | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { Helmet } from "react-helmet"; | ||
|
||
const rootURL = `https://kind-tesla-a088c1.netlify.app`; | ||
const absoluteUrl = (path) => `${rootURL}/${path}`; | ||
const seoImageURL = (file) => `${rootURL}${file}`; | ||
|
||
const getMetaTags = ({ | ||
title, | ||
description, | ||
url, | ||
contentType, | ||
published, | ||
updated, | ||
category, | ||
tags, | ||
twitter, | ||
image, | ||
}) => { | ||
const metaTags = [ | ||
{ itemprop: "name", content: title }, | ||
{ itemprop: "description", content: description }, | ||
{ name: "description", content: description }, | ||
{ name: "twitter:site", content: twitter }, | ||
{ name: "twitter:title", content: title }, | ||
{ name: "twitter:description", content: description }, | ||
{ name: "twitter:creator", content: twitter }, | ||
{ property: "og:title", content: title }, | ||
{ property: "og:type", content: contentType }, //https://ogp.me/#types | ||
{ property: "og:url", content: url }, | ||
{ property: "og:description", content: description }, | ||
{ property: "og:site_name", content: "NEARREST NEIGHBOR" }, | ||
{ property: "og:locale", content: "en_EN" }, | ||
// { name: 'fb:app_id', content: '<FB App ID>' }, | ||
]; | ||
|
||
if (published) | ||
metaTags.push({ name: "article:published_time", content: published }); | ||
if (updated) | ||
metaTags.push({ name: "article:modified_time", content: updated }); | ||
if (category) metaTags.push({ name: "article:section", content: category }); | ||
if (tags) metaTags.push({ name: "article:tag", content: tags }); | ||
if (image) { | ||
metaTags.push({ itemprop: "image", content: seoImageURL(image) }); | ||
metaTags.push({ name: "twitter:image:src", content: seoImageURL(image) }); | ||
metaTags.push({ property: "og:image", content: seoImageURL(image) }); | ||
metaTags.push({ name: "twitter:card", content: "summary_large_image" }); | ||
} else { | ||
metaTags.push({ name: "twitter:card", content: "summary" }); | ||
} | ||
|
||
return metaTags; | ||
}; | ||
|
||
const getHtmlAttributes = ({ schema }) => { | ||
let result = { | ||
lang: "en", | ||
}; | ||
if (schema) { | ||
result = { | ||
...result, | ||
itemscope: undefined, | ||
itemtype: `http://schema.org/${schema}`, | ||
}; | ||
} | ||
return result; | ||
}; | ||
|
||
getHtmlAttributes.propTypes = { | ||
schema: PropTypes.string, | ||
}; | ||
|
||
const Seo = ({ | ||
schema, | ||
title, | ||
description, | ||
path, | ||
contentType, | ||
published, | ||
updated, | ||
category, | ||
tags, | ||
twitter, | ||
image, | ||
}) => ( | ||
<Helmet | ||
htmlAttributes={getHtmlAttributes({ | ||
schema, | ||
})} | ||
title={title ? `${title} | NEARREST NEIGHBOR` : "NEARREST NEIGHBOR"} | ||
link={[{ rel: "canonical", href: absoluteUrl(path) }]} | ||
meta={getMetaTags({ | ||
title: title ? `${title} | NEARREST NEIGHBOR` : "NEARREST NEIGHBOR", | ||
description: description | ||
? description | ||
: "Online MFA show for 2020 DMA grads.", | ||
contentType, | ||
url: path ? absoluteUrl(path) : rootURL, | ||
published, | ||
updated, | ||
category, | ||
tags, | ||
twitter, | ||
image: image | ||
? image.images[image.images.length - 1].path | ||
: `/ogimagecomp.jpg`, | ||
})} | ||
/> | ||
); | ||
|
||
Seo.propTypes = { | ||
schema: PropTypes.string, | ||
title: PropTypes.string, | ||
description: PropTypes.string, | ||
path: PropTypes.string, | ||
contentType: PropTypes.string, | ||
published: PropTypes.string, | ||
updated: PropTypes.string, | ||
category: PropTypes.string, | ||
tags: PropTypes.array, | ||
twitter: PropTypes.string, | ||
image: PropTypes.object, | ||
}; | ||
|
||
export default Seo; |
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,37 +1,60 @@ | ||
import React, { Suspense, lazy } from 'react'; | ||
import React from 'react'; | ||
|
||
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'; | ||
import './style.css'; | ||
import BlobField from 'src/BlobField'; | ||
import config from '../../config'; | ||
import Seo from 'src/Components/Seo' | ||
|
||
import BenLerchin from '../../work/BenLerchin'; | ||
import BerfinAtaman from '../../work/BerfinAtaman'; | ||
import BlaineOneill from '../../work/BlaineOneill'; | ||
import ClaraLeivas from '../../work/ClaraLeivas'; | ||
import DalenaTran from '../../work/DalenaTran'; | ||
import ErinCooney from '../../work/ErinCooney'; | ||
import GrahamAkins from '../../work/GrahamAkins'; | ||
import HiradSab from '../../work/HiradSab'; | ||
import LemingZc from '../../work/LemingZc'; | ||
import MilesPeyton from '../../work/MilesPeyton'; | ||
import ZeynepAbes from '../../work/ZeynepAbes'; | ||
|
||
const comps = { | ||
BenLerchin, | ||
BerfinAtaman, | ||
BlaineOneill, | ||
ClaraLeivas, | ||
DalenaTran, | ||
ErinCooney, | ||
GrahamAkins, | ||
HiradSab, | ||
LemingZc, | ||
MilesPeyton, | ||
ZeynepAbes, | ||
}; | ||
|
||
export default () => ( | ||
<Router> | ||
<div className="app"> | ||
<Suspense fallback={<div />}> | ||
<Switch> | ||
{ | ||
config.artists.map(({slug, component}) => { | ||
const Comp = lazy(() => import(`../../work/${component}`)); | ||
return ( | ||
<Route path={`/${slug}`} key={slug}> | ||
<Comp /> | ||
</Route> | ||
) | ||
}) | ||
} | ||
<Route path='/'>{/* no-op */}</Route> | ||
<Route path="*"> | ||
Page not Found ✧・゚:* | ||
<BlobField /> | ||
<Switch> | ||
{ | ||
config.artists.map(({slug, name, component}) => { | ||
const Comp = comps[component]; | ||
return ( | ||
<Route path={`/${slug}`} key={slug}> | ||
<Comp slug={slug} name={name} /> | ||
</Route> | ||
) | ||
}) | ||
} | ||
<Route path='/'> | ||
<Seo/> | ||
{/* no-op */} | ||
</Route> | ||
</Switch> | ||
</Suspense> | ||
<Route path="/" render={({ match }) => ( | ||
<div className="blobs"> | ||
<BlobField collapsed={!match.isExact} /> | ||
</div> | ||
)}> | ||
</Route> | ||
<Route path="*"> | ||
Page not Found ✧・゚:* | ||
</Route> | ||
</Switch> | ||
</div> | ||
</Router> | ||
); |
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.