diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 289ec07cbe..4c223bfdf5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -19,6 +19,8 @@ about: Create a report to help us improve + + #### What is expected? #### What is actually happening? diff --git a/.gitignore b/.gitignore index 96930bdd73..c090307948 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules .temp vuepress TODOs.md +.idea diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b821cdfc6..e6ef90e4b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,95 @@ + +## [0.14.1](https://github.com/vuejs/vuepress/compare/v0.14.0...v0.14.1) (2018-08-09) + + +### Bug Fixes + +* **$default-theme:** default search box line wrap ([03c812b](https://github.com/vuejs/vuepress/commit/03c812b)) +* **$default-theme:** navbar's regression - siteName null check ([02a4713](https://github.com/vuejs/vuepress/commit/02a4713)) + + + + +# [0.14.0](https://github.com/vuejs/vuepress/compare/v0.13.1...v0.14.0) (2018-08-08) + + +### Bug Fixes + +* **$default-theme:** algolia search doesn't work well at i18n mode ([e8a6ab1](https://github.com/vuejs/vuepress/commit/e8a6ab1)) +* **$default-theme:** navbar's messy layout at narrow screen ([#714](https://github.com/vuejs/vuepress/issues/714)) ([3e1da57](https://github.com/vuejs/vuepress/commit/3e1da57)) +* **$default-theme:** set alias "collapsible" to "collapsable" (close: [#705](https://github.com/vuejs/vuepress/issues/705)) ([#706](https://github.com/vuejs/vuepress/issues/706)) ([ad66fa8](https://github.com/vuejs/vuepress/commit/ad66fa8)) +* **$build:** skip format data.head if not exist while loading toml config ([#707](https://github.com/vuejs/vuepress/issues/707)) ([bb48a77](https://github.com/vuejs/vuepress/commit/bb48a77)) + + +### Features + +* **core:** support writing HTML(Vue) anywhere in the header. ([#711](https://github.com/vuejs/vuepress/issues/711)) ([885496e](https://github.com/vuejs/vuepress/commit/885496e)) +* **$webpack:** display host url at dev HMR log ([2e8d69c](https://github.com/vuejs/vuepress/commit/2e8d69c)) + + + + +## [0.13.1](https://github.com/vuejs/vuepress/compare/v0.13.0...v0.13.1) (2018-08-01) + + +### Bug Fixes + +* **core:** normalize override file path in windows ([#692](https://github.com/vuejs/vuepress/issues/692)) (close: [#642](https://github.com/vuejs/vuepress/issues/642)) ([9537c2c](https://github.com/vuejs/vuepress/commit/9537c2c)) +* **$default-theme:** `py` lang label doesn't display in code block ([#690](https://github.com/vuejs/vuepress/issues/690)) ([88b65cc](https://github.com/vuejs/vuepress/commit/88b65cc)) + + + + +# [0.13.0](https://github.com/vuejs/vuepress/compare/v0.12.0...v0.13.0) (2018-07-28) + + +### Bug Fixes + +* **$seo:** Avoid duplicate `description meta` at runtime. (close: [#665](https://github.com/vuejs/vuepress/issues/665)) ([b207a5f](https://github.com/vuejs/vuepress/commit/b207a5f)) +* **$default-theme:** Scoped styles of `Badge` component (close: [#653](https://github.com/vuejs/vuepress/issues/653)) ([#657](https://github.com/vuejs/vuepress/issues/657)) ([9b602f2](https://github.com/vuejs/vuepress/commit/9b602f2)) +* **$build:** set `babelrc: false` in babel-loader options ([#644](https://github.com/vuejs/vuepress/issues/644)) ([c500201](https://github.com/vuejs/vuepress/commit/c500201)) ([@posva](https://github.com/posva)) +* **$build:** exclude dest folder from pageFiles (close: [#654](https://github.com/vuejs/vuepress/issues/654)) ([#655](https://github.com/vuejs/vuepress/issues/655)) ([c1fe692](https://github.com/vuejs/vuepress/commit/c1fe692)) +* **$build:** markdown config should be included in `cache-loader` identifier ([0ad1a45](https://github.com/vuejs/vuepress/commit/0ad1a45)) +* **$markdown:** cannot highlight external python file (`.py`) correctly (close: [#660](https://github.com/vuejs/vuepress/issues/660)) ([2a33075](https://github.com/vuejs/vuepress/commit/2a33075)) +* **$markdown:** missing space between `italics` and `bold` (close: [#661](https://github.com/vuejs/vuepress/issues/661)) ([7730ee1](https://github.com/vuejs/vuepress/commit/7730ee1)) + 1. `markdown-it` compiler will intendedly reserve this space between some inline elements, but `preserveWhitespace: false` will remove them. (Ref: [vue-template-compiler#options](https://github.com/vuejs/vue/tree/dev/packages/vue-template-compiler#options)) + 2. **Performance Impact**: Size of whole assets of vuepress documentation: + - Before (1952 kb) + - After (1960 kb) + +### Features + +* **$cli:** debug flag at dev mode ([231da6a](https://github.com/vuejs/vuepress/commit/231da6a)) +* **$default-theme:** transform `Badge` into async component ([de9a51b](https://github.com/vuejs/vuepress/commit/de9a51b)) +* **$default-theme**(**$pwa**): `themeConfig.serviceWorker.updatePopup` option (close: [#453](https://github.com/vuejs/vuepress/issues/453)) ([#533](https://github.com/vuejs/vuepress/issues/533)) ([14dbd1e](https://github.com/vuejs/vuepress/commit/14dbd1e)) ([@mysticatea](https://github.com/mysticatea)) + ``` js + module.exports = { + themeConfig: { + serviceWorker: { + updatePopup: true + } + } + } + ``` + + + # [0.12.0](https://github.com/vuejs/vuepress/compare/v0.11.0...v0.12.0) (2018-07-12) ### Bug Fixes -* npm audit vulnerability (close: [#493](https://github.com/vuejs/vuepress/issues/493))([#641](https://github.com/vuejs/vuepress/issues/641)) ([8dde5d8](https://github.com/vuejs/vuepress/commit/8dde5d8)) -* wrong sidebar slugs and anchor link at content (close: [#645](https://github.com/vuejs/vuepress/issues/645)) ([c2eaff3](https://github.com/vuejs/vuepress/commit/c2eaff3)) +* **$build** npm audit vulnerability (close: [#493](https://github.com/vuejs/vuepress/issues/493))([#641](https://github.com/vuejs/vuepress/issues/641)) ([8dde5d8](https://github.com/vuejs/vuepress/commit/8dde5d8)) +* **$markdown**: wrong sidebar slugs and anchor link at content (close: [#645](https://github.com/vuejs/vuepress/issues/645)) ([c2eaff3](https://github.com/vuejs/vuepress/commit/c2eaff3)) ### Features -* version data layer ([0c5b752](https://github.com/vuejs/vuepress/commit/0c5b752)) -* **$default-theme:** new file-level API: style.styl. ([2f53f2f](https://github.com/vuejs/vuepress/commit/2f53f2f)) - +* **$core:**: version data layer ([0c5b752](https://github.com/vuejs/vuepress/commit/0c5b752)) +* **$default-theme:** new file-level API: `style.styl`. ([2f53f2f](https://github.com/vuejs/vuepress/commit/2f53f2f)) + 1. Fixed overriding css variable doesn't work at `0.11.0` (close: [#639](https://github.com/vuejs/vuepress/issues/639)) + 2. Split `override.styl` into two APIs: `override.styl` and `style.styl`, the former will focus on ONLY the stylus constants override, while the latter will focus on styles override or custom styles. See also: https://vuepress.vuejs.org/default-theme-config/#simple-css-override. diff --git a/LICENSE b/LICENSE index 15f1f7e7a4..2f244ac814 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,395 @@ -The MIT License (MIT) - -Copyright (c) 2018-present, Yuxi (Evan) You - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +Attribution 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More_considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution 4.0 International Public License ("Public License"). To the +extent this Public License may be interpreted as a contract, You are +granted the Licensed Rights in consideration of Your acceptance of +these terms and conditions, and the Licensor grants You such rights in +consideration of benefits the Licensor receives from making the +Licensed Material available under these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + i. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + j. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + k. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/README-cn.md b/README-cn.md new file mode 100644 index 0000000000..31c580ac95 --- /dev/null +++ b/README-cn.md @@ -0,0 +1,48 @@ +
+
+
+
+
+
+
+
+
+
This project is sponsored by
-
+
Minimal setup with markdown-centered project structure helps you focus on writing.
+对以 markdown 为中心的项目结构,做最简化的配置,帮助你专注于创作。
Enjoy the dev experience of Vue + webpack, use Vue components in markdown, and develop custom themes with Vue.
+享用 Vue + webpack 开发环境,在 markdown 中使用 Vue 组件,并通过 Vue 开发自定义主题。
VuePress generates pre-rendered static HTML for each page, and runs as an SPA once a page is loaded.
+VuePress 将每个页面生成为预渲染的静态 HTML,每个页面加载之后,然后作为单页面应用程序(SPA)运行。
{{ 1 + 1 }}
{{ 1 + 1 }}
-### Directives
+### 指令
-Directives also work:
+也可以运行指令:
-**Input**
+**输入**
``` md
{{ i }}
```
-**Output**
+**输出**
-{{ i }}
{{ i }}
-### Access to Site & Page Data
+### 访问网站和页面数据
-The compiled component does not have any private data but does have access to the [site metadata](./custom-themes.md#site-and-page-metadata). For example:
+编译后的组件没有任何私有数据,但是我们可以访问到 [网站元数据](./custom-themes.md#网站和网页元数据-site-and-page-metadata)。例如:
-**Input**
+**输入**
``` md
{{ $page }}
```
-**Output**
+**输出**
``` json
{
@@ -76,11 +76,11 @@ The compiled component does not have any private data but does have access to th
}
```
-## Escaping
+## 转义(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:
+默认情况下,花括号代码块(fenced code blocks)会自动用 `v-pre` 包装。如果要在内联代码片段或纯文本内显示原始插值或特定于 Vue 的语法,则需要把段落包裹在 `v-pre` 自定义容器中:
-**Input**
+**输入**
``` md
::: v-pre
@@ -88,15 +88,15 @@ By default, fenced code blocks are automatically wrapped with `v-pre`. If you wa
:::
```
-**Output**
+**输出**
::: v-pre
`{{ This will be displayed as-is }}`
:::
-## Using Components
+## 使用组件(Using Components)
-Any `*.vue` files found in `.vuepress/components` are automatically registered as [global](https://vuejs.org/v2/guide/components-registration.html#Global-Registration), [async](https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components) components. For example:
+`.vuepress/components` 中的所有 `*.vue` 文件都会自动注册为 [全局(global)](https://vuejs.org/v2/guide/components-registration.html#Global-Registration)[异步(async)](https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components) 组件。例如:
```
.
@@ -108,7 +108,7 @@ Any `*.vue` files found in `.vuepress/components` are automatically registered a
└─ Bar.vue
```
-Inside any markdown file you can then directly use the components (names are inferred from filenames):
+在所有 markdown 文件中,你都可以直接使用这些组件(其名称(name)是从文件名推断出的):
``` md
` tag, which will lead to hydration mismatch because `
` does not allow block elements to be placed inside it. +::: warning 重要 +确保自定义组件的名称,是由连字符(hyphen)拼接,或者遵循帕斯卡命名(PascalCase)。否则,它将被视为内联元素,然后被包裹在一个 `
` 标签内,这将导致 hydration 无法匹配,这是因为 `
` 中不允许放置块元素。(译注:查看 [SSR 客户端激活(client-side hydration)](https://ssr.vuejs.org/zh/guide/hydration.html)) ::: -### Using Pre-processors +## 在标题中使用 Vue 组件 + +你可以在标题中使用 Vue 组件,但是请注意以下两种方式的不同: + +| Markdown | 输出的 HTML | 解析后的标题 | +|--------|-------------|----------------| +|
# text <Tag/>
| ` # text \`<Tag/>\`
| `<Tag/>
` 包装的 HTML 将按原样显示,只有未被包装的 HTML 才会被 Vue 解析。
+
+::: tip
+输出的 HTML 由 [markdown-it](https://github.com/markdown-it/markdown-it) 完成。而解析后的标题由 VuePress 完成,用于[侧边栏](../default-theme-config/README.md#侧边栏)以及文档的标题。
+:::
+
+## 使用预处理器
+
+VuePress 已经为如下预处理器内置了相关的 webpack 配置:`sass`, `scss`, `less`, `stylus` 和 `pug`。要使用它们,你只需要在项目中安装对应的依赖即可。例如,要使用 `sass`,直接在项目中安装:
-VuePress has built-in webpack config for the following pre-processors: `sass`, `scss`, `less`, `stylus` and `pug`. All you need to do is installing the corresponding dependencies. For example, to enable `sass`, install the following in your project:
-
``` bash
yarn add -D sass-loader node-sass
```
-Now you can use the following in markdown and theme components:
+接着,你就可以在 markdown 或者主题组件中使用如下代码:
``` vue
```
-Using `` requires installing `pug` and `pug-plain-loader`:
+使用 `` 需要安装 `pug` 和 `pug-plain-loader`:
``` bash
yarn add -D pug pug-plain-loader
```
::: tip
-If you are a Stylus user, you don't need to install `stylus` and `stylus-loader` in your project because VuePress uses Stylus internally.
-
-For pre-processors that do not have built-in webpack config support, you will need to [extend the internal webpack config](../config/README.md#configurewebpack) in addition to installing the necessary dependencies.
+如果你是 Stylus 用户,那么不需要在项目中安装 `stylus` 和 `stylus-loader`,因为 VuePress 内部已经使用了 Stylus。
+
+对于没有内置 webpack 配置支持的预处理器,除了安装必要的依赖外,还需要 [扩展内部 webpack 配置](../config/README.md#configurewebpack)。
:::
-## Script & Style Hoisting
+## 脚本和样式提升
-Sometimes you may need to apply some JavaScript or CSS only to the current page. In those cases you can directly write root-level `
-## Built-In Components
+## 内置组件
### OutboundLink
-It( ) is used to indicate that this is an external link. In VuePress this component have been followed by every external link.
+( ) 用于表示这是一个外部链接。在 VuePress 中,每个外部链接后面,都跟着一个这样的组件。
### ClientOnly
-See [Browser API Access Restrictions](#browser-api-access-restrictions).
+参考 [浏览器 API 访问限制](#browser-api-access-restrictions)。
### Content
@@ -192,31 +207,35 @@ See [Browser API Access Restrictions](#browser-api-access-restrictions).
- `custom` - boolean
-- **Usage**:
-
-The compiled content of the current `.md` file being rendered. This will be very useful when you use [Custom Layout](../default-theme-config/README.md#custom-layout-for-specific-pages).
+- **用法**:
+
+当前 `.md` 文件的编译后内容,会在这里进行渲染。当你使用 [自定义布局](../default-theme-config/README.md#自定义页面的-class) 时,这将非常有用。
``` vue
```
-**Also see:**
+**也可以参考:**
+
+- [自定义主题 > 获取渲染内容](./custom-themes.md#内容出口-content-outlet)
-- [Custom Themes > Content Outlet](./custom-themes.md#content-outlet)
-
### Badge
- **Props**:
- `text` - string
- - `type` - string, optional value: `"tip"|"warn"|"error"`, defaults to `"tip"`.
- - `vertical` - string, optional value: `"top"|"middle"`, defaults to `"top"`.
+ - `type` - string, 可选值:`"tip"|"warn"|"error"`, 默认值是:`"tip"`.
+ - `vertical` - string, 可选值:`"top"|"middle"`, 默认值是:`"top"`.
+
+- **用法**:
-- **Usage**:
+这个组件可以用在标题文本的末尾,用来为某些 API 添加一些状态:
-You can use this component at the end of header text to add some status for some API:
-
``` md
### Badge
-```
+```
+
+**也可以参考:**
+
+- [在标题中使用 Vue 组件](#在标题中使用-vue-组件)
diff --git a/docs/zh/default-theme-config/README.md b/docs/zh/default-theme-config/README.md
index 8ce95d1a55..94c3b11bf5 100644
--- a/docs/zh/default-theme-config/README.md
+++ b/docs/zh/default-theme-config/README.md
@@ -351,6 +351,37 @@ module.exports = {
由于 `lastUpdated` 是基于 `git` 的, 所以你只能在一个基于 `git` 的项目中启用它。
:::
+## Service Worker
+
+`themeConfig.serviceWorker` 允许你去配置 Service Worker。
+
+::: tip 提示
+请不要将本选项与 [Config > serviceWorker](../config/README.md#serviceworker) 混淆,[Config > serviceWorker](../config/README.md#serviceworker) 是网站级别的配置,而本选项是主题级别的配置。
+:::
+
+### 刷新内容的弹窗
+
+开启 `themeConfig.serviceWorker.updatePopup` 选项,将开启一个能够刷新内容的弹窗。当网站更新(即 Service Worker 更新)时,它会提供一个 `refresh` 按钮,允许用户立刻刷新内容。
+
+::: tip 提示
+如果没有 `refresh` 按钮,新的 service worker 将在所有的 [clients](https://developer.mozilla.org/en-US/docs/Web/API/Clients) 关闭后才会处于活动状态。这意味着访问者在关闭你网站的所有标签之前将无法看到新内容。但是,`refresh` 按钮可以立即激活新的 Service Worker。
+:::
+
+``` js
+module.exports = {
+ themeConfig: {
+ serviceWorker: {
+ updatePopup: true // Boolean | Object, 默认值是 undefined.
+ // 如果设置为 true, 默认的文本配置将是:
+ // updatePopup: {
+ // message: "New content is available.",
+ // buttonText: "Refresh"
+ // }
+ }
+ }
+}
+```
+
## 上 / 下一篇链接
上一篇和下一篇文章的链接将会自动地根据当前页面的侧边栏的顺序来获取。你也可以使用 `YAML front matter` 来明确地重写或者禁用它:
@@ -414,6 +445,35 @@ $borderColor = #eaecef
$codeBgColor = #282c34
```
+### 低版本存在的问题
+
+为了 override 上述提及的 [Stylus](http://stylus-lang.com/) 默认样式常量,`override.styl` 将会在默认主题的 `config.styl` 的末尾被导入。但是,由于 `config.styl` 可能会被多个文件导入,所以,一旦你在这里写样式,你的样式将会被重复多次。参考: [#637](https://github.com/vuejs/vuepress/issues/637)。
+
+### 将你的样式迁移到 `style.styl`
+
+事实上,`stylus 常量的 override` 应该在编译所有 Stylus 文件之前完成;而用户额外的 CSS 样式应该生成在最终样式文件的末尾。因此,这两项职责不应该由同一个 stylus 文件来完成。
+
+从 `0.12.0` 开始,我们将 `override.styl` 拆分为两个 API:`override.styl` 和 `style.styl`。如果你过去在 `override.styl` 中书写了样式,如:
+
+``` stylus
+// .vuepress/override.styl
+$textColor = red // stylus 常量的 override
+
+#my-style {} // 你的样式
+```
+
+你将需要将你的样式部分分离到 `style.styl`:
+
+``` stylus
+// .vuepress/override.styl,应该仅仅包含 stylus 常量的 override
+$textColor = red
+```
+
+``` stylus
+// .vuepress/style.styl,你的样式
+#my-style {}
+```
+
## 自定义页面类
有时候你可能需要为特定页面添加一个 CSS 类名,以方便针对该页面添加一些专门的 CSS。这种情况下你可以在该页面的 YAML front matter 中声明一个 `pageClass`:
diff --git a/docs/zh/guide/deploy.md b/docs/zh/guide/deploy.md
index c3f7566edd..1f323dd44a 100644
--- a/docs/zh/guide/deploy.md
+++ b/docs/zh/guide/deploy.md
@@ -89,7 +89,7 @@ pages:
1. 在 Netlify 中, 创建一个新的 Github 项目,使用以下设置:
- - **Build Command:** `npm run build-docs` 或者 `yarn build-docs`
+ - **Build Command:** `npm run build:docs` 或者 `yarn build:docs`
- **Publish directory:** `docs/.vuepress/dist`
2. 点击 deploy 按钮!
diff --git a/docs/zh/guide/i18n.md b/docs/zh/guide/i18n.md
index a4d159a7ba..f0cc1c42be 100644
--- a/docs/zh/guide/i18n.md
+++ b/docs/zh/guide/i18n.md
@@ -53,6 +53,12 @@ module.exports = {
selectText: 'Languages',
label: 'English',
editLinkText: 'Edit this page on GitHub',
+ serviceWorker: {
+ updatePopup: {
+ message: "New content is available.",
+ buttonText: "Refresh"
+ }
+ },
algolia: {},
nav: [
{ text: 'Nested', link: '/nested/' }
@@ -69,6 +75,13 @@ module.exports = {
label: '简体中文',
// 编辑链接文字
editLinkText: '在 GitHub 上编辑此页',
+ // Service Worker 的配置
+ serviceWorker: {
+ updatePopup: {
+ message: "发现新内容可用.",
+ buttonText: "刷新"
+ }
+ },
// 当前 locale 的 algolia docsearch 选项
algolia: {},
nav: [
diff --git a/docs/zh/guide/using-vue.md b/docs/zh/guide/using-vue.md
index 1bb628c070..abf7be60f1 100644
--- a/docs/zh/guide/using-vue.md
+++ b/docs/zh/guide/using-vue.md
@@ -126,6 +126,20 @@ export default {
请确保一个自定义组件的名字包含连接符或者是 PascalCase,否则,它将会被视为一个内联元素,并被包裹在一个 `` 标签中,这将会导致 HTML 渲染紊乱,因为 HTML 标准规定, `
` 标签中不允许放置任何块级元素。
:::
+### 在标题中使用组件
+
+你可以在标题中使用 Vue 组件,但是请留意以下两种方式的不同:
+
+| Markdown | 输出的 HTML | 解析后的标题 |
+|--------|-------------|----------------|
+|
# text <Tag/>
| `text
` | `text` |
+| # text \`<Tag/>\`
| `text <Tag/>
` | `text ` |
+
+被 `` 包装的 HTML 将按原样显示,只有未被包装的 HTML 才会被 Vue 解析。
+
+::: tip
+输出的 HTML 由 [markdown-it](https://github.com/markdown-it/markdown-it) 完成。而解析后的标题由 VuePress 完成,用于[侧边栏](../default-theme-config/README.md#侧边栏)以及文档的标题。
+:::
## 使用预处理器
@@ -218,8 +232,12 @@ export default {
- **Usage**:
-你可以在标题文本的末尾,使用这个组件来为某些 API 添加一些状态:
+你可以在标题中,使用这个组件来为某些 API 添加一些状态:
``` md
### Badge
```
+
+**参考:**
+
+- [在标题中使用组件](#在标题中使用组件)
diff --git a/lib/app/SWUpdateEvent.js b/lib/app/SWUpdateEvent.js
new file mode 100644
index 0000000000..fe6ab31c33
--- /dev/null
+++ b/lib/app/SWUpdateEvent.js
@@ -0,0 +1,43 @@
+export default class SWUpdateEvent {
+ constructor (registration) {
+ Object.defineProperty(this, 'registration', {
+ value: registration,
+ configurable: true,
+ writable: true
+ })
+ }
+
+ /**
+ * Check if the new service worker exists or not.
+ */
+ update () {
+ return this.registration.update()
+ }
+
+ /**
+ * Activate new service worker to work 'location.reload()' with new data.
+ */
+ skipWaiting () {
+ const worker = this.registration.waiting
+ if (!worker) {
+ return Promise.resolve()
+ }
+
+ console.log('[vuepress:sw] Doing worker.skipWaiting().')
+ return new Promise((resolve, reject) => {
+ const channel = new MessageChannel()
+
+ channel.port1.onmessage = (event) => {
+ console.log('[vuepress:sw] Done worker.skipWaiting().')
+ if (event.data.error) {
+ reject(event.data.error)
+ } else {
+ resolve(event.data)
+ }
+ }
+
+ worker.postMessage({ type: 'skip-waiting' }, [channel.port2])
+ })
+ }
+}
+
diff --git a/lib/app/app.js b/lib/app/app.js
index 3bff5421a0..511abbd472 100644
--- a/lib/app/app.js
+++ b/lib/app/app.js
@@ -13,7 +13,6 @@ import('@temp/style.styl')
// built-in components
import Content from './components/Content'
import OutboundLink from './components/OutboundLink.vue'
-import Badge from './components/Badge.vue'
import ClientOnly from './components/ClientOnly'
// suggest dev server restart on base change
@@ -36,7 +35,7 @@ Vue.mixin(dataMixin(siteData))
// component for rendering markdown content and setting title etc.
Vue.component('Content', Content)
Vue.component('OutboundLink', OutboundLink)
-Vue.component('Badge', Badge)
+Vue.component('Badge', () => import('./components/Badge.vue'))
// component for client-only content
Vue.component('ClientOnly', ClientOnly)
diff --git a/lib/app/clientEntry.js b/lib/app/clientEntry.js
index 5691528ebf..7b634e7fb1 100644
--- a/lib/app/clientEntry.js
+++ b/lib/app/clientEntry.js
@@ -1,6 +1,7 @@
/* global BASE_URL, GA_ID, ga, SW_ENABLED, VUEPRESS_VERSION, LAST_COMMIT_HASH*/
import { createApp } from './app'
+import SWUpdateEvent from './SWUpdateEvent'
import { register } from 'register-service-worker'
const { app, router } = createApp()
@@ -46,13 +47,13 @@ router.onReady(() => {
console.log('[vuepress:sw] Service worker is active.')
app.$refs.layout.$emit('sw-ready')
},
- cached () {
+ cached (registration) {
console.log('[vuepress:sw] Content has been cached for offline use.')
- app.$refs.layout.$emit('sw-cached')
+ app.$refs.layout.$emit('sw-cached', new SWUpdateEvent(registration))
},
- updated () {
+ updated (registration) {
console.log('[vuepress:sw] Content updated.')
- app.$refs.layout.$emit('sw-updated')
+ app.$refs.layout.$emit('sw-updated', new SWUpdateEvent(registration))
},
offline () {
console.log('[vuepress:sw] No internet connection found. App is running in offline mode.')
diff --git a/lib/app/components/Badge.vue b/lib/app/components/Badge.vue
index 3129319198..17e6ba6e7a 100644
--- a/lib/app/components/Badge.vue
+++ b/lib/app/components/Badge.vue
@@ -20,7 +20,7 @@ export default {
}
-
diff --git a/lib/default-theme/Page.vue b/lib/default-theme/Page.vue
index fe019abcfe..4621937c84 100644
--- a/lib/default-theme/Page.vue
+++ b/lib/default-theme/Page.vue
@@ -1,31 +1,58 @@
+
+
-
- {{ editLinkText }}
+
-
+
+
{{ lastUpdatedText }}:
{{ lastUpdated }}
+
-
- ←
+
+ ←
+
{{ prev.title || prev.path }}
-
-
+
+
+
{{ next.title || next.path }}
- →
+
+ →
+
@@ -35,12 +62,14 @@ import { resolvePage, normalize, outboundRE, endingSlashRE } from './util'
export default {
props: ['sidebarItems'],
+
computed: {
lastUpdated () {
if (this.$page.lastUpdated) {
return new Date(this.$page.lastUpdated).toLocaleString(this.$lang)
}
},
+
lastUpdatedText () {
if (typeof this.$themeLocaleConfig.lastUpdated === 'string') {
return this.$themeLocaleConfig.lastUpdated
@@ -50,6 +79,7 @@ export default {
}
return 'Last Updated'
},
+
prev () {
const prev = this.$page.frontmatter.prev
if (prev === false) {
@@ -60,6 +90,7 @@ export default {
return resolvePrev(this.$page, this.sidebarItems)
}
},
+
next () {
const next = this.$page.frontmatter.next
if (next === false) {
@@ -70,6 +101,7 @@ export default {
return resolveNext(this.$page, this.sidebarItems)
}
},
+
editLink () {
if (this.$page.frontmatter.editLink === false) {
return
@@ -92,14 +124,21 @@ export default {
return this.createEditLink(repo, docsRepo, docsDir, docsBranch, path)
}
},
+
editLinkText () {
return (
this.$themeLocaleConfig.editLinkText ||
this.$site.themeConfig.editLinkText ||
`Edit this page`
)
+ },
+ rawLink () {
+ const path = normalize(this.$page.path)
+ const rawPath = `https://vuepress.vuejs.org${path}`
+ return rawPath
}
},
+
methods: {
createEditLink (repo, docsRepo, docsDir, docsBranch, path) {
const bitbucket = /bitbucket.org/
diff --git a/lib/default-theme/SWUpdatePopup.vue b/lib/default-theme/SWUpdatePopup.vue
new file mode 100644
index 0000000000..b224db31ed
--- /dev/null
+++ b/lib/default-theme/SWUpdatePopup.vue
@@ -0,0 +1,85 @@
+
+
+
+ {{message}}
+
+
+
+
+
+
+
+
diff --git a/lib/default-theme/SearchBox.vue b/lib/default-theme/SearchBox.vue
index 2da178f985..9860855244 100644
--- a/lib/default-theme/SearchBox.vue
+++ b/lib/default-theme/SearchBox.vue
@@ -4,21 +4,28 @@
@input="query = $event.target.value"
aria-label="Search"
:value="query"
+ :class="{ 'focused': focused }"
autocomplete="off"
spellcheck="false"
@focus="focused = true"
@blur="focused = false"
@keyup.enter="go(focusIndex)"
@keyup.up="onUp"
- @keyup.down="onDown">
-