Skip to content

Commit

Permalink
feat: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MR-Addict committed Jan 12, 2024
1 parent 65b9abe commit 69283d5
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 32 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/page.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: pages

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
pages:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: setup
run: |
cd example && cp assets/bin/* /usr/local/bin
chmod u+x /usr/local/bin/mdbook* && mdbook build
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./example/book
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mdbook-embedify"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ scroll-to-top = true

## 3. Examples

![example](example.png)
![preview](preview.png)

You can see a live demo and more detailed documentation [here](https://mr-addict.github.io/mdbook-embedify).
File renamed without changes.
Binary file added example/assets/bin/mdbook-embedify
Binary file not shown.
8 changes: 7 additions & 1 deletion example/assets/css/patch.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ table {
}

table tr :is(th, td) {
padding-block: 10px;
padding-block: 7px;
}

@media (min-width: 768px) {
table tr :is(th, td) {
padding-block: 10px;
}
}
13 changes: 9 additions & 4 deletions example/src/ignore-embeds.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

Sometimes you may want preprocessors to ignore some embeds.

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:
You can do it by wrapping content that you want to ignore with below two comments:

```text
- `<!-- embed ignore begin -->`
- `<!-- embed ignore end -->`

For example:

```text
<!-- embed ignore begin -->
{% embed codepen user="MR-Addict" slug="NWBOqKw" height="600" theme="dark" %}
{% embed youtube id="DyTCOwB0DVw" %}
<!-- embed ignore end -->
```

And youtube embed won't be rendered.
6 changes: 2 additions & 4 deletions example/src/local/intro.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Local Apps

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

They are hosted on your local book, so it is not necessary to have internet connection to use them.

Below are all supported local apps and its detailed usage.
Below are all supported local apps and its detailed options.

- [Scroll To Top](scroll-to-top.md)
2 changes: 1 addition & 1 deletion example/src/local/scroll-to-top.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ scroll-to-top = true
<!-- embed ignore end -->

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.
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).
4 changes: 2 additions & 2 deletions example/src/third-party/codesandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<!-- embed ignore begin -->

```text
{% embed codesandbox id="ke8wx" theme="dark" %}
{% embed codesandbox id="ke8wx" theme="light" %}
```

<!-- embed ignore end -->

{% embed codesandbox id="ke8wx" theme="dark" %}
{% embed codesandbox id="ke8wx" theme="light" %}
6 changes: 3 additions & 3 deletions example/src/third-party/intro.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Third Party Apps

Third party apps are apps that are hosted on third party sites.

Below are all supported third party apps and its detailed usage.
Third party apps are apps that are hosted on third party sites. Below are all supported third party apps and its detailed options.

- [Gist](gist.md)
- [Youtube](youtube.md)
- [Bilibili](bilibili.md)
- [Codesandbox](codesandbox.md)
- [Stackblitz](stackblitz.md)
- [Codepen](codepen.md)
4 changes: 2 additions & 2 deletions example/src/third-party/stackblitz.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<!-- embed ignore begin -->

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

<!-- embed ignore end -->

{% embed codesandbox id="vitejs-vite-y8mdxg" theme="dark" %}
{% embed stackblitz id="vitejs-vite-y8mdxg" theme="light" %}
4 changes: 2 additions & 2 deletions example/src/third-party/youtube.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<!-- embed ignore begin -->

```text
{% embed youtube id="EngW7tLk6R8" %}
{% embed youtube id="DyTCOwB0DVw" %}
```

<!-- embed ignore end -->

{% embed youtube id="EngW7tLk6R8" %}
{% embed youtube id="DyTCOwB0DVw" %}
2 changes: 0 additions & 2 deletions example/src/usage.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Usage

## Installation

There are two ways to install this plugin.
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion src/embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Preprocessor for Embed {

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

// this can make the process faster
Expand Down
2 changes: 1 addition & 1 deletion templates/bilibili.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
loading="lazy"
name="bilibili"
src="https://player.bilibili.com/player.html?bvid={id}&danmaku=0"
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem"
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem; background: black"
></iframe>
2 changes: 1 addition & 1 deletion templates/codepen.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
loading="lazy"
name="codepen"
height="{height|600}"
style="width: 100%; border: none; border-radius: 1rem"
style="width: 100%; border: none; border-radius: 1rem; background: black"
src="https://codepen.io/{user}/embed/{slug}?default-tab=result&theme-id={theme|dark}"
></iframe>
2 changes: 1 addition & 1 deletion templates/codesandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
loading="lazy"
name="sandbox"
src="https://codesandbox.io/embed/{id}?&theme={theme|dark}"
style="width: 100%; height: 100%; border: solid 1px #e5e7eb; aspect-ratio: 16/9; border-radius: 1rem"
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem; background: black"
></iframe>
2 changes: 1 addition & 1 deletion templates/scroll-to-top.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
</style>

<script>
<script async defer>
window.addEventListener("scroll", () => {
const button = document.querySelector(".scroll-to-top");
button.classList.toggle("hidden", window.scrollY < 200);
Expand Down
2 changes: 1 addition & 1 deletion templates/stackblitz.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
loading="lazy"
name="stackblitz"
src="https://stackblitz.com/edit/{id}?embed=1&theme={theme|dark}&view=preview"
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem"
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem; background: black"
></iframe>
4 changes: 2 additions & 2 deletions templates/youtube.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<iframe
allowfullscreen
loading="lazy"
name="YouTube"
name="youtube"
src="https://www.youtube.com/embed/{id}"
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem"
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem; background: black"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
></iframe>

0 comments on commit 69283d5

Please sign in to comment.