diff --git a/build/build.js b/build/build.js index 7dfa6b536..563861373 100644 --- a/build/build.js +++ b/build/build.js @@ -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) diff --git a/docs/deploy.md b/docs/deploy.md index d68b5c9dc..2c96060f9 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -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 + ``` + diff --git a/docs/embed-files.md b/docs/embed-files.md index d50387477..d1a447338 100644 --- a/docs/embed-files.md +++ b/docs/embed-files.md @@ -1,15 +1,16 @@ # 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') @@ -17,11 +18,13 @@ 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` @@ -29,13 +32,13 @@ This is a supported embedding type: * **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') @@ -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') diff --git a/docs/quickstart.md b/docs/quickstart.md index 5dc75728c..39a9328b1 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -47,7 +47,7 @@ If you don't like `npm` or have trouble installing the tool, you can manually cr - +
@@ -56,11 +56,31 @@ If you don't like `npm` or have trouble installing the tool, you can manually cr //... } - + ``` +### 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 + + +``` + +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 + + +``` + +### 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 @@ -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 - + -
Please wait...
+
Please wait...
``` You should set the `data-app` attribute if you changed `el`: ```html - + -
Please wait...
+
Please wait...