rebuilt client
This commit is contained in:
parent
4293e445a6
commit
99cdfc0c8d
4 changed files with 88 additions and 7 deletions
|
@ -11,10 +11,14 @@ var _reactHelmet = _interopRequireDefault(require("react-helmet"));
|
||||||
|
|
||||||
var _propTypes = _interopRequireDefault(require("prop-types"));
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
||||||
|
|
||||||
|
var _siteConfig = _interopRequireDefault(require("@config/siteConfig.json"));
|
||||||
|
|
||||||
var _createPageTitle = _interopRequireDefault(require("../../utils/createPageTitle"));
|
var _createPageTitle = _interopRequireDefault(require("../../utils/createPageTitle"));
|
||||||
|
|
||||||
var _createMetaTags = _interopRequireDefault(require("../../utils/createMetaTags"));
|
var _createMetaTags = _interopRequireDefault(require("../../utils/createMetaTags"));
|
||||||
|
|
||||||
|
var _oEmbed = _interopRequireDefault(require("../../utils/oEmbed.js"));
|
||||||
|
|
||||||
var _createCanonicalLink = _interopRequireDefault(require("../../utils/createCanonicalLink"));
|
var _createCanonicalLink = _interopRequireDefault(require("../../utils/createCanonicalLink"));
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
@ -37,6 +41,8 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
||||||
|
|
||||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) { return o.__proto__; }; return _getPrototypeOf(o); }
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) { return o.__proto__; }; return _getPrototypeOf(o); }
|
||||||
|
|
||||||
|
var host = _siteConfig.default.details.host;
|
||||||
|
|
||||||
var SEO =
|
var SEO =
|
||||||
/*#__PURE__*/
|
/*#__PURE__*/
|
||||||
function (_React$Component) {
|
function (_React$Component) {
|
||||||
|
@ -61,15 +67,15 @@ function (_React$Component) {
|
||||||
asset: asset,
|
asset: asset,
|
||||||
channel: channel
|
channel: channel
|
||||||
});
|
});
|
||||||
var canonicalLink = (0, _createCanonicalLink.default)(asset, channel, pageUri); // render results
|
var cannonicalLink = (0, _createCanonicalLink.default)(asset, channel, pageUri); // render results
|
||||||
|
|
||||||
return _react.default.createElement(_reactHelmet.default, {
|
return _react.default.createElement(_reactHelmet.default, {
|
||||||
title: pageTitle,
|
title: pageTitle,
|
||||||
meta: metaTags,
|
meta: metaTags,
|
||||||
link: [{
|
link: [{
|
||||||
rel: 'canonical',
|
rel: 'canonical',
|
||||||
href: canonicalLink
|
href: cannonicalLink
|
||||||
}]
|
}, _oEmbed.default.json(host, cannonicalLink), _oEmbed.default.xml(host, cannonicalLink)]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
@ -79,7 +85,6 @@ function (_React$Component) {
|
||||||
return SEO;
|
return SEO;
|
||||||
}(_react.default.Component);
|
}(_react.default.Component);
|
||||||
|
|
||||||
;
|
|
||||||
SEO.propTypes = {
|
SEO.propTypes = {
|
||||||
pageTitle: _propTypes.default.string,
|
pageTitle: _propTypes.default.string,
|
||||||
pageUri: _propTypes.default.string,
|
pageUri: _propTypes.default.string,
|
||||||
|
|
36
client/build/utils/oEmbed.js
Normal file
36
client/build/utils/oEmbed.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.default = void 0;
|
||||||
|
var rel = 'alternate';
|
||||||
|
var title = 'spee.ch oEmbed profile';
|
||||||
|
|
||||||
|
var formatUrlForQuery = function formatUrlForQuery(url) {
|
||||||
|
return url.replace(/\/+/, '%2F').replace(/:/, '%3A');
|
||||||
|
};
|
||||||
|
|
||||||
|
var createJsonLinkData = function createJsonLinkData(host, canonicalUrl) {
|
||||||
|
return {
|
||||||
|
rel: rel,
|
||||||
|
type: 'application/json+oembed',
|
||||||
|
href: "".concat(host, "/api/oembed?url=").concat(formatUrlForQuery(canonicalUrl), "%2F&format=json"),
|
||||||
|
title: title
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var createXmlLinkData = function createXmlLinkData(host, canonicalUrl) {
|
||||||
|
return {
|
||||||
|
rel: rel,
|
||||||
|
type: 'application/xml+oembed',
|
||||||
|
href: "".concat(host, "/api/oembed?").concat(formatUrlForQuery(canonicalUrl), "%2F&format=xml"),
|
||||||
|
title: title
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var _default = {
|
||||||
|
json: createJsonLinkData,
|
||||||
|
xml: createXmlLinkData
|
||||||
|
};
|
||||||
|
exports.default = _default;
|
|
@ -2,10 +2,14 @@ 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 siteConfig from '@config/siteConfig.json';
|
||||||
import createPageTitle from '../../utils/createPageTitle';
|
import createPageTitle from '../../utils/createPageTitle';
|
||||||
import createMetaTags from '../../utils/createMetaTags';
|
import createMetaTags from '../../utils/createMetaTags';
|
||||||
|
import oEmbed from '../../utils/oEmbed.js';
|
||||||
import createCanonicalLink from '../../utils/createCanonicalLink';
|
import createCanonicalLink from '../../utils/createCanonicalLink';
|
||||||
|
|
||||||
|
const { details: { host } } = siteConfig;
|
||||||
|
|
||||||
class SEO extends React.Component {
|
class SEO extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
// props from parent
|
// props from parent
|
||||||
|
@ -17,17 +21,24 @@ class SEO extends React.Component {
|
||||||
asset,
|
asset,
|
||||||
channel,
|
channel,
|
||||||
});
|
});
|
||||||
const canonicalLink = createCanonicalLink(asset, channel, pageUri);
|
const cannonicalLink = createCanonicalLink(asset, channel, pageUri)
|
||||||
// render results
|
// render results
|
||||||
return (
|
return (
|
||||||
<Helmet
|
<Helmet
|
||||||
title={pageTitle}
|
title={pageTitle}
|
||||||
meta={metaTags}
|
meta={metaTags}
|
||||||
link={[{rel: 'canonical', href: canonicalLink}]}
|
link={[
|
||||||
|
{
|
||||||
|
rel : 'canonical',
|
||||||
|
href: cannonicalLink,
|
||||||
|
},
|
||||||
|
oEmbed.json(host, cannonicalLink),
|
||||||
|
oEmbed.xml(host, cannonicalLink),
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
SEO.propTypes = {
|
SEO.propTypes = {
|
||||||
pageTitle: PropTypes.string,
|
pageTitle: PropTypes.string,
|
||||||
|
|
29
client/src/utils/oEmbed.js
Normal file
29
client/src/utils/oEmbed.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const rel = 'alternate';
|
||||||
|
const title = 'spee.ch oEmbed profile';
|
||||||
|
|
||||||
|
const formatUrlForQuery = (url) => {
|
||||||
|
return url.replace(/\/+/, '%2F').replace(/:/, '%3A');
|
||||||
|
};
|
||||||
|
|
||||||
|
const createJsonLinkData = (host, canonicalUrl) => {
|
||||||
|
return {
|
||||||
|
rel,
|
||||||
|
type: 'application/json+oembed',
|
||||||
|
href: `${host}/api/oembed?url=${formatUrlForQuery(canonicalUrl)}%2F&format=json`,
|
||||||
|
title,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const createXmlLinkData = (host, canonicalUrl) => {
|
||||||
|
return {
|
||||||
|
rel,
|
||||||
|
type: 'application/xml+oembed',
|
||||||
|
href: `${host}/api/oembed?${formatUrlForQuery(canonicalUrl)}%2F&format=xml`,
|
||||||
|
title,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
json: createJsonLinkData,
|
||||||
|
xml : createXmlLinkData,
|
||||||
|
};
|
Loading…
Reference in a new issue