提交 36daecdd 编写于 作者: E Evan You

refactor stylus

上级 6db5e83a
# Default Theme Config
## Accent Color
## Simple CSS Override
## Logo
If you wish to apply simple overrides to the styling of the default theme, you can create an `.vuepress/override.styl` file. This is a [Stylus](http://stylus-lang.com/) file but you can use normal CSS syntax as well.
## Navbar
There are a few color variables you can tweak:
### nav
``` stylus
// showing default values
$accentColor = #3eaf7c
$textColor = #2c3e50
$borderColor = #eaecef
$codeBgColor = #282c34
```
## Options Reference
## Sidebar
### logo
### nav
### sidebar
### sidebarDepth
## GitHub Repo & Edit Links
### editLinks
## Search
### docsDir
## Simple CSS Override
### docsBranch
......@@ -4,20 +4,49 @@ next: ./getting-started
# Introduction
VuePress is composed of two parts: a minimalistic static site generator with a Vue-powered theming system, and a default theme optimized for writing technical documentation. In fact, it was created to support the documentation needs of Vue's own sub projects.
A VuePress site is in fact a Single-Page Application (SPA) powered by [Vue](http://vuejs.org/), [Vue Router](https://github.com/vuejs/vue-router) and [webpack](http://webpack.js.org/). If you've used Vue before, you will notice the familiar development experience when you are writing or developing custom themes (you can even use Vue DevTools to debug your custom theme!).
When deployed, each page has its own pre-rendered static HTML, providing great loading performance and is SEO-friendly. Once the page is loaded, Vue takes over the static content and turns it into a full SPA. Additional pages are fetched on demand as the user navigates around the site.
## How It Works
## Todo Features
During the build, we create a server-rendered version of the app and render the corresponding HTML by virtually visiting each route. This approach is inspired by [Nuxt](https://nuxtjs.org/)'s `nuxt generate` command and other projects like [Gatsby](https://www.gatsbyjs.org/).
Each markdown file is compiled into HTML with [markdown-it](https://github.com/markdown-it/markdown-it) and then processed as the template of a Vue component. This allows you to directly use Vue inside your markdown files and is great when you need to embed dynamic content.
### PWA Support
## Features
### Dropdown Items in Navbar
- [Built-in markdown extensions](./markdown.md) optimized for technical documentation
- [Ability to leverage Vue inside markdown files](./using-vue.md)
- [Vue-powered custom theme system](./custom-thems)
- A default theme with:
- Responsive layout
- Simple out-of-the-box header-based search
- Customizable navbar and sidebar
- Auto-generated GitHub link and page edit links
### Algolia DocSearch Integration
## Todo Features
VuePress is still a work in progress. There are a few things that it currently does not support but are planned:
- PWA Support
- Blogging support
- Dropdown Items in Navbar
- Google Analytics Integration
- Algolia DocSearch Integration
## Why Not ...?
### Nuxt / NuxtDoc
### Nuxt
Nuxt is capable of doing what VuePress does, but it is designed for building applications. VuePress is focused on content-centric static sites and provides features tailored for technical documentation out of the box.
### Docsify / Docute
Both are great projects and also Vue-powered. Except they are both completely runtime-driven and thus not SEO-friendly. If you don't care about SEO and don't want to mess with installing dependencies, these are still great choices.
### Hexo
Hexo is great - in fact, we are probably still a long way to go from migrating away from it for our main site. The biggest problem is that its theming system is very static and string-based - we really want to leverage Vue for both the layout and the interactivity. Also, Hexo's markdown rendering isn't the most flexible to configure.
......@@ -6,6 +6,8 @@ next: ./markdown
## Global Installation
If you just want to play around with VuePress, you can install it globally:
``` bash
# install globally
npm install -g vuepress
......@@ -22,6 +24,8 @@ vuepress build .
## Inside an Existing Project
If you have an existing project and would like to keep documentation inside the project, you should install VuePress as a local dependency. This setup also allows you to use CI or services like Netlify for automatic deployment on push.
``` bash
# install as a local dependency
npm install -D vuepress
......@@ -62,9 +66,16 @@ By default the built files will be in `.vuepress/dist`, which can be configured
## Basic Configurations
### Title and Description
Right now our page is pretty minimal, and the user has no way to navigate around the site. To customize your site, let's first create a `.vuepress` directory inside your docs directory. This is where all VuePress-specific files will be placed in.
The essential file for configuring a VuePress site is `.vuepress/config.js`, which simply exports a JavaScript object:
### Logo
``` js
module.exports = {
title: 'Hello VuePress',
description: 'Just playing around'
}
```
### Navbar Links
......
......@@ -41,7 +41,7 @@ export default {
</script>
<style lang="stylus">
@import './styles/config.stylus'
@import './styles/config.styl'
.home
padding $navbarHeight 2rem 0
......
......@@ -139,4 +139,4 @@ function updateMetaTags (page, current) {
</script>
<style src="prismjs/themes/prism-tomorrow.css"></style>
<style src="./styles/theme.stylus" lang="stylus"></style>
<style src="./styles/theme.styl" lang="stylus"></style>
......@@ -46,7 +46,7 @@ export default {
</script>
<style lang="stylus">
@import './styles/config.stylus'
@import './styles/config.styl'
.nav-links
display inline-block
......
......@@ -29,7 +29,7 @@ export default {
</script>
<style lang="stylus">
@import './styles/config.stylus'
@import './styles/config.styl'
.navbar
padding 0.7rem 1.5rem
......
......@@ -64,7 +64,7 @@ export default {
</script>
<style lang="stylus">
@import './styles/config.stylus'
@import './styles/config.styl'
.edit-link
padding-top 0 !important
......
......@@ -113,7 +113,7 @@ export default {
</script>
<style lang="stylus">
@import './styles/config.stylus'
@import './styles/config.styl'
.search-box
display inline-block
......
......@@ -136,7 +136,7 @@ function resolveItem (item, pages, base, isNested) {
</script>
<style lang="stylus">
@import './styles/config.stylus'
@import './styles/config.styl'
.sidebar
ul
......@@ -144,7 +144,7 @@ function resolveItem (item, pages, base, isNested) {
margin 0
list-style-type none
a
display block
display inline-block
.nav-links
display none
border-bottom 1px solid $borderColor
......
......@@ -7,7 +7,7 @@
</template>
<style lang="stylus">
@import './styles/config.stylus'
@import './styles/config.styl'
.sidebar-button
display none
......
......@@ -61,7 +61,7 @@ function renderChildren (h, children, path, route, maxDepth, depth = 1) {
</script>
<style lang="stylus">
@import './styles/config.stylus'
@import './styles/config.styl'
.sidebar .sidebar-sub-headers
padding-left 1rem
......
@import './config.stylus'
@require './config'
.arrow
display inline-block
......
@import './config.stylus'
@require './config'
p, h1, h2, h3, h4, h5, h6
code
......
// colors
@import '../../app/.temp/accent.stylus' // generated from user config
$accentColor = #3eaf7c
$textColor = #2c3e50
$borderColor = #eaecef
$codeBgColor = #282c34
......@@ -13,3 +13,5 @@ $contentWidth = 740px
$MQNarrow = 959px
$MQMobile = 719px
$MQMobileNarrow = 419px
@import '../../app/.temp/override.styl' // generated from user config
@import './config.stylus'
@require './config'
$mobileSidebarWidth = $sidebarWidth * 0.82
......
@import './config.stylus'
@import './nprogress.stylus'
@import './code.stylus'
@import './custom-blocks.stylus'
@import './arrow.stylus'
@require './config'
@require './nprogress'
@require './code'
@require './custom-blocks'
@require './arrow'
html, body
padding 0
......@@ -154,4 +154,4 @@ th, td
.page
padding-left 0
@import './mobile.stylus'
@require './mobile.styl'
......@@ -44,10 +44,11 @@ if (!Object.assign) Object.assign = require('object-assign')`
}
writeTemp('polyfill.js', polyfillCode)
// 5. handle user accentColor
// 5. handle user override
if (options.useDefaultTheme) {
const accentColor = options.siteData.themeConfig.accentColor || '#3eaf7c'
writeTemp('accent.stylus', `$accentColor = ${accentColor}`)
const overridePath = path.resolve(sourceDir, '.vuepress/override.styl')
const hasUserOverride = fs.existsSync(overridePath)
writeTemp(`override.styl`, hasUserOverride ? `@import(${JSON.stringify(overridePath)})` : ``)
}
return options
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册