-
Notifications
You must be signed in to change notification settings - Fork 144
Add CustardUI script as bundled custom plugin #2906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| ### Plugin: CustardUI | ||
|
|
||
| <div id="content"> | ||
|
|
||
| This plugin automatically injects the [CustardUI](https://custardui.js.org/) auto-init script into the page, enhancing generated static sites with more interactivity and personalization. | ||
|
|
||
| <box type="info"> | ||
|
|
||
| CustardUI provides additional custom elements like `<cv-toggle>`, `<cv-tabgroup>`, placeholders, page highlighting capabilities, and more. | ||
|
|
||
| </box> | ||
|
|
||
| To enable this plugin, add `custardui` to your site's plugins. | ||
|
|
||
| ```js {heading="site.json"} | ||
| { | ||
| ... | ||
| "plugins": [ | ||
| "custardui" | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| <panel header="Optional: Specifying a Base URL"> | ||
|
|
||
| By default, the plugin sets the `data-base-url` attribute for CustardUI to `/`. If you are hosting your site in a subdirectory or need to customize this base URL, you can configure it under `pluginsContext`. | ||
|
|
||
| ```js {heading="site.json"} | ||
| { | ||
| ... | ||
| "pluginsContext": { | ||
| "custardui": { | ||
| "baseUrl": "/my-base-url" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| </panel> | ||
|
|
||
| <br> | ||
|
|
||
| **Adding a CustardUI configuration file**: | ||
|
|
||
| After enabling the plugin, create a `custardui.config.json` file in your site's root directory. This tells CustardUI what options and features to expose to your readers. | ||
|
|
||
| <box type="tip"> | ||
|
|
||
| Make sure your `site.json` ignore list does not exclude JSON files, or MarkBind will not copy `custardui.config.json` into the generated site and the plugin will not work. | ||
|
|
||
| </box> | ||
|
|
||
| Here is a sample configuration with the settings panel enabled: | ||
|
|
||
| ```json {heading="custardui.config.json"} | ||
| { | ||
| "config": { | ||
| "toggles": [ | ||
| { "toggleId": "mac", "label": "macOS", "description": "Show macOS instructions" }, | ||
| { "toggleId": "win", "label": "Windows", "description": "Show Windows instructions" } | ||
| ] | ||
| }, | ||
| "settings": { | ||
| "enabled": true | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| With this configuration, readers will see a settings panel they can use to switch between viewing macOS and Windows content. For more information, check out the [CustardUI documentation](https://custardui.js.org/). | ||
|
|
||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { PluginContext } from './Plugin.js'; | ||
|
|
||
| /** | ||
| * CustardUI Plugin for MarkBind | ||
| * Injects the CustardUI auto-init script into every page. | ||
| */ | ||
|
|
||
| const getScripts = (pluginContext: PluginContext) => { | ||
| const baseUrl = pluginContext?.baseUrl || '/'; | ||
| return [ | ||
| // Latest Stable Release | ||
| '<script src="https://cdn.jsdelivr.net/npm/@custardui/custardui@latest" ' | ||
| + `data-base-url="${baseUrl}"></script>`, | ||
| ]; | ||
| }; | ||
|
|
||
| const tagConfig = { | ||
| 'cv-toggle': { isCustomElement: true }, | ||
| 'cv-toggle-control': { isCustomElement: true }, | ||
| 'cv-tabgroup': { isCustomElement: true }, | ||
| 'cv-tab': { isCustomElement: true }, | ||
| 'cv-tab-body': { isCustomElement: true }, | ||
| 'cv-tab-header': { isCustomElement: true }, | ||
| 'cv-define-placeholder': { isCustomElement: true }, | ||
| 'cv-placeholder-input': { isCustomElement: true }, | ||
| 'cv-label': { isCustomElement: true }, | ||
| 'cv-insertion': { isCustomElement: true }, | ||
| }; | ||
|
|
||
| export { getScripts, tagConfig }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.