Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add some documentation #2707

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
TODOs.md
packages/@vuepress/shared-utils/lib/
types
.vscode
53 changes: 53 additions & 0 deletions packages/@vuepress/vue-cli-plugin-vuepress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# vue-cli-plugin-vuepress

> The official vue-cli plugin for VuePress

## Usage

### With vue ui

- Run `vue ui` in a terminal.
- Choose an existing Vue project or create a new one
- Go to the `Plugins` section
- Click the `Add plugin` button
- Search `@vuepress/vue-cli-plugin-vuepress`
- Install the plugin and answer questions

If you go to the `Tasks` section, you can see that you now have access to two new VuePress commands:

- docs:dev (Run your VuePress site in dev mode)
- docs:build (Build your VuePress site)

Those commands are available in your `package.json` in the `scripts` section.

To edit/bootstrap your VuePress configuration, go to the `Configuration` section and select VuePress.
Note that if you edit your VuePress config while it's running in dev mode, it will be live reloaded.

**⚠️ Some configurations are not covered by this ui plugin. Refer to the [official VuePress documentaion](https://vuepress.vuejs.org/) for advanced config ⚠️**

### With vue-cli

- Run `vue add @vuepress/vue-cli-plugin-vuepress` in a terminal:
- Answer questions

Run `yarn docs:dev` for dev mode or `yarn docs:build` to build your VuePress site.
See more details in the [official VuePress documentaion](https://vuepress.vuejs.org/).

## Local Development

### 1. Clone this repository

```
git clone https://github.com/vuepressjs/vue-cli-plugin-vuepress.git
cd vue-cli-plugin-vuepress
```

### 2. Install dependencies

```
yarn
```

### 3. Install plugin locally

Please refer to the official [vue-cli documentation](https://cli.vuejs.org/dev-guide/plugin-dev.html#installing-plugin-locally)
13 changes: 13 additions & 0 deletions packages/@vuepress/vue-cli-plugin-vuepress/generator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = async (api, projectOptions) => {
api.extendPackage({
scripts: {
'docs:dev': 'vuepress dev docs',
'docs:build': 'vuepress build docs'
},
devDependencies: {
vuepress: '^1.1.0'
}
})

api.render('./template', projectOptions)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# <%= title %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
title: '<%= title %>',
description: '<%= description %>'
}
1 change: 1 addition & 0 deletions packages/@vuepress/vue-cli-plugin-vuepress/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = () => {}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions packages/@vuepress/vue-cli-plugin-vuepress/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@vuepress/vue-cli-plugin-vuepress",
"version": "1.1.0",
"description": "vue-cli plugin for VuePress",
"main": "index.js",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/vuepress.git",
"directory": "packages/@vuepress/vue-cli-plugin-vuepress"
},
"keywords": [
"vuepress",
"vue",
"vue-cli",
"bootstrap"
],
"author": "Franck Abgrall",
"license": "MIT",
"bugs": {
"url": "https://github.com/vuejs/vuepress/issues"
},
"homepage": "https://github.com/vuejs/vuepress#readme",
"dependencies": {
"load-json-file": "^6.2.0"
}
}
20 changes: 20 additions & 0 deletions packages/@vuepress/vue-cli-plugin-vuepress/prompts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = [
{
name: 'title',
type: 'input',
message: 'Title',
description: 'Title for the site.',
link: 'https://vuepress.vuejs.org/config/#title',
group: 'General settings',
validate: input => !!input
},
{
name: 'description',
type: 'input',
message: 'Description',
description: 'Description for the site.',
link: 'https://vuepress.vuejs.org/config/#description',
group: 'General settings',
validate: input => !!input
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const flattenDeep = require('lodash/flattenDeep')

const navbarItems = require('./navbarItems')
const sidebar = require('./sidebar')
const navigation = require('./navigation')
const searchBox = require('./searchBox')
const pages = require('./pages')
const { isDefaultTheme } = require('../utils')

module.exports = data => {
const promptItems = flattenDeep([
navigation(data),
navbarItems(data),
sidebar(data),
searchBox(data),
pages(data)
])

return promptItems.map(item => ({
...item,
when: answer => {
if (!isDefaultTheme(answer)) {
return false
} else if (item.when) {
return item.when(answer)
}

return true
}
}))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const times = require('lodash/times')
const get = require('lodash/get')

const isNavBarVisible = answer => answer.themeConfig.navbar === true
const isPreviousLinkDefined = (answer, previousLinkIndex) => previousLinkIndex === -1
|| (
get(answer, `themeConfig.nav[${previousLinkIndex}].text`)
&& get(answer, `themeConfig.nav[${previousLinkIndex}].link`)
)

const NAVLINKS_GROUP_NAME = 'Navbar items'
const NAVBAR_LINKS_COUNT = 10

module.exports = data => times(NAVBAR_LINKS_COUNT, count => {
const shouldDisplayItem = answer => isNavBarVisible(answer)
&& isPreviousLinkDefined(answer, count - 1)

return [{
when: shouldDisplayItem,
name: `themeConfig.nav.${count}.text`,
type: 'input',
message: `Item ${count + 1}: text`,
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#navbar',
group: NAVLINKS_GROUP_NAME,
value: get(data, `config.themeConfig.nav[${count}].text`)
}, {
when: shouldDisplayItem,
name: `themeConfig.nav.${count}.link`,
type: 'input',
message: `Item ${count + 1}: link`,
description: 'This is the targeted page. Can be both external (example: https://vuepress.vuejs.org) or internal (example: /my/page/path) URL.',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#navbar',
group: NAVLINKS_GROUP_NAME,
value: get(data, `config.themeConfig.nav[${count}].link`)
}]
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const get = require('lodash/get')

const GROUP_NAME = 'Navbar settings'

module.exports = data => ([
{
name: 'themeConfig.navbar',
type: 'confirm',
message: 'Show navigation bar',
description: 'Disable the navbar globally.',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#disable-the-navbar',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.navbar'),
default: true
},
{
name: 'themeConfig.logo',
type: 'input',
message: 'Logo path',
description: 'You can add a logo to the navbar. Logo can be placed in public folder.',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#navbar-logo',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.logo')
}
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
const get = require('lodash/get')

const { emptyStringToUndefined } = require('../utils')

const GROUP_NAME = 'Pages settings'

module.exports = data => ([
{
name: 'themeConfig.lastUpdated',
type: 'input',
message: 'Last updated label',
description: 'This option allows you to get the UNIX timestamp(ms) of each file’s last git commit, and it will also be displayed at the bottom of each page in an appropriate format. Enter the string that will be displayed as a prefix (example: \'Last updated\')',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#last-updated',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.lastUpdated')
},
{
name: 'themeConfig.repo',
type: 'input',
message: 'Github/Gitlab/Bitbucket repository url',
description: 'Auto generates a Github/Gitlab/Bitbucket link in the navbar and "Edit this page" links at the bottom of each page. (value example: "https://github.com/vuejs/vuepress")',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#git-repository-and-edit-links',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.repo')
},
{
when: answer => get(answer, 'themeConfig.repo'),
name: 'themeConfig.repoLabel',
type: 'input',
message: 'Repository label in navbar',
description: 'Defaults to "GitHub"/"GitLab"/"Bitbucket" depending on platform you\'re using',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#git-repository-and-edit-links',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.repoLabel')
},
{
name: 'themeConfig.docsRepo',
type: 'input',
message: 'Github/Gitlab/Bitbucket documentation repository url',
description: 'Use this field if your doc is in a different repo from your main project.',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#git-repository-and-edit-links',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.docsRepo'),
transform: emptyStringToUndefined
},
{
when: answer => get(answer, 'themeConfig.docsRepo'),
name: 'themeConfig.docsDir',
type: 'input',
message: 'Documentation directory',
description: 'Use this if your documentation is not at the root of the repo',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#git-repository-and-edit-links',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.docsDir')
},
{
when: answer => get(answer, 'themeConfig.docsRepo'),
name: 'themeConfig.docsBranch',
type: 'input',
message: 'Documentation branch',
description: "Use this field if your docs are in a specific branch (defaults to 'master')",
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#git-repository-and-edit-links',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.docsBranch'),
default: 'master'
},
{
name: 'themeConfig.editLinks',
type: 'confirm',
message: 'Edit links',
description: 'Allows to display edit link on all pages',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#git-repository-and-edit-links',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.editLinks'),
default: false
},
{
when: answer => get(answer, 'themeConfig.editLinks'),
name: 'themeConfig.editLinkText',
type: 'input',
message: 'Edit link text',
description: 'Allows to custom text for edit links',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#git-repository-and-edit-links',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.editLinkText'),
default: 'Edit this page'
},
{
name: 'themeConfig.nextLinks',
type: 'confirm',
message: 'Next links',
description: 'Allows to hide next page links on all pages',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#git-repository-and-edit-links',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.nextLinks'),
default: true
},
{
name: 'themeConfig.prevLinks',
type: 'confirm',
message: 'Prev links',
description: 'Allows to hide prev page links on all pages',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#git-repository-and-edit-links',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.prevLinks'),
default: true
}
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

const get = require('lodash/get')

const { isNumber } = require('../validators')

const GROUP_NAME = 'Search box'

module.exports = data => ([
{
name: 'themeConfig.search',
type: 'confirm',
message: 'Show search box',
description: 'Show the search box globally.',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#built-in-search',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.search'),
default: true
},
{
when: answer => get(answer, 'themeConfig.search'),
name: 'themeConfig.searchMaxSuggestions',
type: 'input',
message: 'Max suggestions',
description: 'Allows to customize how many suggestions will be shown in the search box.',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#built-in-search',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.searchMaxSuggestions'),
default: '5',
validate: isNumber,
transform: Number
},
{
when: answer => get(answer, 'themeConfig.search'),
name: 'themeConfig.searchPlaceholder',
type: 'input',
message: 'Search placeholder',
description: 'Define a placeholder for the search box.',
link: 'https://vuepress.vuejs.org/theme/default-theme-config.html#search-placeholder',
group: GROUP_NAME,
value: get(data, 'config.themeConfig.searchPlaceholder'),
default: ''
}
])

Loading