提交 404a0a1c 编写于 作者: E Evan You

wip mobile

上级 b4ca0e4c
......@@ -15,6 +15,7 @@ module.exports = {
'/assets',
'/using-vue',
'/config',
'/default-theme',
'/theming',
'/deploy'
]
......
......@@ -8,15 +8,15 @@ navTitle: Getting Started
## Why
- Writing first: minimal setup, all you need is a markdown file.
- **Writing First**: minimal setup, all you need is a markdown file.
- Vue-powered: the layout system is a Vue app. It's also pre-rendered into static HTML. And you can register and use Vue components inside markdown content.
- **Vue-powered**: Use custom Vue components inside markdown, and develop custom themes using Vue single file components.
- Flexible: develop with full power of webpack (hot-reload, pre-processors support), generate SEO-friendly static HTML, and works as an SPA after initial page load.
- **Great Dev Experience**: enjoy the same enjoyable development experience of a Vue app. Leverage the full power of webpack (hot-reload, pre-processors), generate SEO-friendly static HTML, and works as an SPA after initial page load.
- Optimized for docs: many built-in markdown extensions and default theme features for writing great documentation.
- **Optimized for Docs**: many [built-in markdown extensions](./markdown.md) and default theme features for writing great documentation.
- GitHub friendly: pages can link to each other using relative links that ends in `.md`, auto-generates GitHub link and page edit links if a repo is provided.
- **GitHub Friendly**: source markdown files can link to each other using relative links that ends in `.md` so they are also readable on GitHub, auto-generates page edit links if a repo is provided.
## Quickstart
......
......@@ -20,6 +20,8 @@
### themeConfig
Also see [config options for the default theme](./default-theme.md).
## Markdown
### markdown.anchor
......
# Default Theme Configuration
# Theming
# Custom Themes
VuePress uses Vue single file components for custom themes. To use a custom layout, create a `.vuepress/theme` directory in your docs root, and then create a `Layout.vue` file:
......
......@@ -42,18 +42,32 @@ The compiled component does not have any private data but do have access to the
**Output**
<pre><code>{{ $page }}</code></pre>
``` json
{
"path": "/using-vue.html",
"title": "Using Vue in Markdown",
"frontmatter": {}
}
```
## Escaping
By default, fenced code blocks are automatically wrapped with `v-pre`. If you want to display raw mustaches or Vue-specific syntax inside inline code snippets or plain text, you need to wrap a paragraph with the `v-pre` custom container:
**Input**
``` markdown
::: v-pre
`{{ This will be displayed as-is }}`
:::
```
**Output**
::: v-pre
`{{ This will be displayed as-is }}`
:::
## Using Components
Any `*.vue` file found in `.vuepress/components` are automatically registered as global async components. For example:
......@@ -77,7 +91,7 @@ Inside any markdown file you can then directly use the components (names are inf
<OtherComponent/>
::: warning
::: warning IMPORTANT
Make sure a custom component's names either contains a hyphen or is in PascalCase. Otherwise it will be treated as an inline element and wrapped inside a `<p>` tag, which will lead to hydration mismatch because `<p>` does not allow block elements to be placed inside it.
:::
......
......@@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title></title>
</head>
<body>
......
......@@ -2,6 +2,7 @@
<html lang="{{ lang }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>{{ title }}</title>
{{{ userHeadTags }}}
{{{ pageMeta }}}
......
<template>
<div class="theme-container">
<ul class="sidebar">
<li v-for="page in sortedPages">
<router-link :to="page.path">
{{ page.frontmatter.navTitle || page.title || page.path }}
</router-link>
</li>
</ul>
<div class="sidebar">
<ul>
<li v-for="page in sortedPages">
<router-link :to="page.path">
{{ page.frontmatter.navTitle || page.title || page.path }}
</router-link>
</li>
</ul>
</div>
<Index v-if="$page.path === '/index'" />
<Page v-else />
</div>
......
.theme-container
body
font-family -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif
-webkit-font-smoothing antialiased
-moz-osx-font-smoothing grayscale
padding 0 30px
font-size 16px
color #2c3e50
.markdown
max-width 800px
margin-left 300px
margin-bottom 30px
.page
padding-left 300px
.sidebar
width 300px
position fixed
margin 0
top 30px
top 0
left 0
bottom 0
padding 2em 0
box-sizing border-box
border-right 1px solid #eaecef
overflow-y scroll
ul
padding 0
margin 0
list-style-type none
a
display inline-block
color #2c3e50
border-left 4px solid transparent
padding 0.25em
padding-left 1.25em
&:hover
color darken(#41b883, 5%)
&.router-link-exact-active
font-weight 600
color darken(#41b883, 5%)
border-left-color darken(#41b883, 5%)
.markdown
max-width 720px
margin 2em auto
padding 0 2em
blockquote
font-size 1.25em
......@@ -64,7 +89,7 @@ code
font-family source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace
p, ul, ol
line-height 1.5
line-height 1.7
p, h1, h2, h3, h4, h5, h6
code
......@@ -81,19 +106,19 @@ pre, pre[class*="language-"]
background-color #2d2d2d
color white
line-height 1.4
border-radius 5px
padding 1.3rem 1.575rem
border-radius 6px
padding 1.4em 1.6em
white-space pre-wrap
word-break break-word
overflow auto
code
font-size .88em
font-size 0.85em
.highlighted-line
background-color #14161a
display block
margin 0 -1.575rem
padding 0.2rem 1.575rem 0
margin 0 -1.6em
padding 0.2em 1.6em 0
.custom-block
.custom-block-title
......@@ -105,7 +130,7 @@ pre, pre[class*="language-"]
border-left-style solid
margin 1em 0
&.tip
background-color #f1f3f5
background-color #f3f5f7
border-color #42b983
&.warning
background-color rgba(255,229,100,.3)
......@@ -125,3 +150,27 @@ p
padding 1rem
border 1px solid #ddd
border-radius 4px
@media (max-width: 879px)
body
font-size 15px
.sidebar
font-size 14px
width 250px
.page
padding-left 250px
.markdown
margin 1.5em 0
padding 0 1.5em
@media (max-width: 639px)
body
font-size 15px
.sidebar
width 275px
display none
.page
padding-left 0
.markdown
margin 1em 0
padding 0 1em
......@@ -4,6 +4,7 @@ const globby = require('globby')
const mkdirp = require('mkdirp')
const yaml = require('yaml-front-matter')
const tempPath = path.resolve(__dirname, 'app/.temp')
const { inferTitle } = require('./util')
mkdirp(tempPath)
......@@ -114,9 +115,9 @@ async function resolveOptions (sourceDir) {
// extract yaml frontmatter
const frontmatter = yaml.loadFront(content)
// infer title
const titleMatch = frontmatter.__content.trim().match(/^#+\s+(.*)/)
if (titleMatch) {
data.title = titleMatch[1]
const title = inferTitle(frontmatter)
if (title) {
data.title = title
}
delete frontmatter.__content
if (Object.keys(frontmatter).length) {
......
......@@ -24,3 +24,13 @@ exports.applyUserWebpackConfig = function (userConfig, config, isServer) {
}
return config
}
exports.inferTitle = function (frontmatter) {
if (frontmatter.title) {
return frontmatter.title
}
const match = frontmatter.__content.trim().match(/^#+\s+(.*)/)
if (match) {
return match[1]
}
}
const { EventEmitter } = require('events')
const { getOptions } = require('loader-utils')
const frontmatter = require('yaml-front-matter')
const yaml = require('yaml-front-matter')
const { inferTitle } = require('../util')
const frontmatterCache = new Map()
const cache = new Map()
module.exports = function (src) {
const { markdown } = getOptions(this)
const parsed = frontmatter.loadFront(src)
const content = parsed.__content
delete parsed.__content
// diff frontmatter, since it's not going to be part of the returned
// component, changes in frontmatter do not trigger hot updates
const serializedData = JSON.stringify(parsed)
const cachedData = frontmatterCache.get(this.resourcePath)
if (cachedData != null && cachedData !== serializedData) {
const frontmatter = yaml.loadFront(src)
const inferredTitle = inferTitle(frontmatter)
const content = frontmatter.__content
delete frontmatter.__content
// diff frontmatter and title, since they are not going to be part of the
// returned component, changes in frontmatter do not trigger proper updates
const cachedData = cache.get(this.resourcePath)
if (cachedData && (
cachedData.inferredTitle !== inferredTitle ||
JSON.stringify(cachedData.frontmatter) !== JSON.stringify(frontmatter)
)) {
// frontmatter changed... need to do a full reload
module.exports.frontmatterEmitter.emit('update')
}
frontmatterCache.set(this.resourcePath, serializedData)
cache.set(this.resourcePath, {
frontmatter,
inferredTitle
})
const { html, hoistedTags } = markdown.renderWithHoisting(content)
return (
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册