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

feat(v2): add meta RSS/Atom feed links to head #2000

Merged
merged 6 commits into from
Nov 30, 2019
Merged
Changes from 1 commit
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
21 changes: 21 additions & 0 deletions packages/docusaurus-theme-classic/src/theme/Layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function Layout(props) {
title: defaultTitle,
themeConfig: {image: defaultImage},
url: siteUrl,
presets,
} = siteConfig;
const {
children,
Expand All @@ -36,6 +37,10 @@ function Layout(props) {
const metaImage = image || defaultImage;
const metaImageUrl = siteUrl + useBaseUrl(metaImage);
const faviconUrl = useBaseUrl(favicon);
const hasBlog = presets.some(preset => (preset[1] || {}).blog !== undefined);
const rssFeedLink = siteUrl + useBaseUrl('blog/feed.xml');
const atomFeedLink = siteUrl + useBaseUrl('blog/atom.xml');
endiliey marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
<Head>
Expand All @@ -57,6 +62,22 @@ function Layout(props) {
)}
{permalink && <meta property="og:url" content={siteUrl + permalink} />}
<meta name="twitter:card" content="summary" />
{hasBlog && (
<link
rel="alternate"
type="application/rss+xml"
href={rssFeedLink}
title={`${defaultTitle} Blog RSS Feed`}
/>
)}
{hasBlog && (
<link
rel="alternate"
type="application/atom+xml"
href={atomFeedLink}
title={`${defaultTitle} Blog Atom Feed`}
/>
)}
</Head>
<Navbar />
<div className="main-wrapper">{children}</div>
Expand Down