diff --git a/Home.md b/Home.md index 5b9c547..89262a1 100644 --- a/Home.md +++ b/Home.md @@ -96,4 +96,62 @@ questions: points: 0 --- This is a great quiz that I'm sure you'll have fun taking. Let me tell you all about it… +``` + +### Settings +How to add a settings "plugin," like woo-mode, or weather: + +1. Create a user-facing form control element at `_includes/settings/controllers/myController.njk`, for example: +``` nunjucks +
+``` +2. Create the logic for your settings plugin at `_includes/mySetting.njk`, for example: +``` nunjucks + + + +``` +You will need, at minimum, two functions: one to start the plugin, and one to end it. Four are possible: +* start the plugin when it is loaded on a page by default +* start the plugin when it is toggled on by the user +* stop the plugin when it is off by default and the user has not turned it on +* stop the plugin when the user toggles it off +3. Add the configuration for your setting in `_includes/settings/settingsConfig.njk`, for example: +```nunjucks +const petBirbSettings = { + handleOnToggle: showBirb, + handleOnDefault: showBirb, + handleOffToggle: hideBirb, + handleOffDefault: noBirb, + settingToggle: "birbToggle", // ID of the input created to control the setting + preferenceName: "petBirb", // Name to be used in local storage to record the user's preference + defaultSetting: false, // Whether the plugin will run by default in absence of a user preference + forcedOn: false, // Whether the plugin will ignore user preference and run anyway if on by default + }; + +``` +4. In the same file, hand off the config object to `settingHandler()` which will handle the starting, stopping, and local storage for your plugin: +```nunjucks +settingHandler(petBirbSettings); +``` +5. Add your plugin include to `_includes/layouts/base.njk`: +```nunjucks +{% include "birb.njk" %} ``` \ No newline at end of file