Skip to content

Commit

Permalink
Merge branch 'develop' into fix-1233
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Jun 26, 2020
2 parents 14fdf2b + 0663cb3 commit 454e694
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 16 deletions.
12 changes: 11 additions & 1 deletion build/build.js
Expand Up @@ -29,7 +29,17 @@ async function build(opts) {
__VERSION__: version,
'process.env.SSR': false
})
])
]),
onwarn: function (message) {
if (message.code === 'UNRESOLVED_IMPORT') {
throw new Error(
`Could not resolve module ` +
message.source +
`. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
`Module ${message.source} is imported in ${message.importer}`
)
}
}
})
.then(function (bundle) {
var dest = 'lib/' + (opts.output || opts.input)
Expand Down
46 changes: 46 additions & 0 deletions docs/deploy.md
Expand Up @@ -135,3 +135,49 @@ frontend:
| /<*>.md | /<*>.md | 200 (Rewrite) |
| /<*>.png | /<*>.png | 200 (Rewrite) |
| /<*> | /index.html | 200 (Rewrite) |


## Docker

- Create docsify files

You need prepare the initial files instead of making in container.
See the [Quickstart](https://docsify.js.org/#/quickstart) section for instructions on how to create these files manually or using [docsify-cli](https://github.com/docsifyjs/docsify-cli).

```sh
index.html
README.md
```

- Create dockerfile

```Dockerfile
FROM node:latest
LABEL description="A demo Dockerfile for build Docsify."
WORKDIR /docs
RUN npm install -g docsify-cli@latest
EXPOSE 3000/tcp
ENTRYPOINT docsify serve .

```

So, current directory structure should be this:

```sh
index.html
README.md
Dockerfile
```

- Build docker image

```sh
docker build -f Dockerfile -t docsify/demo .
```

- Run docker image

```sh
docker run -itp 3000:3000 --name=docsify -v $(pwd):/docs docsify/demo
```

90 changes: 84 additions & 6 deletions docs/embed-files.md
@@ -1,41 +1,44 @@
# Embed files

With docsify 4.6 it is now possible to embed any type of file.

You can embed these files as video, audio, iframes, or code blocks, and even Markdown files can even be embedded directly into the document.

For example, here embedded a Markdown file. You only need to do this:
For example, here is an embedded Markdown file. You only need to do this:

```markdown
[filename](_media/example.md ':include')
```

Then the content of `example.md` will be displayed directly here
Then the content of `example.md` will be displayed directly here;

[filename](_media/example.md ':include')

You can check the original content for [example.md](_media/example.md ':ignore').

Normally, this will compiled into a link, but in docsify, if you add `:include` it will be embedded.

External links can be used too - just replace the target. If you want to use a gist URL, see [Embed a gist](#embed-a-gist) section.

## Embedded file type

Currently, file extension are automatically recognized and embedded in different ways.
Currently, file extensions are automatically recognized and embedded in different ways.

This is a supported embedding type:
These types are supported:

* **iframe** `.html`, `.htm`
* **markdown** `.markdown`, `.md`
* **audio** `.mp3`
* **video** `.mp4`, `.ogg`
* **code** other file extension

Of course, you can force the specified. For example, you want to Markdown file as code block embedded.
Of course, you can force the specified type. For example, a Markdown file can be embedded as a code block by setting `:type=code`.

```markdown
[filename](_media/example.md ':include :type=code')
```

You will get it
You will get:

[filename](_media/example.md ':include :type=code')

Expand Down Expand Up @@ -91,3 +94,78 @@ Embedding any type of source code file, you can specify the highlighted language
[](_media/example.html ':include :type=code text')

?> How to set highlight? You can see [here](language-highlight.md).

## Embed a gist

You can embed a gist as markdown content or as a code block - this is based on the approach at the start of [Embed Files](#embed-files) section, but uses a raw gist URL as the target.

?> **No** plugin or app config change is needed here to make this work. In fact, the "Embed" `script` tag that is copied from a gist will _not_ load even if you make plugin or config changes to allow an external script.

### Identify the gist's metadata

Start by viewing a gist on `gist.github.com`. For the purposes of this guide, we use this gist:

- https://gist.github.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15

Identify the following items from the gist:

Field | Example | Description
--- | --- | ---
**Username** | `anikethsaha` | The gist's owner.
**Gist ID** | `c2bece08f27c4277001f123898d16a7c` | Identifier for the gist. This is fixed for the gist's lifetime.
**Filename** | `content.md` | Select a name of a file in the gist. This needed even on a single-file gist for embedding to work.

You will need those to build the _raw gist URL_ for the target file. This has the following format:

- `https://gist.githubusercontent.com/USERNAME/GIST_ID/raw/FILENAME`

Here are two examples based on the sample gist:

- https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/content.md
- https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/script.js

?> Alternatively, you can get a raw URL directly clicking the _Raw_ button on a gist file. But, if you use that approach, just be sure to **remove** the revision number between `raw/` and the filename so that the URL matches the pattern above instead. Otherwise your embedded gist will **not** show the latest content when the gist is updated.

Continue with one of the sections below to embed the gist on a Docsify page.

### Render markdown content from a gist

This is a great way to embed content **seamlessly** in your docs, without sending someone to an external link. This approach is well-suited to reusing a gist of say installation instructions across doc sites of multiple repos. This approach works equally well with a gist owned by your account or by another user.

Here is the format:

```markdown
[LABEL](https://gist.githubusercontent.com/USERNAME/GIST_ID/raw/FILENAME ':include')
```

For example:

```markdown
[gist: content.md](https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/content.md ':include')
```

Which renders as:

[gist: content.md](https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/content.md ':include')

The `LABEL` can be any text you want. It acts as a _fallback_ message if the link is broken - so it is useful to repeat the filename here in case you need to fix a broken link. It also makes an embedded element easy to read at a glance.

### Render a codeblock from a gist

The format is the same as the previous section, but with `:type=code` added to the alt text. As with the [Embedded file type](#embedded-file-type) section, the syntax highlighting will be **inferred** from the extension (e.g. `.js` or `.py`), so you can leave the `type` set as `code`.

Here is the format:

```markdown
[LABEL](https://gist.githubusercontent.com/USERNAME/GIST_ID/raw/FILENAME ':include :type=code')
```

For example:

```markdown
[gist: script.js](https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/script.js ':include :type=code')
```

Which renders as:

[gist: script.js](https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/script.js ':include :type=code')
32 changes: 26 additions & 6 deletions docs/quickstart.md
Expand Up @@ -47,7 +47,7 @@ If you don't like `npm` or have trouble installing the tool, you can manually cr
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/themes/vue.css" />
</head>
<body>
<div id="app"></div>
Expand All @@ -56,11 +56,31 @@ If you don't like `npm` or have trouble installing the tool, you can manually cr
//...
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
</body>
</html>
```

### Specifying docsify versions

?> Note that in both of the examples below, docsify URLs will need to be manually updated when a new major version of docsify is released (e.g. `v4.x.x` => `v5.x.x`). Check the docsify website periodically to see if a new major version has been released.

Specifying a major version in the URL (`@4`) will allow your site will receive non-breaking enhancements (i.e. "minor" updates) and bug fixes (i.e. "patch" updates) automatically. This is the recommended way to load docsify resources.

```html
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/themes/vue.css" />
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
```

If you prefer to lock docsify to a specific version, specify the full version after the `@` symbol in the URL. This is the safest way to ensure your site will look and behave the same way regardless of any changes made to future versions of docsify.

```html
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4.11.4/themes/vue.css">
<script src="//cdn.jsdelivr.net/npm/docsify@4.11.4"></script>
```

### Manually preview your site

If you installed python on your system, you can easily use it to run a static server to preview your site.

```bash
Expand All @@ -72,17 +92,17 @@ cd docs && python -m SimpleHTTPServer 3000
If you want, you can show a loading dialog before docsify starts to render your documentation:

```html
<!-- index.html -->
<!-- index.html -->

<div id="app">Please wait...</div>
<div id="app">Please wait...</div>
```

You should set the `data-app` attribute if you changed `el`:

```html
<!-- index.html -->
<!-- index.html -->

<div data-app id="main">Please wait...</div>
<div data-app id="main">Please wait...</div>

<script>
window.$docsify = {
Expand Down
4 changes: 1 addition & 3 deletions src/core/render/tpl.js
@@ -1,4 +1,3 @@
import { isMobile } from '../util/env';
/**
* Render github corner
* @param {Object} data URL for the View Source on Github link
Expand Down Expand Up @@ -51,9 +50,8 @@ export function main(config) {
: '') +
'<div class="sidebar-nav"><!--sidebar--></div>' +
'</aside>';

return (
(isMobile ? `${aside}<main>` : `<main>${aside}`) +
`<main>${aside}` +
'<section class="content">' +
'<article class="markdown-section" id="main"><!--main--></article>' +
'</section>' +
Expand Down

0 comments on commit 454e694

Please sign in to comment.