Skip to content
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

support profile, article, and book open graph type properties #22

Merged
merged 5 commits into from
Dec 22, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions src/meta/buildTags.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,84 @@ const buildTags = (config) => {

if (config.openGraph.type) {
tagsToRender.push(<meta key="og:type" property="og:type" content={config.openGraph.type} />);
econdie marked this conversation as resolved.
Show resolved Hide resolved

if (config.openGraph.type == 'profile' && config.openGraph.profile) {
econdie marked this conversation as resolved.
Show resolved Hide resolved
if (config.openGraph.profile.first_name) {
econdie marked this conversation as resolved.
Show resolved Hide resolved
tagsToRender.push(<meta key="profile:first_name" property="profile:first_name" content={config.openGraph.profile.first_name} />);
}

if (config.openGraph.profile.last_name) {
tagsToRender.push(<meta key="profile:last_name" property="profile:last_name" content={config.openGraph.profile.last_name} />);
}

if (config.openGraph.profile.username) {
tagsToRender.push(<meta key="profile:username" property="profile:username" content={config.openGraph.profile.username} />);
}

if (config.openGraph.profile.gender) {
tagsToRender.push(<meta key="profile:gender" property="profile:gender" content={config.openGraph.profile.gender} />);
}
}

if (config.openGraph.type == 'book' && config.openGraph.book) {
econdie marked this conversation as resolved.
Show resolved Hide resolved
if (config.openGraph.book.author && config.openGraph.book.author.length) {
config.openGraph.book.author.forEach((author, index) => {
tagsToRender.push(
<meta key={`book:author:0${index}`} property="book:author" content={author} />,
);
});
}

if (config.openGraph.book.isbn) {
tagsToRender.push(<meta key="book:isbn" property="book:isbn" content={config.openGraph.book.isbn} />);
}

if (config.openGraph.book.release_date) {
tagsToRender.push(<meta key="book:release_date" property="book:release_date" content={config.openGraph.book.release_date} />);
}

if (config.openGraph.book.tag && config.openGraph.book.tag.length) {
config.openGraph.book.tag.forEach((tag, index) => {
tagsToRender.push(
<meta key={`book:tag:0${index}`} property="book:tag" content={tag} />,
);
});
}
}

if (config.openGraph.type == 'article' && config.openGraph.article) {
econdie marked this conversation as resolved.
Show resolved Hide resolved
if (config.openGraph.article.published_time) {
tagsToRender.push(<meta key="article:published_time" property="article:published_time" content={config.openGraph.article.published_time} />);
}

if (config.openGraph.article.modified_time) {
tagsToRender.push(<meta key="article:modified_time" property="article:modified_time" content={config.openGraph.article.modified_time} />);
}

if (config.openGraph.article.expiration_time) {
tagsToRender.push(<meta key="article:expiration_time" property="article:expiration_time" content={config.openGraph.article.expiration_time} />);
}

if (config.openGraph.article.author && config.openGraph.article.author.length) {
config.openGraph.article.author.forEach((author, index) => {
tagsToRender.push(
<meta key={`article:author:0${index}`} property="article:author" content={author} />,
);
});
}

if (config.openGraph.article.section) {
tagsToRender.push(<meta key="article:section" property="article:section" content={config.openGraph.article.section} />);
}

if (config.openGraph.article.tag && config.openGraph.article.tag.length) {
config.openGraph.article.tag.forEach((tag, index) => {
tagsToRender.push(
<meta key={`article:tag:0${index}`} property="article:tag" content={tag} />,
);
});
}
}
}

if (config.openGraph.title) {
Expand Down