Skip to content

Commit 246fb38

Browse files
feat(plugin): store plug-in
1 parent 4c94fae commit 246fb38

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

packages/plugin/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export { IndiekitPlugin } from "./lib/base.js";
22
export { IndiekitEndpointPlugin } from "./lib/endpoint.js";
33
export { IndiekitPostTypePlugin } from "./lib/post-type.js";
44
export { IndiekitPresetPlugin } from "./lib/preset.js";
5+
export { IndiekitStorePlugin } from "./lib/store.js";
56
export { IndiekitSyndicatorPlugin } from "./lib/syndicator.js";

packages/plugin/lib/store.js

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import makeDebug from "debug";
2+
3+
import { IndiekitPlugin } from "./base.js";
4+
5+
const debug = makeDebug(`indiekit:plugin`);
6+
7+
/**
8+
* @typedef StoreInformation
9+
* @property {string} name - Name of content store
10+
* @property {string} uid - Unique identifier
11+
*/
12+
13+
/**
14+
* Content store plug-in
15+
* @class
16+
* @augments {IndiekitPlugin}
17+
*/
18+
export class IndiekitStorePlugin extends IndiekitPlugin {
19+
/**
20+
* Content store information
21+
* @type {StoreInformation}
22+
*/
23+
info = undefined;
24+
25+
/**
26+
* Create file
27+
* @param {string} filePath - Path to file
28+
* @returns {Promise<string>} Created file URL
29+
*/
30+
async createFile(filePath) {
31+
debug(`Creating ${filePath} to ${this.name}`);
32+
return;
33+
}
34+
35+
/**
36+
* Read file
37+
* @param {string} filePath - Path to file
38+
* @returns {Promise<string>} File content
39+
*/
40+
async readFile(filePath) {
41+
debug(`Reading ${filePath} at ${this.name}`);
42+
return;
43+
}
44+
45+
/**
46+
* Update file
47+
* @param {string} filePath - Path to file
48+
* @returns {Promise<string>} Updated file URL
49+
*/
50+
async updateFile(filePath) {
51+
debug(`Updating ${filePath} at ${this.name}`);
52+
return;
53+
}
54+
55+
/**
56+
* Delete file
57+
* @param {string} filePath - Path to file
58+
* @returns {Promise<boolean>} File deleted
59+
*/
60+
async deleteFile(filePath) {
61+
debug(`Creating ${filePath} to ${this.name}`);
62+
return;
63+
}
64+
65+
#addStore() {
66+
debug(`Adding content store: ${this.name}`);
67+
this.indiekit.stores.add(this);
68+
}
69+
70+
async init() {
71+
await super.init();
72+
73+
this.#addStore();
74+
}
75+
}

0 commit comments

Comments
 (0)