From d65b9513e338e1864cd15e7cfae8567229e198d1 Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Sat, 23 Nov 2024 18:51:33 +0000 Subject: [PATCH] docs: addCollection API method --- docs/.vitepress/config.js | 4 ++++ docs/api/add-collection.md | 18 ++++++++++++++++++ docs/api/index.md | 2 ++ 3 files changed, 24 insertions(+) create mode 100644 docs/api/add-collection.md diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index d9c08051f..7a0b710e9 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -42,6 +42,10 @@ const sidebar = [ const sidebarApi = [ { text: "Introduction", link: "/api/" }, + { + text: "Indiekit.addCollection", + link: "/api/add-collection", + }, { text: "Indiekit.addEndpoint", link: "/api/add-endpoint", diff --git a/docs/api/add-collection.md b/docs/api/add-collection.md new file mode 100644 index 000000000..820b88f1d --- /dev/null +++ b/docs/api/add-collection.md @@ -0,0 +1,18 @@ +--- +outline: deep +--- + +# `Indiekit.addCollection` + +This method is enables plug-ins to add a new collection to the MongoDB database for storing data. + +## Syntax + +```js +new Indiekit.addCollection(name); +``` + +## Constructor + +`name` +: Collection name. This cannot share the name of a collection added by another plug-in. Indiekit currently adds 2 collections: `posts` and `media`. diff --git a/docs/api/index.md b/docs/api/index.md index f9e5672a2..bdbf49753 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -12,6 +12,8 @@ A plug-in can provide any of the following features: * [content store functions](add-store.md) * [syndication functions](add-syndicator.md) +A plug-in can also [add a collection](add-collection.md) to the MongoDb database. + ## Anatomy of a plug-in A plug-in is a `Class` with an `init()` function that is used to register endpoints, presets, stores and syndicators. You can also use the `init()` function to modify Indiekit’s [configuration](../configuration/index.md). For example: