From dc835770a0b5952b9838cc8694f802a199fdd704 Mon Sep 17 00:00:00 2001 From: Eric Nakagawa Date: Wed, 27 Sep 2017 12:49:09 -0700 Subject: [PATCH] RSS/ATOM Feed added, Prism changes, and global Copyright notice. (#94) * Add Reason support to Prism.js * Add XML/ATOM feed. Generates for both localhost and build script. Adds meta links to feeds to all html files. * Updated /core/Footer.js to pull from siteConfig --- docs/api-site-config.md | 2 + docs/guides-blog.md | 6 ++ examples/basics/siteConfig.js | 15 ++-- lib/core/Head.js | 35 ++++++-- lib/generate-feed.js | 33 ++++++++ lib/server/feed.js | 111 +++++++++++++++++++++++++ lib/server/generate.js | 21 +++-- lib/server/readMetadata.js | 23 +++-- lib/server/server.js | 28 +++++-- package.json | 7 +- website/blog/2017-09-25-testing-rss.md | 11 +++ website/blog/2017-09-26-adding-rss.md | 12 +++ website/core/Footer.js | 5 +- website/package.json | 3 + website/siteConfig.js | 12 +-- 15 files changed, 285 insertions(+), 39 deletions(-) create mode 100644 lib/generate-feed.js create mode 100644 lib/server/feed.js create mode 100644 website/blog/2017-09-25-testing-rss.md create mode 100644 website/blog/2017-09-26-adding-rss.md diff --git a/docs/api-site-config.md b/docs/api-site-config.md index 48076ab85f..bc32b778b3 100644 --- a/docs/api-site-config.md +++ b/docs/api-site-config.md @@ -57,6 +57,8 @@ headerLinks: [ - `prismColor` is the color used in the background of syntax highlighting for code in documentation. It is recommended to be the same color as `primaryColor` in `rgba` form with an alpha value of `0.03`. Other fields can be added - Custom color configurations can also be added. For example, if user styles are added with colors specified as `$myColor`, then adding a `myColor` field to `colors` will allow you to easily configure this color. +`copyright` - The copyright string at footer of site and within feed + ### Optional Fields `editUrl` - url for editing docs, usage example: `editUrl + 'en/doc1.md'`. If this field is omitted, there will be no "Edit this Doc" button for each document. diff --git a/docs/guides-blog.md b/docs/guides-blog.md index ea73b0264f..b73f90cfc7 100644 --- a/docs/guides-blog.md +++ b/docs/guides-blog.md @@ -67,3 +67,9 @@ Not this. Or this. ``` + +## RSS Feed + +Docusaurus provides a simple RSS feed for your blog posts. Both RSS and Atom feed formats are supported. This data is automatically to your website page's HTML tag. + +A summary of the post's text is provided in the RSS feed up to the ``. If no `` tag is found, then all text up 250 chacters are used. \ No newline at end of file diff --git a/examples/basics/siteConfig.js b/examples/basics/siteConfig.js index accc9e4abf..96b5cc6b60 100644 --- a/examples/basics/siteConfig.js +++ b/examples/basics/siteConfig.js @@ -24,10 +24,10 @@ const siteConfig = { baseUrl: "/test-site/" /* base url for your project */, projectName: "test-site", headerLinks: [ - { doc: "doc1", label: "Docs" }, - { doc: "doc4", label: "API" }, - { page: "help", label: "Help" }, - { blog: true, label: "Blog" } + {doc: "doc1", label: "Docs"}, + {doc: "doc4", label: "API"}, + {page: "help", label: "Help"}, + {blog: true, label: "Blog"} ], users, /* path to images for header/footer */ @@ -40,7 +40,12 @@ const siteConfig = { secondaryColor: "#205C3B", prismColor: "rgba(46, 133, 85, 0.03)" /* primaryColor in rgba form, with 0.03 alpha */ - } + }, + // This copyright info is used in /core/Footer.js and blog rss/atom feeds. + copyright: + "Copyright © " + + new Date().getFullYear() + + " Your Name or Your Company Name" }; module.exports = siteConfig; diff --git a/lib/core/Head.js b/lib/core/Head.js index 983591e6b2..f3edcd030e 100644 --- a/lib/core/Head.js +++ b/lib/core/Head.js @@ -12,37 +12,58 @@ const React = require("react"); // html head for each page class Head extends React.Component { render() { + let links = this.props.config.headerLinks; + let hasBlog = false; + links.map(link => { + if (link.blog) hasBlog = true; + }); return ( - - {this.props.title} - + {this.props.title} - {this.props.config.ogImage && + {this.props.config.ogImage && ( } + /> + )} - {this.props.config.algolia && + {this.props.config.algolia && ( } + /> + )} + {hasBlog && ( + + )}{" "} + {hasBlog && ( + + )}