Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8b76095
chore: update dependencies
paulrobertlloyd Mar 8, 2025
18217f6
test(preset-eleventy): correct test names
paulrobertlloyd Mar 9, 2025
6510519
feat(plugin): base plug-in
paulrobertlloyd Feb 26, 2025
270cbb7
docs(create-indiekit): consistent use of packageName
paulrobertlloyd Mar 1, 2025
1737a73
feat(plugin): post type plug-in
paulrobertlloyd Feb 28, 2025
0689c99
feat: post type plug-ins use IndiekitPostTypePlugin
paulrobertlloyd Feb 28, 2025
64c4e6a
feat(indiekit): remove addPostType method
paulrobertlloyd Feb 28, 2025
fb7b3dd
feat(plugin): endpoint plug-in
paulrobertlloyd Feb 28, 2025
b0248a7
feat: endpoint plug-ins use IndiekitEndpointPlugin
paulrobertlloyd Feb 28, 2025
3b5468b
feat(indiekit): remove addCollection method
paulrobertlloyd Feb 28, 2025
d575b37
feat(indiekit): remove addEndpoint method
paulrobertlloyd Feb 28, 2025
4ab5871
feat(indiekit): remove _routes method used for internal routing
paulrobertlloyd Feb 28, 2025
9558382
feat(plugin): publication preset plug-in
paulrobertlloyd Feb 28, 2025
63b6417
feat: publication preset plug-ins use IndiekitPresetPlugin
paulrobertlloyd Feb 28, 2025
2fffb02
feat(indiekit): remove addPreset method
paulrobertlloyd Feb 28, 2025
d103724
feat(plugin): syndicator plug-in
paulrobertlloyd Mar 2, 2025
a700141
feat: syndicator plug-ins use IndiekitSyndicatorPlugin
paulrobertlloyd Mar 2, 2025
3c18cbb
feat(indiekit): remove addSyndicator method
paulrobertlloyd Mar 2, 2025
8de2f1d
feat(plugin): store plug-in
paulrobertlloyd Mar 2, 2025
7cd86e3
feat: content store plug-ins use IndiekitStorePlugin
paulrobertlloyd Mar 2, 2025
ac7767a
feat(indiekit): remove addStore method
paulrobertlloyd Mar 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions helpers/frontend/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
import express from "express";
import { IndiekitEndpointPlugin } from "@indiekit/plugin";

const defaults = {
mountPath: "/frontend",
};
export default class FrontendEndpointPlugin extends IndiekitEndpointPlugin {
mountPath = "/frontend";

const router = express.Router({ caseSensitive: true, mergeParams: true });

export default class FrontendEndpoint {
constructor(options = {}) {
this.name = "Frontend endpoint";
this.options = { ...defaults, ...options };
this.mountPath = this.options.mountPath;
}
name = "Frontend endpoint";

get routesPublic() {
router.get("/:page", (request, response) => {
this.router.get("/:page", (request, response) => {
const { page } = request.params;

response.render(`frontend-${page}`, {
title: `Frontend ${page}`,
});
});

router.post("/form", (request, response) => {
this.router.post("/form", (request, response) => {
response.render(`frontend-form`, {
title: `Frontend form (with errors)`,
errors: {
Expand All @@ -34,10 +26,6 @@ export default class FrontendEndpoint {
});
});

return router;
}

init(Indiekit) {
Indiekit.addEndpoint(this);
return this.router;
}
}
24 changes: 13 additions & 11 deletions helpers/store/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IndiekitError } from "@indiekit/error";
import { IndiekitStorePlugin } from "@indiekit/plugin";

const defaults = {
baseUrl: "https://store.example",
Expand All @@ -8,17 +9,22 @@ const defaults = {
* @typedef Response
* @property {object} response - HTTP response
*/
export default class TestStore {
export default class TestStorePlugin extends IndiekitStorePlugin {
name = "Test store";

/**
* @param {object} [options] - Plug-in options
* @param {string} [options.baseUrl] - Base URL
* @param {string} [options.user] - Username
*/
constructor(options = {}) {
this.name = "Test store";
super(options);

this.options = { ...defaults, ...options };
}

get info() {
const { baseUrl, user } = this.options;
return {
this.info = {
name: "Test store",
uid: `${baseUrl}/${user}`,
uid: `${this.options.baseUrl}/${this.options.user}`,
};
}

Expand Down Expand Up @@ -102,8 +108,4 @@ export default class TestStore {
await this.#client(path, "DELETE", { message });
return true;
}

init(Indiekit) {
Indiekit.addStore(this);
}
}
Loading