diff --git a/.github/workflows/page.yaml b/.github/workflows/page.yaml index 70f6b05..8bf013f 100644 --- a/.github/workflows/page.yaml +++ b/.github/workflows/page.yaml @@ -37,7 +37,7 @@ jobs: cp example/assets/bin/* /usr/local/bin && chmod u+x /usr/local/bin/mdbook* - name: Build book - run: mdbook build example + run: sed -i 54d example/book.toml && mdbook build example - uses: peaceiris/actions-gh-pages@v3 with: diff --git a/example/book.toml b/example/book.toml index 3000d59..0fdffd3 100644 --- a/example/book.toml +++ b/example/book.toml @@ -22,7 +22,7 @@ mathjax-support = true copy-fonts = true no-section-label = false git-repository-url = "https://github.com/mr-addict/mdbook-embedify" -edit-url-template = "https://github.com/mr-addict/mdbook-embedify/edit/main/{path}" +edit-url-template = "https://github.com/mr-addict/mdbook-embedify/edit/main/example/{path}" additional-css = ["assets/css/patch.css"] [output.html.print] @@ -51,9 +51,10 @@ heading-split-level = 3 copy-js = true [preprocessor.embedify] +command = "target/release/mdbook-embedify.exe" scroll-to-top.enable = true announcement-banner.enable = true -announcement-banner.name = "0.2.2" -announcement-banner.style = "default" +announcement-banner.id = "0.2.2" +announcement-banner.theme = "default" announcement-banner.message = "*Version **0.2.2** now has relased, check it out [here](https://github.com/MR-Addict/mdbook-embedify/releases/tag/0.2.2).*" diff --git a/example/src/global-configuration.md b/example/src/global-configuration.md index c387042..718f4a5 100644 --- a/example/src/global-configuration.md +++ b/example/src/global-configuration.md @@ -24,8 +24,8 @@ Below is a full list of apps that support global configuration: scroll-to-top.enable = true announcement-banner.enable = true -announcement-banner.name = "0.2.2" -announcement-banner.style = "default" +announcement-banner.id = "0.2.2" +announcement-banner.theme = "default" announcement-banner.message = "*Version **0.2.2** now has relased, check it out [here](https://github.com/MR-Addict/mdbook-embedify/releases/tag/0.2.2).*" ``` diff --git a/example/src/ignore-embeds.md b/example/src/ignore-embeds.md index 1f7638f..c7caee1 100644 --- a/example/src/ignore-embeds.md +++ b/example/src/ignore-embeds.md @@ -1,6 +1,6 @@ # Ignore Embeds -Sometimes you may want preprocessors to ignore some embeds. +Sometimes you may want preprocessor to ignore some embeds. You can do it by wrapping content that you want to ignore with below two comments: diff --git a/example/src/local/announcement-banner.md b/example/src/local/announcement-banner.md index e39704b..f202880 100644 --- a/example/src/local/announcement-banner.md +++ b/example/src/local/announcement-banner.md @@ -2,16 +2,16 @@ | Option | Description | Required | Default | | :------ | :----------------------------------------------------------- | :------- | :------ | -| name | Announcement name | Yes | - - | +| id | Announcement id | Yes | - - | | message | Announcement message, supports markdown syntax | Yes | - - | -| style | Supports style: **default**, **ocean**, **forest**, **lava** | No | default | +| theme | Supports theme: **default**, **ocean**, **forest**, **lava** | No | default | ## Example ```text -{% embed announcement-banner name="0.2.2" style="default" message="*Version **0.2.2** now has relased, check it out [here](https://github.com/MR-Addict/mdbook-embedify/releases/tag/0.2.2).*" %} +{% embed announcement-banner id="0.2.2" theme="default" message="*Version **0.2.2** now has relased, check it out [here](https://github.com/MR-Addict/mdbook-embedify/releases/tag/0.2.2).*" %} ``` @@ -23,9 +23,9 @@ However, you may want to enable it for the whole book. You can do this by adding ```toml [preprocessor.embedify] announcement-banner.enable = true -announcement-banner.name = "0.2.2" -announcement-banner.style = "default" +announcement-banner.id = "0.2.2" +announcement-banner.theme = "default" announcement-banner.message = "*Version **0.2.2** now has relased, check it out [here](https://github.com/MR-Addict/mdbook-embedify/releases/tag/0.2.2).*" ``` -Note that announcement banner name must be **unique**, otherwise it won't be shown if there is another announcement banner with the same name when user closed it. +Note that announcement banner id must be **unique**, otherwise it won't be shown if there is another announcement banner with the same id when user closed it. diff --git a/src/embed.rs b/src/embed.rs index 247d0a1..cd191e5 100644 --- a/src/embed.rs +++ b/src/embed.rs @@ -25,12 +25,11 @@ impl Preprocessor for Embed { let announcement_banner_enabled = utils::get_config_bool(config, "announcement-banner.enable", false); - let announcement_banner_name = - utils::get_config_string(config, "announcement-banner.name", ""); + let announcement_banner_id = utils::get_config_string(config, "announcement-banner.id", ""); + let announcement_banner_theme = + utils::get_config_string(config, "announcement-banner.theme", "default"); let announcement_banner_message = utils::get_config_string(config, "announcement-banner.message", ""); - let announcement_banner_style = - utils::get_config_string(config, "announcement-banner.style", "default"); book.for_each_mut(|item| { if let mdbook::book::BookItem::Chapter(chapter) = item { @@ -39,8 +38,8 @@ impl Preprocessor for Embed { } if announcement_banner_enabled { chapter.content.push_str(&format!( - "\n{{% embed announcement-banner name=\"{}\" message=\"{}\" style=\"{}\" %}}\n", - announcement_banner_name, announcement_banner_message, announcement_banner_style + "\n{{% embed announcement-banner id=\"{}\" message=\"{}\" theme=\"{}\" %}}\n", + announcement_banner_id, announcement_banner_message, announcement_banner_theme )); } chapter.content = utils::render_embeds(chapter.content.clone()); diff --git a/templates/announcement-banner.html b/templates/announcement-banner.html index eeb9e5c..0c0f124 100644 --- a/templates/announcement-banner.html +++ b/templates/announcement-banner.html @@ -22,17 +22,17 @@ --site-announcement-bar-stripe-color2: #d1d5db; } - .announcement-banner[data-style="ocean"] { + .announcement-banner[data-theme="ocean"] { --site-announcement-bar-stripe-color1: #86b2f9; --site-announcement-bar-stripe-color2: #7298ea; } - .announcement-banner[data-style="forest"] { + .announcement-banner[data-theme="forest"] { --site-announcement-bar-stripe-color1: #97f5d6; --site-announcement-bar-stripe-color2: #6de0bf; } - .announcement-banner[data-style="lava"] { + .announcement-banner[data-theme="lava"] { --site-announcement-bar-stripe-color1: #fea3a3; --site-announcement-bar-stripe-color2: #e57e7e; } @@ -62,17 +62,17 @@ } -