moved title, metaTag, and link utils into SEO component
This commit is contained in:
parent
a96f79a068
commit
89fcfd84ea
11 changed files with 53 additions and 56 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ config/sequelizeCliConfig.js
|
||||||
config/speechConfig.js
|
config/speechConfig.js
|
||||||
public/bundle
|
public/bundle
|
||||||
server.js
|
server.js
|
||||||
|
webpack.config.js
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
"test": "mocha --recursive",
|
"test": "mocha --recursive",
|
||||||
"test-all": "mocha --recursive",
|
"test-all": "mocha --recursive",
|
||||||
"start": "node server.js",
|
"start": "node server.js",
|
||||||
|
"start-dev": "nodemon server.js",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"fix": "eslint . --fix",
|
"fix": "eslint . --fix",
|
||||||
"precommit": "eslint .",
|
"precommit": "eslint .",
|
||||||
|
|
|
@ -1,18 +1,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import NavBar from 'containers/NavBar';
|
import NavBar from 'containers/NavBar';
|
||||||
import SEO from 'components/SEO';
|
import SEO from 'components/SEO';
|
||||||
import { createPageTitle } from 'utils/pageTitle';
|
|
||||||
import { createBasicCanonicalLink } from 'utils/canonicalLink';
|
|
||||||
import { createBasicMetaTags } from 'utils/metaTags';
|
|
||||||
|
|
||||||
class AboutPage extends React.Component {
|
class AboutPage extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
const pageTitle = createPageTitle('About');
|
|
||||||
const canonicalLink = createBasicCanonicalLink('about');
|
|
||||||
const metaTags = createBasicMetaTags();
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<SEO pageTitle={pageTitle} canonicalLink={canonicalLink} metaTags={metaTags} />
|
<SEO pageTitle={'About'} pageUri={'about'} />
|
||||||
<NavBar />
|
<NavBar />
|
||||||
<div className='row row--padded'>
|
<div className='row row--padded'>
|
||||||
<div className='column column--5 column--med-10 align-content-top'>
|
<div className='column column--5 column--med-10 align-content-top'>
|
||||||
|
|
|
@ -2,18 +2,12 @@ import React from 'react';
|
||||||
import SEO from 'components/SEO';
|
import SEO from 'components/SEO';
|
||||||
import NavBar from 'containers/NavBar';
|
import NavBar from 'containers/NavBar';
|
||||||
import PublishTool from 'containers/PublishTool';
|
import PublishTool from 'containers/PublishTool';
|
||||||
import { createPageTitle } from 'utils/pageTitle';
|
|
||||||
import { createBasicCanonicalLink } from 'utils/canonicalLink';
|
|
||||||
import { createBasicMetaTags } from 'utils/metaTags';
|
|
||||||
|
|
||||||
class HomePage extends React.Component {
|
class HomePage extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
const pageTitle = createPageTitle();
|
|
||||||
const canonicalLink = createBasicCanonicalLink();
|
|
||||||
const metaTags = createBasicMetaTags();
|
|
||||||
return (
|
return (
|
||||||
<div className={'row row--tall flex-container--column'}>
|
<div className={'row row--tall flex-container--column'}>
|
||||||
<SEO pageTitle={pageTitle} canonicalLink={canonicalLink} metaTags={metaTags} />
|
<SEO />
|
||||||
<NavBar />
|
<NavBar />
|
||||||
<div className={'row row--tall row--padded flex-container--column'}>
|
<div className={'row row--tall row--padded flex-container--column'}>
|
||||||
<PublishTool />
|
<PublishTool />
|
||||||
|
|
|
@ -2,23 +2,31 @@ import React from 'react';
|
||||||
import Helmet from 'react-helmet';
|
import Helmet from 'react-helmet';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
import { createPageTitle } from 'utils/pageTitle';
|
||||||
|
import { createMetaTags } from 'utils/metaTags';
|
||||||
|
import { createCanonicalLink } from 'utils/canonicalLink';
|
||||||
|
|
||||||
class SEO extends React.Component {
|
class SEO extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
const { pageTitle, metaTags, canonicalLink } = this.props;
|
let { pageTitle, asset, channel, pageUri } = this.props;
|
||||||
|
pageTitle = createPageTitle(pageTitle);
|
||||||
|
const metaTags = createMetaTags(asset, channel);
|
||||||
|
const canonicalLink = createCanonicalLink(asset, channel, pageUri);
|
||||||
return (
|
return (
|
||||||
<Helmet
|
<Helmet
|
||||||
title={pageTitle}
|
title={pageTitle}
|
||||||
link={[{rel: 'canonical', href: canonicalLink}]}
|
|
||||||
meta={metaTags}
|
meta={metaTags}
|
||||||
|
link={[{rel: 'canonical', href: canonicalLink}]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SEO.propTypes = {
|
SEO.propTypes = {
|
||||||
pageTitle : PropTypes.string.isRequired,
|
pageTitle: PropTypes.string,
|
||||||
metaTags : PropTypes.array.isRequired,
|
pageUri : PropTypes.string,
|
||||||
canonicalLink: PropTypes.string.isRequired,
|
channel : PropTypes.object,
|
||||||
|
asset : PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SEO;
|
export default SEO;
|
||||||
|
|
|
@ -5,21 +5,15 @@ import ErrorPage from 'components/ErrorPage';
|
||||||
import AssetTitle from 'components/AssetTitle';
|
import AssetTitle from 'components/AssetTitle';
|
||||||
import AssetDisplay from 'components/AssetDisplay';
|
import AssetDisplay from 'components/AssetDisplay';
|
||||||
import AssetInfo from 'components/AssetInfo';
|
import AssetInfo from 'components/AssetInfo';
|
||||||
import { createPageTitle } from 'utils/pageTitle';
|
|
||||||
import { createAssetCanonicalLink } from 'utils/canonicalLink';
|
|
||||||
import { createAssetMetaTags } from 'utils/metaTags';
|
|
||||||
|
|
||||||
class ShowAssetDetails extends React.Component {
|
class ShowAssetDetails extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
const { asset } = this.props;
|
const { asset } = this.props;
|
||||||
if (asset) {
|
if (asset) {
|
||||||
const { name } = asset.claimData;
|
const { name } = asset.claimData;
|
||||||
const pageTitle = createPageTitle(`${name} - details`);
|
|
||||||
const canonicalLink = createAssetCanonicalLink(asset);
|
|
||||||
const metaTags = createAssetMetaTags(asset);
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<SEO pageTitle={pageTitle} canonicalLink={canonicalLink} metaTags={metaTags} />
|
<SEO pageTitle={`${name} - details`} asset={asset} />
|
||||||
<NavBar />
|
<NavBar />
|
||||||
<div className='row row--tall row--padded'>
|
<div className='row row--tall row--padded'>
|
||||||
<div className='column column--10'>
|
<div className='column column--10'>
|
||||||
|
|
|
@ -2,21 +2,15 @@ import React from 'react';
|
||||||
import SEO from 'components/SEO';
|
import SEO from 'components/SEO';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import AssetDisplay from 'components/AssetDisplay';
|
import AssetDisplay from 'components/AssetDisplay';
|
||||||
import { createPageTitle } from 'utils/pageTitle';
|
|
||||||
import { createAssetCanonicalLink } from 'utils/canonicalLink';
|
|
||||||
import { createAssetMetaTags } from 'utils/metaTags';
|
|
||||||
|
|
||||||
class ShowLite extends React.Component {
|
class ShowLite extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
const { asset } = this.props;
|
const { asset } = this.props;
|
||||||
if (asset) {
|
if (asset) {
|
||||||
const { name, claimId } = asset.claimData;
|
const { name, claimId } = asset.claimData;
|
||||||
const pageTitle = createPageTitle(name);
|
|
||||||
const canonicalLink = createAssetCanonicalLink(asset);
|
|
||||||
const metaTags = createAssetMetaTags(asset);
|
|
||||||
return (
|
return (
|
||||||
<div className='row row--tall flex-container--column flex-container--center-center'>
|
<div className='row row--tall flex-container--column flex-container--center-center'>
|
||||||
<SEO pageTitle={pageTitle} canonicalLink={canonicalLink} metaTags={metaTags} />
|
<SEO pageTitle={name} asset={asset} />
|
||||||
<div>
|
<div>
|
||||||
<AssetDisplay />
|
<AssetDisplay />
|
||||||
<Link id='asset-boilerpate' className='link--primary fine-print' to={`/${claimId}/${name}`}>hosted
|
<Link id='asset-boilerpate' className='link--primary fine-print' to={`/${claimId}/${name}`}>hosted
|
||||||
|
|
|
@ -3,27 +3,21 @@ import SEO from 'components/SEO';
|
||||||
import ErrorPage from 'components/ErrorPage';
|
import ErrorPage from 'components/ErrorPage';
|
||||||
import NavBar from 'containers/NavBar';
|
import NavBar from 'containers/NavBar';
|
||||||
import ChannelClaimsDisplay from 'containers/ChannelClaimsDisplay';
|
import ChannelClaimsDisplay from 'containers/ChannelClaimsDisplay';
|
||||||
import { createPageTitle } from 'utils/pageTitle';
|
|
||||||
import { createChannelCanonicalLink } from 'utils/canonicalLink';
|
|
||||||
import { createChannelMetaTags } from 'utils/metaTags';
|
|
||||||
|
|
||||||
class ShowChannel extends React.Component {
|
class ShowChannel extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
const { channel } = this.props;
|
const { channel } = this.props;
|
||||||
if (channel) {
|
if (channel) {
|
||||||
const { name, longId, shortId } = channel;
|
const { name, longId, shortId } = channel;
|
||||||
const pageTitle = createPageTitle(`${name}`);
|
|
||||||
const canonicalLink = createChannelCanonicalLink(channel);
|
|
||||||
const metaTags = createChannelMetaTags(channel);
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<SEO pageTitle={pageTitle} canonicalLink={canonicalLink} metaTags={metaTags} />
|
<SEO pageTitle={name} channel={channel} />
|
||||||
<NavBar />
|
<NavBar />
|
||||||
<div className='row row--tall row--padded'>
|
<div className='row row--tall row--padded'>
|
||||||
<div className='column column--10'>
|
<div className='column column--10'>
|
||||||
<h2>channel name: {name || 'loading...'}</h2>
|
<h2>channel name: {name}</h2>
|
||||||
<p className={'fine-print'}>full channel id: {longId || 'loading...'}</p>
|
<p className={'fine-print'}>full channel id: {longId}</p>
|
||||||
<p className={'fine-print'}>short channel id: {shortId || 'loading...'}</p>
|
<p className={'fine-print'}>short channel id: {shortId}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className='column column--10'>
|
<div className='column column--10'>
|
||||||
<ChannelClaimsDisplay />
|
<ChannelClaimsDisplay />
|
||||||
|
|
|
@ -4,9 +4,6 @@ import SEO from 'components/SEO';
|
||||||
import NavBar from 'containers/NavBar';
|
import NavBar from 'containers/NavBar';
|
||||||
import ChannelLoginForm from 'containers/ChannelLoginForm';
|
import ChannelLoginForm from 'containers/ChannelLoginForm';
|
||||||
import ChannelCreateForm from 'containers/ChannelCreateForm';
|
import ChannelCreateForm from 'containers/ChannelCreateForm';
|
||||||
import { createPageTitle } from 'utils/pageTitle';
|
|
||||||
import { createBasicCanonicalLink } from 'utils/canonicalLink';
|
|
||||||
import { createBasicMetaTags } from 'utils/metaTags';
|
|
||||||
|
|
||||||
class LoginPage extends React.Component {
|
class LoginPage extends React.Component {
|
||||||
componentWillReceiveProps (newProps) {
|
componentWillReceiveProps (newProps) {
|
||||||
|
@ -17,12 +14,9 @@ class LoginPage extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
const pageTitle = createPageTitle('Login');
|
|
||||||
const canonicalLink = createBasicCanonicalLink('login');
|
|
||||||
const metaTags = createBasicMetaTags();
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<SEO pageTitle={pageTitle} canonicalLink={canonicalLink} metaTags={metaTags} />
|
<SEO pageTitle={'Login'} pageUri={'login'} />
|
||||||
<NavBar />
|
<NavBar />
|
||||||
<div className='row row--padded'>
|
<div className='row row--padded'>
|
||||||
<div className='column column--5 column--med-10 align-content-top'>
|
<div className='column column--5 column--med-10 align-content-top'>
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
const { site: { host } } = require('../../config/speechConfig.js');
|
const { site: { host } } = require('../../config/speechConfig.js');
|
||||||
|
|
||||||
export const createBasicCanonicalLink = (page) => {
|
const createBasicCanonicalLink = (page) => {
|
||||||
if (!page) {
|
if (!page) {
|
||||||
return `${host}`;
|
return `${host}`;
|
||||||
};
|
};
|
||||||
return `${host}/${page}`;
|
return `${host}/${page}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createAssetCanonicalLink = (asset) => {
|
const createAssetCanonicalLink = (asset) => {
|
||||||
let channelName, certificateId, name, claimId;
|
let channelName, certificateId, name, claimId;
|
||||||
if (asset.claimData) {
|
if (asset.claimData) {
|
||||||
({ channelName, certificateId, name, claimId } = asset.claimData);
|
({ channelName, certificateId, name, claimId } = asset.claimData);
|
||||||
|
@ -18,7 +18,20 @@ export const createAssetCanonicalLink = (asset) => {
|
||||||
return `${host}/${claimId}/${name}`;
|
return `${host}/${claimId}/${name}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createChannelCanonicalLink = (channel) => {
|
const createChannelCanonicalLink = (channel) => {
|
||||||
const { name, longId } = channel;
|
const { name, longId } = channel;
|
||||||
return `${host}/${name}:${longId}`;
|
return `${host}/${name}:${longId}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const createCanonicalLink = (asset, channel, page) => {
|
||||||
|
if (asset) {
|
||||||
|
return createAssetCanonicalLink(asset);
|
||||||
|
}
|
||||||
|
if (channel) {
|
||||||
|
return createChannelCanonicalLink(channel);
|
||||||
|
}
|
||||||
|
if (page) {
|
||||||
|
return createBasicCanonicalLink(page);
|
||||||
|
}
|
||||||
|
return createBasicCanonicalLink();
|
||||||
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@ const determineOgThumbnailContentType = (thumbnail) => {
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createBasicMetaTags = () => {
|
const createBasicMetaTags = () => {
|
||||||
return [
|
return [
|
||||||
{property: 'og:title', content: title},
|
{property: 'og:title', content: title},
|
||||||
{property: 'og:url', content: host},
|
{property: 'og:url', content: host},
|
||||||
|
@ -31,7 +31,7 @@ export const createBasicMetaTags = () => {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createChannelMetaTags = (channel) => {
|
const createChannelMetaTags = (channel) => {
|
||||||
const { name, longId } = channel;
|
const { name, longId } = channel;
|
||||||
return [
|
return [
|
||||||
{property: 'og:title', content: `${name} on ${title}`},
|
{property: 'og:title', content: `${name} on ${title}`},
|
||||||
|
@ -43,7 +43,7 @@ export const createChannelMetaTags = (channel) => {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createAssetMetaTags = (asset) => {
|
const createAssetMetaTags = (asset) => {
|
||||||
const { claimData } = asset;
|
const { claimData } = asset;
|
||||||
const { contentType } = claimData;
|
const { contentType } = claimData;
|
||||||
const embedUrl = `${host}/${claimData.claimId}/${claimData.name}`;
|
const embedUrl = `${host}/${claimData.claimId}/${claimData.name}`;
|
||||||
|
@ -84,3 +84,13 @@ export const createAssetMetaTags = (asset) => {
|
||||||
}
|
}
|
||||||
return metaTags;
|
return metaTags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const createMetaTags = (asset, channel) => {
|
||||||
|
if (asset) {
|
||||||
|
return createAssetMetaTags(asset);
|
||||||
|
};
|
||||||
|
if (channel) {
|
||||||
|
return createChannelMetaTags(channel);
|
||||||
|
};
|
||||||
|
return createBasicMetaTags();
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue