mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
Move Docusaurus 1 files into directory (#966)
* Move Docusaurus 1 into v1 directory * Update Circle CI commands for new v1 dir * Remove OC * Fix tests
This commit is contained in:
parent
9d4a5d5359
commit
f2927a9fc4
291 changed files with 7591 additions and 6532 deletions
65
v1/lib/server/feed.js
Normal file
65
v1/lib/server/feed.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const Feed = require('feed');
|
||||
const truncateHtml = require('truncate-html');
|
||||
|
||||
const BLOG_POST_SUMMARY_LENGTH = 250;
|
||||
|
||||
const CWD = process.cwd();
|
||||
const siteConfig = require(`${CWD}/siteConfig.js`);
|
||||
const readMetadata = require('./readMetadata.js');
|
||||
|
||||
const blogRootURL = `${siteConfig.url + siteConfig.baseUrl}blog`;
|
||||
const siteImageURL =
|
||||
siteConfig.url + siteConfig.baseUrl + siteConfig.headerIcon;
|
||||
const utils = require('../core/utils');
|
||||
|
||||
const renderMarkdown = require('../core/renderMarkdown.js');
|
||||
|
||||
module.exports = function(type) {
|
||||
console.log('feed.js triggered...');
|
||||
|
||||
type = type || 'rss';
|
||||
|
||||
readMetadata.generateMetadataBlog();
|
||||
const MetadataBlog = require('../core/MetadataBlog.js');
|
||||
|
||||
const feed = new Feed({
|
||||
title: `${siteConfig.title} Blog`,
|
||||
description: `The best place to stay up-to-date with the latest ${
|
||||
siteConfig.title
|
||||
} news and events.`,
|
||||
id: blogRootURL,
|
||||
link: blogRootURL,
|
||||
image: siteImageURL,
|
||||
copyright: siteConfig.copyright,
|
||||
updated: new Date(MetadataBlog[0].date),
|
||||
});
|
||||
|
||||
MetadataBlog.forEach(post => {
|
||||
const url = `${blogRootURL}/${post.path}`;
|
||||
const description = utils.blogPostHasTruncateMarker(post.content)
|
||||
? renderMarkdown(utils.extractBlogPostBeforeTruncate(post.content))
|
||||
: truncateHtml(renderMarkdown(post.content), BLOG_POST_SUMMARY_LENGTH);
|
||||
|
||||
feed.addItem({
|
||||
title: post.title,
|
||||
link: url,
|
||||
author: [
|
||||
{
|
||||
name: post.author,
|
||||
link: post.authorURL,
|
||||
},
|
||||
],
|
||||
date: new Date(post.date),
|
||||
description,
|
||||
});
|
||||
});
|
||||
|
||||
return type === 'rss' ? feed.rss2() : feed.atom1();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue