Skip to content

Commit

Permalink
doc(vuepress): npm start should serve from src for live-reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
about-code committed Sep 25, 2019
1 parent a369bfd commit 8930098
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions doc/vuepress.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Using *glossarify-md* with [vuepress](https://vuepress.vuejs.org)

Below we assume a sample project structure like this:
Below we assume a *sample* project structure like this:

```
${root}
Expand All @@ -19,30 +19,14 @@ ${root}
| '- glossary.md
|
+- target/ <-- Generated
|
|- glossarify-md.conf.json
|- package.json
'- .gitignore
```

Add prebuild steps to your *package.json*:

*package.json*
```json

"scripts": {
"prestart": "npm run glossarify",
"prebuild": "npm run glossarify",
"glossarify": "glossarify-md --config ./glossarify-md.conf.json",
"start": "cd ./target && vuepress dev",
"build": "cd ./target && vuepress build",
}
```

We configure our *glossarify-md.conf.json* to write outputs to *../target*. You *may* add `outDir` to your `.gitignore`. Though, glossary links will also be navigable on GitHub, so this may also be what you
*actually* want to put on GitHub.
> **Tip:** As a matter of choice you may also decide for a different structure with `.vuepress` *next to* `baseDir` rather than being a child of it. This will reduce the number of files being copied from `baseDir` to `outDir`.
> Note that all paths inside the file are being interpreted relativ to `baseDir`, so to write outputs to a sibling directory we need to step out of `baseDir`.
## Configure glossarify-md

*glossarify-md.conf.json*
```json
Expand All @@ -51,7 +35,7 @@ We configure our *glossarify-md.conf.json* to write outputs to *../target*. You
"baseDir": "./src",
"outDir": "../target",
"includeFiles": ["."],
"excludeFiles": ["**/*exclude*/**"],
"excludeFiles": ["**/*.exclude.md"],
"keepRawFiles": ["**/*.raw.md"],
"glossaries": [
{ "file": "./glossary.md", "termHint": ""},
Expand All @@ -60,17 +44,26 @@ We configure our *glossarify-md.conf.json* to write outputs to *../target*. You
"ignoreCase": false
}
```
Files in `baseDir` except those in `excludeFiles` will be copied to `outDir`. Relative paths to your assets remain stable.

> In the example any files apart from those in a folder which has *exclude* in its name will be copied.
> **Note:** All relative paths inside the config file are being interpreted
> relativ to `baseDir`.
There might be markdown files which should be part of a vuepress book but
should not be linkified. Those can be listed in `keepRawFiles`. They will be copied but won't be processed. Now run
So we set `outDir` to `../target`. Consider adding your `outDir` to *.gitignore*.

## Build Scripts

*package.json*
```json

"scripts": {
"glossarify": "glossarify-md --config ./glossarify-md.conf.json",
"start": "vuepress dev src",
"glossarified": "npm run glossarify && vuepress dev target",
"build": "npm run glossarify && vuepress build target",
}
```
npm run build
```
`npm start` builds and serves files from `src/`. Unfortunately, the preview won't be glossarified but live-reloading your changes to `src/` is likely to be more important to you when writing.

`npm run glossarified` serves a glossarified preview from `target/`.

Any glossary terms defined *glossary.md* and found in
one of the *page* files should now be linked. Mind the [excluded syntactic
positions](../README.md#Result).
More information see [README.md](../README.md).

0 comments on commit 8930098

Please sign in to comment.