This is the Docusaurus plugin to get the create date of the docs.
npm install docusaurus-plugin-get-docs-create-date
Add the plugin to your docusaurus.config.js
:
module.exports = {
plugins: ["docusaurus-plugin-get-docs-create-date",],
};
and when you build the site, the create date of the docs json file will be created in the build
directory as docsCreateDate.json
.
The data structure of the docsCreateDate.json
is:
[
{
"path": "/docs/docusaurus/intro.mdx",
"date": "2023/05/07",
"timestamp": 1683439283000
},
...
]
path
: the path of the docs in your site.date
: the create date of the docs. (format:yyyy/mm/dd
)timestamp
: the timestamp of the create date.
You can use the create date of the docs in your site.
async function fetchDocs() {
try {
const res = await fetch("./docsCreateDate.json");
const data = await res.json();
return data;
} catch (err) {
console.error(err);
return [];
}
}
You can customize the plugin by adding an object to the plugin array in your docusaurus.config.js
:
module.exports = {
plugins: [
[
"docusaurus-plugin-get-docs-create-date",
{
filename: "docsCreateDate",
},
],
],
};
Option | Type | Default | Description |
---|---|---|---|
filename |
string |
"docsCreateDate" |
The name of the output file that will be created in the build directory. |
Contributions are welcome! Please feel free to submit a Pull Request.