-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre-rendered seo #46
Merged
Merged
Pre-rendered seo #46
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
05cb69e
doing a clean edit off of master
hsab 7aca5d7
update preview url
hsab 7767417
narrow down the issue
hsab 5f2e343
pass name and slug to artist container (passing all of config is fine…
brysonian 35e0e93
remove comma after app
brysonian c1b9b4d
remove assigning wid/hei based on window. this is not necessary and c…
hsab 25c71e8
add seo to homepage
hsab 05a1d29
experiment without _redirects
blerchin 61d2090
update seo url to netlify master preview
hsab 481c551
Merge branch 'pre-rendered-seo' of github.com:blerchin/dma-20-mfa-sho…
hsab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again fixing styling when entering the homepage from and external link or by typing in the address bar. Translation is to accommodate centering in the absence of
style={collapsed ? {} : { width: parentWidth, height: parentHeight }}
#46 (comment)