Skip to content

Commit 2c3e721

Browse files
committed
feat: update docs
1 parent 65b9abe commit 2c3e721

23 files changed

+62
-45
lines changed

.github/workflows/page.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
pages:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: setup
17+
run: |
18+
cd example && cp assets/bin/* /usr/local/bin
19+
chmod u+x /usr/local/bin/mdbook* && mdbook build
20+
- uses: peaceiris/actions-gh-pages@v3
21+
with:
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
publish_dir: ./example/book

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mdbook-embedify"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55
license = "MIT"
66
readme = "README.md"

README.md

+1-14
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,8 @@ Then you can use `embed` macro to embed an app. The syntax is like this:
3232
{% embed codepen user="MR-Addict" slug="NWBOqKw" height="600" theme="dark" %}
3333
```
3434

35-
Some apps are not third-party apps, for example scroll-to-top button. You can use it like this:
36-
37-
```text
38-
{% embed scroll-to-top %}
39-
```
40-
41-
But this only works for chapter that embeds this, not for the whole book. Most of cases, you want to use it for the whole book. You can do this by adding `scroll-to-top` option to embedify preprocessor in `book.toml` file like this:
42-
43-
```toml
44-
[preprocessor.embedify]
45-
scroll-to-top = true
46-
```
47-
4835
## 3. Examples
4936

50-
![example](example.png)
37+
![preview](preview.png)
5138

5239
You can see a live demo and more detailed documentation [here](https://mr-addict.github.io/mdbook-embedify).
File renamed without changes.

example/assets/bin/mdbook-embedify

1.77 MB
Binary file not shown.

example/assets/css/patch.css

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@ table {
44
}
55

66
table tr :is(th, td) {
7-
padding-block: 10px;
7+
padding-block: 7px;
8+
}
9+
10+
@media (min-width: 768px) {
11+
table tr :is(th, td) {
12+
padding-block: 10px;
13+
}
814
}

example/src/ignore-embeds.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
Sometimes you may want preprocessors to ignore some embeds.
44

5-
You can do it by adding group of `<!-- embed ignore begin -->` and `<!-- embed ignore end -->` comment to the content where you want to ignore. For example:
5+
You can do it by wrapping content that you want to ignore with below two comments:
66

7-
```text
7+
- `<!-- embed ignore begin -->`
8+
- `<!-- embed ignore end -->`
9+
10+
For example:
811

12+
```text
913
<!-- embed ignore begin -->
1014
11-
{% embed codepen user="MR-Addict" slug="NWBOqKw" height="600" theme="dark" %}
15+
{% embed youtube id="DyTCOwB0DVw" %}
1216
1317
<!-- embed ignore end -->
14-
1518
```
19+
20+
And youtube embed won't be rendered.

example/src/local/intro.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# Local Apps
22

3-
Local apps are apps that are not hosted on third party sites.
3+
Local apps are apps hosted on your local book, so it is not necessary to have internet connection to use them.
44

5-
They are hosted on your local book, so it is not necessary to have internet connection to use them.
6-
7-
Below are all supported local apps and its detailed usage.
5+
Below are all supported local apps and its detailed options.
86

97
- [Scroll To Top](scroll-to-top.md)

example/src/local/scroll-to-top.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ scroll-to-top = true
2323
2424
<!-- embed ignore end -->
2525

26-
This book uses this option. You can see it at the bottom right corner of this page. But it only shows pages that are longer enough to scroll. You can see it in action by scrolling down this page.
26+
This book uses this option. You can see it at the bottom right corner of this page. But it only shows pages that are longer enough to scroll. You can see it in action by scrolling down this page. Or you can see it my another book [Notes](https://mr-addict.github.io/notes).

example/src/third-party/codesandbox.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
<!-- embed ignore begin -->
1111

1212
```text
13-
{% embed codesandbox id="ke8wx" theme="dark" %}
13+
{% embed codesandbox id="ke8wx" theme="light" %}
1414
```
1515

1616
<!-- embed ignore end -->
1717

18-
{% embed codesandbox id="ke8wx" theme="dark" %}
18+
{% embed codesandbox id="ke8wx" theme="light" %}

example/src/third-party/intro.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Third Party Apps
22

3-
Third party apps are apps that are hosted on third party sites.
4-
5-
Below are all supported third party apps and its detailed usage.
3+
Third party apps are apps that are hosted on third party sites. Below are all supported third party apps and its detailed options.
64

75
- [Gist](gist.md)
86
- [Youtube](youtube.md)
97
- [Bilibili](bilibili.md)
8+
- [Codesandbox](codesandbox.md)
9+
- [Stackblitz](stackblitz.md)
1010
- [Codepen](codepen.md)

example/src/third-party/stackblitz.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
<!-- embed ignore begin -->
1111

1212
```text
13-
{% embed codesandbox id="vitejs-vite-y8mdxg" theme="dark" %}
13+
{% embed stackblitz id="vitejs-vite-y8mdxg" theme="light" %}
1414
```
1515

1616
<!-- embed ignore end -->
1717

18-
{% embed codesandbox id="vitejs-vite-y8mdxg" theme="dark" %}
18+
{% embed stackblitz id="vitejs-vite-y8mdxg" theme="light" %}

example/src/third-party/youtube.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
<!-- embed ignore begin -->
1010

1111
```text
12-
{% embed youtube id="EngW7tLk6R8" %}
12+
{% embed youtube id="DyTCOwB0DVw" %}
1313
```
1414

1515
<!-- embed ignore end -->
1616

17-
{% embed youtube id="EngW7tLk6R8" %}
17+
{% embed youtube id="DyTCOwB0DVw" %}

example/src/usage.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Usage
2-
31
## Installation
42

53
There are two ways to install this plugin.

example.png preview.png

File renamed without changes.

src/embed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Preprocessor for Embed {
3838

3939
// if scroll-to-top is enabled, add {% embed scrolltotop %}
4040
if scroll_to_top {
41-
content.push_str("\n{% embed scroll-to-top %}");
41+
content.push_str("\n{% embed scroll-to-top %}\n");
4242
}
4343

4444
// this can make the process faster

templates/bilibili.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
loading="lazy"
44
name="bilibili"
55
src="https://player.bilibili.com/player.html?bvid={id}&danmaku=0"
6-
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem"
6+
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem; background: black"
77
></iframe>

templates/codepen.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
loading="lazy"
44
name="codepen"
55
height="{height|600}"
6-
style="width: 100%; border: none; border-radius: 1rem"
6+
style="width: 100%; border: none; border-radius: 1rem; background: black"
77
src="https://codepen.io/{user}/embed/{slug}?default-tab=result&theme-id={theme|dark}"
88
></iframe>

templates/codesandbox.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
loading="lazy"
33
name="sandbox"
44
src="https://codesandbox.io/embed/{id}?&theme={theme|dark}"
5-
style="width: 100%; height: 100%; border: solid 1px #e5e7eb; aspect-ratio: 16/9; border-radius: 1rem"
5+
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem; background: black"
66
></iframe>

templates/scroll-to-top.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
</style>
3232

33-
<script>
33+
<script async defer>
3434
window.addEventListener("scroll", () => {
3535
const button = document.querySelector(".scroll-to-top");
3636
button.classList.toggle("hidden", window.scrollY < 200);

templates/stackblitz.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
loading="lazy"
33
name="stackblitz"
44
src="https://stackblitz.com/edit/{id}?embed=1&theme={theme|dark}&view=preview"
5-
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem"
5+
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem; background: black"
66
></iframe>

templates/youtube.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<iframe
22
allowfullscreen
33
loading="lazy"
4-
name="YouTube"
4+
name="youtube"
55
src="https://www.youtube.com/embed/{id}"
6-
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem"
6+
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem; background: black"
77
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
88
></iframe>

0 commit comments

Comments
 (0)