mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-17 19:16:58 +02:00
Allow controlling number of blog posts in Recent Blogs sidebar. (#432)
New feature. Allow controlling number of blog posts in Recent Blogs sidebar. Can have qty or ALL.
This commit is contained in:
parent
c99cdefd3a
commit
dfb70e1829
3 changed files with 35 additions and 4 deletions
|
@ -365,17 +365,23 @@ function generateMetadataBlog() {
|
|||
filePathDateArr[2] +
|
||||
'T06:00:00.000Z'
|
||||
);
|
||||
// allow easier sorting of blog by providing seconds since epoch
|
||||
metadata.seconds = Math.round(metadata.date.getTime() / 1000);
|
||||
|
||||
metadatas.push(metadata);
|
||||
});
|
||||
|
||||
const sortedMetadatas = metadatas.sort(
|
||||
(a, b) => parseInt(b.seconds) - parseInt(a.seconds)
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
__dirname + '/../core/MetadataBlog.js',
|
||||
'/**\n' +
|
||||
' * @generated\n' +
|
||||
' */\n' +
|
||||
'module.exports = ' +
|
||||
JSON.stringify(metadatas, null, 2) +
|
||||
JSON.stringify(sortedMetadatas, null, 2) +
|
||||
';\n'
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue