-
-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new create-nuxt-content-docs package (#336)
* chore: move tests to content package * chore(content): fix readme license * chore(theme-docs): fix readme license * chore(theme-docs): add generate.routes option by default * feat: init create-nuxt-content-docs package * Update README.md * Update packages/create-nuxt-content-docs/src/saofile.js Co-authored-by: Sébastien Chopin <seb@nuxtjs.com> * Update packages/create-nuxt-content-docs/src/saofile.js Co-authored-by: Sébastien Chopin <seb@nuxtjs.com> * fix(theme-docs): put back after rebase * chore(create-nuxt-content-docs): update default template alert to success * docs: improve themes docs * chore(create-nuxt-content-docs): improve readme * chore(theme-docs): improve readme Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
- Loading branch information
1 parent
090cfde
commit 34439eb
Showing
48 changed files
with
1,102 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ coverage | |
|
||
# Packages | ||
packages/content/templates | ||
packages/create-nuxt-content-docs/template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# create-nuxt-content-docs | ||
|
||
[![npm version][npm-version-src]][npm-version-href] | ||
[![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
[![License][license-src]][license-href] | ||
[![lerna][lerna-src]][lerna-href] | ||
|
||
> Create a documentation with @nuxt/content docs theme in seconds | ||
- [📖 Read the @nuxt/content-theme-docs documentation](https://content.nuxtjs.org/themes/docs) | ||
|
||
## Usage | ||
|
||
With [yarn](https://yarnpkg.com/en/): | ||
|
||
```bash | ||
yarn create nuxt-content-docs <project-name> | ||
``` | ||
|
||
Or with [npx](https://www.npmjs.com/package/npx) (`npx` is shipped by default since [npm](https://www.npmjs.com/get-npm) `5.2.0`) | ||
|
||
```bash | ||
npx create-nuxt-content-docs <project-name> | ||
``` | ||
|
||
Or starting with npm v6.1 you can do: | ||
|
||
```bash | ||
npm init nuxt-content-docs <project-name> | ||
``` | ||
|
||
## License | ||
|
||
[MIT License](../../LICENSE) | ||
|
||
<!-- Badges --> | ||
[npm-version-src]: https://img.shields.io/npm/v/create-nuxt-content-docs/latest.svg | ||
[npm-version-href]: https://npmjs.com/package/create-nuxt-content-docs | ||
|
||
[npm-downloads-src]: https://img.shields.io/npm/dt/create-nuxt-content-docs.svg | ||
[npm-downloads-href]: https://npmjs.com/package/create-nuxt-content-docs | ||
|
||
[license-src]: https://img.shields.io/npm/l/@nuxt/content.svg | ||
[license-href]: https://npmjs.com/package/@nuxt/content | ||
|
||
[lerna-src]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg | ||
[lerna-href]: https://lerna.js.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "create-nuxt-content-docs", | ||
"version": "0.0.0", | ||
"files": [ | ||
"src", | ||
"template" | ||
], | ||
"bin": "src/cli.js", | ||
"dependencies": { | ||
"cac": "^6.6.1", | ||
"sao": "^1.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env node | ||
const path = require('path') | ||
const fs = require('fs') | ||
const sao = require('sao') | ||
const cac = require('cac') | ||
const chalk = require('chalk') | ||
const { version } = require('../package.json') | ||
|
||
const generator = path.resolve(__dirname, './') | ||
|
||
const cli = cac('create-nuxt-content-docs') | ||
|
||
cli | ||
.command('[out-dir]', 'Generate in a custom directory or current directory') | ||
.option('--verbose', 'Show debug logs') | ||
.action((outDir = '.', cliOptions) => { | ||
const files = fs.existsSync(outDir) ? fs.readdirSync(outDir) : [] | ||
// eslint-disable-next-line no-console | ||
console.log(chalk`{cyan create-nuxt-content-docs v${version}}`) | ||
if (files.length) { | ||
// eslint-disable-next-line no-console | ||
return console.log(chalk.red(`Can't create ${outDir} because there's already a non-empty directory ${outDir} existing in path.`)) | ||
} | ||
// eslint-disable-next-line no-console | ||
console.log(chalk`✨ Generating @nuxt/content documentation in {cyan ${outDir}}`) | ||
|
||
const { verbose, answers } = cliOptions | ||
const logLevel = verbose ? 4 : 2 | ||
// See https://saojs.org/api.html#standalone-cli | ||
sao({ generator, outDir, logLevel, answers, cliOptions }) | ||
.run() | ||
.catch((err) => { | ||
// eslint-disable-next-line no-console | ||
console.trace(err) | ||
process.exit(1) | ||
}) | ||
}) | ||
|
||
cli.help() | ||
|
||
cli.version(version) | ||
|
||
cli.parse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
module.exports = { | ||
prompts () { | ||
return [ | ||
{ | ||
name: 'name', | ||
message: 'Project name:', | ||
default: this.outFolder, | ||
filter: val => val.toLowerCase() | ||
}, | ||
{ | ||
name: 'title', | ||
message: 'Project title:' | ||
}, | ||
{ | ||
name: 'url', | ||
message: 'Documentation url:' | ||
}, | ||
{ | ||
name: 'github', | ||
message: 'GitHub repository (owner/name):' | ||
}, | ||
{ | ||
name: 'twitter', | ||
message: 'Twitter username (@username):' | ||
}, | ||
{ | ||
name: 'pm', | ||
message: 'Package manager:', | ||
choices: [ | ||
{ name: 'Yarn', value: 'yarn' }, | ||
{ name: 'Npm', value: 'npm' } | ||
], | ||
type: 'list', | ||
default: 'yarn' | ||
} | ||
] | ||
}, | ||
templateData () { | ||
const pm = this.answers.pm === 'yarn' ? 'yarn' : 'npm' | ||
const pmRun = this.answers.pm === 'yarn' ? 'yarn' : 'npm run' | ||
|
||
return { | ||
pm, | ||
pmRun | ||
} | ||
}, | ||
actions: [ | ||
{ | ||
type: 'add', | ||
files: '**', | ||
templateDir: '../template' | ||
}, | ||
{ | ||
type: 'move', | ||
patterns: { | ||
gitignore: '.gitignore', | ||
'_package.json': 'package.json' | ||
} | ||
} | ||
], | ||
async completed () { | ||
this.gitInit() | ||
await this.npmInstall() | ||
this.showProjectTips() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# <%= name %> | ||
|
||
## Setup | ||
|
||
Install dependencies: | ||
|
||
```bash | ||
<%= pmRun %> install | ||
``` | ||
|
||
## Development | ||
|
||
```bash | ||
<%= pmRun %> dev | ||
``` | ||
|
||
## Static Generation | ||
|
||
This will create the `dist/` directory for publishing to static hosting: | ||
|
||
```bash | ||
<%= pmRun %> generate | ||
``` | ||
|
||
To preview the static generated app, run `<%= pmRun %> start` | ||
|
||
For detailed explanation on how things work, checkout [nuxt/content](https://content.nuxtjs.org) and [@nuxt/content theme docs](https://content.nuxtjs.org/themes-docs). |
29 changes: 29 additions & 0 deletions
29
packages/create-nuxt-content-docs/template/content/en/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: Introduction | ||
description: 'Welcome to your new documentation!' | ||
position: 1 | ||
category: Getting started | ||
features: | ||
- Blazing fast hot reload in development | ||
- Vue components in Markdown | ||
- Full-text search | ||
- Support static site generation with `nuxt generate` | ||
- Powerful QueryBuilder API (MongoDB like) | ||
- Syntax highlighting to code blocks in markdown files using PrismJS. | ||
- Table of contents generation | ||
- Handles Markdown, CSV, YAML, JSON(5), XML | ||
- Extend with custom parsers | ||
- Extend with hooks | ||
--- | ||
|
||
<alert type="success"> | ||
|
||
Your documentation has been created successfully! | ||
|
||
</alert> | ||
|
||
## Features | ||
|
||
<list :items="features"></list> | ||
|
||
<p class="flex items-center">Enjoy light and dark mode: <app-color-switcher class="inline-flex ml-2"></app-color-switcher></p> |
10 changes: 10 additions & 0 deletions
10
packages/create-nuxt-content-docs/template/content/settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"title": "<%= title %>", | ||
"url": "<%= url %>", | ||
"logo": { | ||
"light": "/logo-light.svg", | ||
"dark": "/logo-dark.svg" | ||
}, | ||
"github": "<%= github %>", | ||
"twitter": "<%= twitter %>" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import theme from '@nuxt/content-theme-docs' | ||
|
||
export default theme({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "<%= name %>", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "nuxt", | ||
"build": "nuxt build", | ||
"start": "nuxt start", | ||
"generate": "nuxt generate" | ||
}, | ||
"dependencies": { | ||
"@nuxt/content-theme-docs": "^0.3.1", | ||
"nuxt": "^2.14.0" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.