Skip to content

Commit

Permalink
feat: add more apps: bilibili, codesandbox and stackblitz
Browse files Browse the repository at this point in the history
  • Loading branch information
MR-Addict committed Jan 10, 2024
1 parent df8f4a7 commit 781b7d4
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 15 deletions.
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.0.1"
version = "0.0.2"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Then you can use `embed` macro to embed an app. The syntax is like this:
{% embed app options[] %}
```

**options** are key-value based array seperated by space and its value must be wrapped by quotes. For example:
**options** are key-value based array seperated by space and its value must be wrapped by **quotes**. For example:

```text
{% embed codepen username="MR-Addict" slug="NWBOqKw" height="600" theme="dark" %}
{% embed codepen user="MR-Addict" slug="NWBOqKw" height="600" theme="dark" %}
```

## 3. Examples
Expand Down
4 changes: 4 additions & 0 deletions docs/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ pre {
color: red;
}

iframe:not(:last-of-type) {
margin-bottom: 2rem;
}

@media (max-width: 600px) {
body {
padding: 0.5rem;
Expand Down
61 changes: 54 additions & 7 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h2>2. Usage</h2>
For example:
</p>

<pre><code>{% embed codepen username="MR-Addict" slug="NWBOqKw" height="600" theme="dark" %}</code></pre>
<pre><code>{% embed codepen user="MR-Addict" slug="NWBOqKw" height="600" theme="dark" %}</code></pre>

<p>Below is the list of supported apps and their options(<strong class="red">*</strong> means required):</p>

Expand All @@ -57,17 +57,29 @@ <h2>2. Usage</h2>
</tr>
</thead>
<tbody>
<tr>
<td>gist</td>
<td>id<strong class="red">*</strong></td>
</tr>
<tr>
<td>youtube</td>
<td>id<strong class="red">*</strong></td>
</tr>
<tr>
<td>gist</td>
<td>bilibili</td>
<td>id<strong class="red">*</strong></td>
</tr>
<tr>
<td>codesandbox</td>
<td>id<strong class="red">*</strong>, theme(dark)</td>
</tr>
<tr>
<td>stackblitz</td>
<td>id<strong class="red">*</strong>, theme(dark)</td>
</tr>
<tr>
<td>codepen</td>
<td>username<strong class="red">*</strong>, slug<strong class="red">*</strong>, height, theme</td>
<td>user<strong class="red">*</strong>, slug<strong class="red">*</strong>, theme(dark), height(600)</td>
</tr>
</tbody>
</table>
Expand All @@ -76,13 +88,13 @@ <h2>2. Usage</h2>
<section>
<h2>3. Examples</h2>

<h3>3.1 Gist</h3>
<h3>Gist</h3>

<pre><code>{% embed gist id="76cf171d1bdd7da41d4ca96b908eb57a" %}</code></pre>

<script src="https://gist.github.com/MR-Addict/76cf171d1bdd7da41d4ca96b908eb57a.js"></script>

<h3>3.2 Youtube</h3>
<h3>Youtube</h3>

<pre><code>{% embed youtube id="EngW7tLk6R8" %}</code></pre>

Expand All @@ -93,9 +105,44 @@ <h3>3.2 Youtube</h3>
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
></iframe>

<h3>3.3 Codepen</h3>
<h3>Bilibili</h3>

<pre><code>{% embed bilibili id="BV1uT4y1P7CX" danmaku="0" %}</code></pre>

<iframe
allowfullscreen
name="Bilibili"
src="https://player.bilibili.com/player.html?bvid=BV1uT4y1P7CX&danmaku=0"
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 0.375rem"
></iframe>

<h3>Codesandbox</h3>

<pre><code>{% embed codesandbox id="ke8wx" theme="dark" %}</code></pre>

<iframe
loading="lazy"
name="Sandbox"
src="https://codesandbox.io/embed/ke8wx?&theme=light"
style="width: 100%; height: 100%; border: solid 1px #e5e7eb; aspect-ratio: 16/9; border-radius: 0.375rem"
></iframe>

<h3>Stackblitz</h3>

<pre><code>{% embed stackblitz id="vitejs-vite-y8mdxg" theme="light" %}</code></pre>

<iframe
loading="lazy"
name="Stackblitz"
src="https://stackblitz.com/edit/vitejs-vite-y8mdxg?embed=1&theme=light&view=preview"
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 0.375rem"
></iframe>
</section>

<section>
<h3>Codepen</h3>

<pre><code>{% embed codepen username="MR-Addict" slug="NWBOqKw" height="600" theme="dark" %}</code></pre>
<pre><code>{% embed codepen user="MR-Addict" slug="NWBOqKw" height="600" theme="dark" %}</code></pre>

<iframe
height="600"
Expand Down
7 changes: 7 additions & 0 deletions templates/bilibili.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<iframe
allowfullscreen
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: 0.375rem"
></iframe>
8 changes: 4 additions & 4 deletions templates/codepen.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<iframe
title="Codepen"
height="{height|600}"
allowfullscreen
allowtransparency
loading="lazy"
name="Codepen"
height="{height|600}"
style="width: 100%; border: none; border-radius: 0.375rem"
src="https://codepen.io/{username}/embed/{slug}?default-tab=result&theme-id={theme|dark}"
src="https://codepen.io/{user}/embed/{slug}?default-tab=result&theme-id={theme|dark}"
></iframe>
6 changes: 6 additions & 0 deletions templates/codesandbox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<iframe
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: 0.375rem"
></iframe>
6 changes: 6 additions & 0 deletions templates/stackblitz.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<iframe
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: 0.375rem"
></iframe>
2 changes: 2 additions & 0 deletions templates/youtube.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<iframe
allowfullscreen
loading="lazy"
name="YouTube"
src="https://www.youtube.com/embed/{id}"
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 0.375rem"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
Expand Down

0 comments on commit 781b7d4

Please sign in to comment.