Skip to content

Commit

Permalink
build: set up lint and format scripts (#4)
Browse files Browse the repository at this point in the history
Co-authored-by: Xinyu Liu <meteor.lxy@foxmail.com>
  • Loading branch information
Mister-Hope and meteorlxy committed Dec 10, 2023
1 parent fed55ed commit 7c79898
Show file tree
Hide file tree
Showing 68 changed files with 372 additions and 267 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm lint

- name: Build docs with ${{ matrix.bundler }}
run: pnpm docs:build
env:
Expand Down
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
pnpm-lock.yaml
*.html
*.md
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ VuePress documentation repository.

## Deployments

- Release deployment: https://v2.vuepress.vuejs.org
- Developer deployment: https://vuepress.github.io
- Release deployment: <https://v2.vuepress.vuejs.org>
- Developer deployment: <https://vuepress.github.io>

## License

Expand Down
4 changes: 3 additions & 1 deletion docs/.vuepress/public/new.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<script>window.location = 'https://stackblitz.com/fork/vuepress'</script>
<script>
window.location = 'https://stackblitz.com/fork/vuepress'
</script>
2 changes: 1 addition & 1 deletion docs/advanced/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ The above figure shows the core process of VuePress Node App and the hooks of [P
- In the **dev / build** stage:
- Bundler will be resolved:
- [extendsBundlerOptions](../reference/plugin-api.md#extendsbundleroptions) hook will be processed to create bundler configuration.
- [alias](../reference/plugin-api.md#alias) hook and [define](../reference/plugin-api.md#define) hook would be used in bundler configuration, so they will be processed here.
- [alias](../reference/plugin-api.md#alias) hook and [define](../reference/plugin-api.md#define) hook would be used in bundler configuration, so they will be processed here.
30 changes: 16 additions & 14 deletions docs/advanced/cookbook/markdown-and-vue-sfc.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ _Current count is: {{ count }}_
<script setup>
import { h, ref } from 'vue'
const RedDiv = (_, ctx) => h(
'div',
{
class: 'red-div',
},
ctx.slots.default()
)
const RedDiv = (_, ctx) =>
h(
'div',
{
class: 'red-div',
},
ctx.slots.default(),
)
const msg = 'Vue in Markdown'
const count = ref(0)
</script>
Expand All @@ -60,13 +61,14 @@ _Current count is: {{ count }}_
<script setup>
import { h, ref } from 'vue'

const RedDiv = (_, ctx) => h(
'div',
{
class: 'red-div',
},
ctx.slots.default()
)
const RedDiv = (_, ctx) =>
h(
'div',
{
class: 'red-div',
},
ctx.slots.default(),
)
const msg = 'Vue in Markdown'
const count = ref(0)
</script>
Expand Down
5 changes: 4 additions & 1 deletion docs/advanced/cookbook/passing-data-to-client-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ First, write a temp file `foo.js`, which will be generated in the [temp](../../r
export default (options) => ({
async onPrepared(app) {
// write temp file
await app.writeTemp('foo.js', `export const foo = ${JSON.stringify(options.foo)}`)
await app.writeTemp(
'foo.js',
`export const foo = ${JSON.stringify(options.foo)}`,
)
},
})
```
Expand Down
6 changes: 3 additions & 3 deletions docs/advanced/cookbook/usage-of-client-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const pluginOrTheme = {
}
```

Inside the client config file, `@vuepress/client` package provides a helper function [defineClientConfig](../../reference/client-api.md#defineclientconfig) to help you define the client config:
Inside the client config file, `@vuepress/client` package provides a helper function [defineClientConfig](../../reference/client-api.md#defineclientconfig) to help you define the client config:

```ts
import { defineClientConfig } from '@vuepress/client'
Expand Down Expand Up @@ -119,7 +119,7 @@ export default defineClientConfig({
// provide a value that can be injected by layouts, pages and other components
const count = ref(0)
provide('count', count)
}
},
})
```

Expand All @@ -139,7 +139,7 @@ export default defineClientConfig({
// use DOM API after mounted
document.querySelector('#app')
})
}
},
})
```

Expand Down
12 changes: 5 additions & 7 deletions docs/advanced/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before reading this guide, you'd better learn the VuePress [architecture](./arch

## Create a Plugin

A plugin should be a plain JavaScript object that satisfies the [Plugin API](../reference/plugin-api.md), which is called a *Plugin Object*:
A plugin should be a plain JavaScript object that satisfies the [Plugin API](../reference/plugin-api.md), which is called a _Plugin Object_:

```ts
const fooPlugin = {
Expand All @@ -15,7 +15,7 @@ const fooPlugin = {
}
```

A plugin could also be a function that receives the [app instance](../reference/node-api.md#app) as the param and returns a *Plugin Object*, which is called a *Plugin Function*:
A plugin could also be a function that receives the [app instance](../reference/node-api.md#app) as the param and returns a _Plugin Object_, which is called a _Plugin Function_:

```ts
const barPlugin = (app) => {
Expand All @@ -26,7 +26,7 @@ const barPlugin = (app) => {
}
```

A plugin usually needs to allow user options, so we typically provide users with a function to receive options, and returns a *Plugin Object* or a *Plugin Function*. Then your plugin should be converted like this:
A plugin usually needs to allow user options, so we typically provide users with a function to receive options, and returns a _Plugin Object_ or a _Plugin Function_. Then your plugin should be converted like this:

```ts
const fooPlugin = (options) => {
Expand All @@ -53,11 +53,9 @@ After creating a plugin, you should follow some conventions in the [package.json
```json
{
"name": "vuepress-plugin-foo",
"keywords": [
"vuepress-plugin"
]
"keywords": ["vuepress-plugin"]
}
```

- Set `name` to follow the naming convention, i.e. `vuepress-plugin-xxx` or `@org/vuepress-plugin-xxx`, which should be consistent with the [name](../reference/plugin-api.md#name) field of the *Plugin Object*.
- Set `name` to follow the naming convention, i.e. `vuepress-plugin-xxx` or `@org/vuepress-plugin-xxx`, which should be consistent with the [name](../reference/plugin-api.md#name) field of the _Plugin Object_.
- Set `keywords` to include `vuepress-plugin`, so that users can search your plugin on NPM.
8 changes: 3 additions & 5 deletions docs/advanced/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before reading this guide, you'd better learn the guide of [Writing a Plugin](./

## Create a Theme

A VuePress theme is a special plugin, which should satisfy the [Theme API](../reference/theme-api.md). Like plugins, a theme should also be a *Theme Object* or a *Theme Function*, and could be wrapped with a function to receive options:
A VuePress theme is a special plugin, which should satisfy the [Theme API](../reference/theme-api.md). Like plugins, a theme should also be a _Theme Object_ or a _Theme Function_, and could be wrapped with a function to receive options:

```ts
import { getDirname, path } from '@vuepress/utils'
Expand Down Expand Up @@ -90,11 +90,9 @@ Also, there are some conventions for theme in [package.json](https://docs.npmjs.
```json
{
"name": "vuepress-theme-foo",
"keywords": [
"vuepress-theme"
]
"keywords": ["vuepress-theme"]
}
```

- Set `name` to follow the naming convention: `vuepress-theme-xxx` or `@org/vuepress-theme-xxx`, which should be consistent with the [name](../reference/theme-api.md#name) field of the *Theme Object*.
- Set `name` to follow the naming convention: `vuepress-theme-xxx` or `@org/vuepress-theme-xxx`, which should be consistent with the [name](../reference/theme-api.md#name) field of the _Theme Object_.
- Set `keywords` to include `vuepress-theme`, so that users can search your theme on NPM.
3 changes: 2 additions & 1 deletion docs/guide/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ In most cases, you don't need to worry about the reference path of those public

```md
<!-- you don't need to prepend `/bar/` to `/images/hero.png` manually -->

![VuePress Logo](/images/hero.png)
```

However, sometimes you may have some dynamical links referencing public files, especially when you are authoring a custom theme. In such case, the `base` could not be handled automatically. To help with that, VuePress provides a [withBase](../reference/client-api.md#withbase) helper to prepend `base` for you:

```vue
<template>
<img :src="withBase(logoPath)">
<img :src="withBase(logoPath)" />
</template>
<script setup>
Expand Down
4 changes: 4 additions & 0 deletions docs/guide/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The following guides are based on some shared assumptions:
Create `.github/workflows/docs.yml` to set up the workflow.

::: details Click to expand sample config

```yaml
name: docs

Expand Down Expand Up @@ -81,6 +82,7 @@ jobs:
# @see https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

:::

::: tip
Expand All @@ -98,6 +100,7 @@ Please refer to [GitHub Pages official guide](https://pages.github.com/) for mor
2. Create `.gitlab-ci.yml` to set up [GitLab CI](https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/) workflow.

::: details Click to expand sample config

```yaml
# choose a docker image to use
image: node:18-buster
Expand Down Expand Up @@ -129,6 +132,7 @@ pages:
paths:
- public
```

:::

::: tip
Expand Down
30 changes: 24 additions & 6 deletions docs/guide/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@ Take our documentation source files as an example:

```md
<!-- relative path -->

[Home](../README.md)
[Config Reference](../reference/config.md)
[Getting Started](./getting-started.md)
[Getting Started](./getting-started.md)

<!-- absolute path -->

[Guide](/guide/README.md)
[Config Reference > markdown.links](/reference/config.md#links)
[Config Reference > markdown.links](/reference/config.md#links)

<!-- URL -->
[GitHub](https://github.com)

[GitHub](https://github.com)
```

**Converted to**
Expand All @@ -66,8 +71,12 @@ Take our documentation source files as an example:
<RouterLink to="/reference/config.html">Config Reference</RouterLink>
<RouterLink to="/guide/getting-started.html">Getting Started</RouterLink>
<RouterLink to="/guide/">Guide</RouterLink>
<RouterLink to="/reference/config.html#links">Config Reference &gt; markdown.links</RouterLink>
<a href="https://github.com" target="_blank" rel="noopener noreferrer">GitHub</a>
<RouterLink to="/reference/config.html#links">
Config Reference &gt; markdown.links
</RouterLink>
<a href="https://github.com" target="_blank" rel="noopener noreferrer">
GitHub
</a>
</template>
```

Expand All @@ -78,7 +87,7 @@ Take our documentation source files as an example:
[Getting Started](./getting-started.md)
[Guide](/guide/README.md)
[Config Reference > markdown.links](/reference/config.md#links)
[GitHub](https://github.com)
[GitHub](https://github.com)

**Explanation**

Expand Down Expand Up @@ -254,11 +263,13 @@ If you want to make Vue syntax work in those languages anyway, try to disable th
````md
```md
<!-- This will be kept as is by default -->

1 + 2 + 3 = {{ 1 + 2 + 3 }}
```

```md:no-v-pre
<!-- This will be compiled by Vue -->

1 + 2 + 3 = {{ 1 + 2 + 3 }}
```

Expand All @@ -272,11 +283,13 @@ const onePlusTwoPlusThree = {{ 1 + 2 + 3 }}

```md
<!-- This will be kept as is -->

1 + 2 + 3 = {{ 1 + 2 + 3 }}
```

```md:no-v-pre
<!-- This will be compiled by Vue -->
1 + 2 + 3 = {{ 1 + 2 + 3 }}
```

Expand All @@ -302,27 +315,31 @@ You can import code blocks from files with following syntax:

```md
<!-- minimal syntax -->

@[code](../foo.js)
```

If you want to partially import the file:

```md
<!-- partial import, from line 1 to line 10 -->

@[code{1-10}](../foo.js)
```

The code language is inferred from the file extension, while it is recommended to specify it explicitly:

```md
<!-- specify the code language -->

@[code js](../foo.js)
```

In fact, the second part inside the `[]` will be treated as the mark of the code fence, so it supports all the syntax mentioned in the above [Code Blocks](#code-blocks) section:

```md
<!-- line highlighting -->

@[code js{2,4-5}](../foo.js)
```

Expand Down Expand Up @@ -356,6 +373,7 @@ export default {

```md
<!-- it will be resolved to 'path/to/src/foo.js' -->

@[code](@src/foo.js)
```

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Assuming this is the directory structure of your markdown files:
Take the `docs` directory as your [sourceDir](../reference/cli.md), e.g. you are running `vuepress dev docs` command. Then the route paths of your markdown files would be:

| Relative Path | Route Path |
|-----------------------------|-------------------------------|
| --------------------------- | ----------------------------- |
| `/README.md` | `/` |
| `/index.md` | `/` |
| `/contributing.md` | `/contributing.html` |
Expand Down
6 changes: 2 additions & 4 deletions docs/guide/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { googleAnalyticsPlugin } from '@vuepress/plugin-google-analytics'
export default {
plugins: [
googleAnalyticsPlugin({
id: 'G-XXXXXXXXXX'
id: 'G-XXXXXXXXXX',
}),
],
}
Expand All @@ -38,9 +38,7 @@ But if you have too many things to do in your config file, you can consider to e
import myPlugin from './path/to/my-plugin.js'

export default {
plugins: [
myPlugin(),
],
plugins: [myPlugin()],
}
```

Expand Down

0 comments on commit 7c79898

Please sign in to comment.