Skip to content

Commit

Permalink
Themes: Fix og:url meta, add canonical link tag (#13505)
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham authored Apr 28, 2017
1 parent c4e5e9b commit 84269b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions client/my-sites/themes/controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function getProps( context ) {
analyticsPageTitle,
analyticsPath: basePath,
search: context.query.s,
pathName: context.pathname,
trackScrollPage: boundTrackScrollPage
};
}
Expand Down
21 changes: 10 additions & 11 deletions client/my-sites/themes/theme-showcase.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { localize } from 'i18n-calypso';
import page from 'page';
import { includes, pickBy } from 'lodash';
import { pickBy } from 'lodash';
import Gridicon from 'gridicons';

/**
Expand Down Expand Up @@ -39,13 +39,6 @@ function getThemeShowcaseTitle( tier ) {
return titles[ tier ];
}

function getThemeShowcaseCanonicalUrl( tier ) {
if ( includes( [ 'free', 'premium' ], tier ) ) {
return 'https://wordpress.com/themes/' + tier;
}
return 'https://wordpress.com/themes';
}

const subjectsMeta = {
photo: { icon: 'camera', order: 1 },
portfolio: { icon: 'custom-post-type', order: 2 },
Expand All @@ -71,6 +64,7 @@ const ThemeShowcase = React.createClass( {
emptyContent: PropTypes.element,
tier: PropTypes.oneOf( [ '', 'free', 'premium' ] ),
search: PropTypes.string,
pathName: PropTypes.string,
// Connected props
options: PropTypes.objectOf( optionShape ),
defaultOption: optionShape,
Expand Down Expand Up @@ -147,16 +141,21 @@ const ThemeShowcase = React.createClass( {
translate,
siteSlug,
vertical,
isLoggedIn
isLoggedIn,
pathName,
} = this.props;
const tier = config.isEnabled( 'upgrades/premium-themes' ) ? this.props.tier : 'free';

const canonicalUrl = 'https://wordpress.com' + pathName;

const metas = [
{ name: 'description', property: 'og:description', content: this.props.description },
{ property: 'og:url', content: getThemeShowcaseCanonicalUrl( tier ) },
{ property: 'og:url', content: canonicalUrl },
{ property: 'og:type', content: 'website' }
];

const links = [ { rel: 'canonical', href: canonicalUrl } ];

const headerIcons = [ {
label: 'new',
uri: '/themes',
Expand All @@ -178,7 +177,7 @@ const ThemeShowcase = React.createClass( {
// FIXME: Logged-in title should only be 'Themes'
return (
<Main className="themes">
<DocumentHead title={ getThemeShowcaseTitle( tier ) } meta={ metas } />
<DocumentHead title={ getThemeShowcaseTitle( tier ) } meta={ metas } link={ links } />
<PageViewTracker path={ this.props.analyticsPath } title={ this.props.analyticsPageTitle } />
{ ! isLoggedIn && (
<SubMasterbarNav
Expand Down

0 comments on commit 84269b8

Please sign in to comment.