Skip to content

Jim876633/docusaurus-plugin-get-doc-create-date

Repository files navigation

docusaurus-plugin-get-docs-create-date

GitHub Release GitHub License GitHub Actions Workflow Status node-current NPM Downloads

This is the Docusaurus plugin to get the create date of the docs.

Installation

npm install docusaurus-plugin-get-docs-create-date

Usage

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 [];
  }
}

Options

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.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

A Docusaurus plugin to get the create date of all docs

Resources

License

Stars

Watchers

Forks

Packages

No packages published