Skip to content

Commit 5fa7e08

Browse files
committed
docs: Add Embed section
1 parent cfdd4e9 commit 5fa7e08

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

docs/README.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,67 @@ Open the link in the browser.
340340
341341
This section deals with how to update and add to the content of your doc files.
342342
343-
Embed
343+
### Embed
344344
345-
[filename](https://docsify.js.org/_media/example.md ':include')
345+
You can embed content such as video, audio, iframes (`.html`), code blocks or even Markdown files.
346+
347+
#### Format
348+
349+
Add the `':include'` parameter in a markdown URL reference. Here is the format:
350+
351+
```markdown
352+
[filename](url ':include')
353+
```
354+
355+
The URL could be a local file (e.g. `_media/foo.js`) or a remote URL `https://...`.
356+
357+
If you want to embed a code block, you can use the automatic formatting. But markdown and HTML files need to be marked as a code if you want them as code rather than HTML.
358+
359+
```
360+
':include :type=code'
361+
```
362+
363+
See the _Docsify_ [Embed](https://docsify.js.org/#/embed-files) help for forcing types and using fragments.
364+
365+
#### Examples
366+
367+
#### Render markdown
368+
369+
Render markdown as HTML.
370+
371+
```markdown
372+
[example.md](https://docsify.js.org/_media/example.md ':include')
373+
```
374+
375+
[example.md](https://docsify.js.org/_media/example.md ':include')
376+
377+
Note: The result is _not_ inside a code block expected. It is inside a quote block because the source content starts with `> `.
378+
379+
#### JS snippet
380+
381+
Auto formatted.
382+
383+
```markdown
384+
[example.js](_media/example.js ':include' )
385+
```
386+
387+
[example.js](_media/example.js ':include' )
388+
389+
#### Markdown snippet
390+
391+
Force to code snippet.
392+
393+
```markdown
394+
[_sidebar.md](_coverpage.md ':include :type=code')
395+
```
396+
397+
[_sidebar.md](_coverpage.md ':include :type=code')
398+
399+
#### Warnings
400+
401+
- Do not put the URL in a bullet point as it will become an ordinary link.
402+
- Do not put two embed items in a sequence without some characters in between, otherwise you will get a JS error rending the page. Putting an empty line between them is **not** sufficient.
403+
- If you embed a URL of a Github file, remember to use the _Raw_ URL otherwise you will get an error.
346404
347405
348406
## Docsify CLI

docs/_media/example.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Hello, world!');

0 commit comments

Comments
 (0)