Skip to content

Commit e242f59

Browse files
committed
syntax highlight tweaks
1 parent ea4b85b commit e242f59

File tree

8 files changed

+43
-11
lines changed

8 files changed

+43
-11
lines changed

docs/config.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
### title
88

9+
### description
10+
911
### head
1012

1113
### port
@@ -14,7 +16,7 @@
1416

1517
### theme
1618

17-
### data
19+
### themeConfig
1820

1921
### markdown
2022

docs/kitchen/sink.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ foo: 123
33
bar: 234
44
---
55

6+
# Kitchen Sink
7+
68
## Relative Links
79

810
- [Go home](../README.md)
@@ -14,7 +16,7 @@ bar: 234
1416
const a = 123
1517
```
1618

17-
``` html{2,10}
19+
``` html{2,10-13}
1820
<div id="example">
1921
<p>Original message: "{{ message }}"</p>
2022
<p>Computed reversed message: "{{ reversedMessage }}"</p>

docs/test.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Dynamic Component
2+
3+
<div>
4+
<demo-1/>
5+
</div>

docs/using-vue.md

+14
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,27 @@
44

55
## Using Components
66

7+
Any `*.vue` file found in `.vuepress/components` are automatically registered as global async components. For example:
8+
79
``` bash
810
.
911
└── .vuepress
1012
   └── components
1113
      └── demo-1.vue
1214
```
1315

16+
Inside any markdown file you can then use the component like so:
17+
18+
``` markdown
19+
<div>
20+
<demo-1/>
21+
</div>
22+
```
23+
24+
::: warning
25+
Note **components must be nested inside a `<div>`**, because otherwise they'd be automatically wrapped inside a `<p>`, which can only contain inline elements.
26+
:::
27+
1428
## Style & Script
1529

1630
(TODO)

lib/default-theme/Layout.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="theme-container">
33
<ul class="nav">
44
<li v-for="page in $site.pages">
5-
<router-link :to="page.path">{{ page.path }}</router-link>
5+
<router-link :to="page.path">{{ page.title || page.path }}</router-link>
66
</li>
77
</ul>
88
<Index v-if="$page.path === '/index'" />

lib/default-theme/styles.css

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ pre code, pre[class*="language-"] code {
2222
.highlighted-line {
2323
background-color: #14161a;
2424
display: block;
25-
margin: 1px -1.575rem;
26-
padding: 1px 1.575rem;
25+
margin: 0 -1.575rem;
26+
padding: 0 1.575rem;
27+
}
28+
29+
div.warning {
30+
background-color: yellow;
2731
}
2832

2933
/*

lib/markdown/highlight.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
const prism = require('prismjs')
22
const loadLanguages = require('prismjs/components/index')
33

4+
// required to make embedded highlighting work...
5+
loadLanguages(['markup', 'css', 'javascript'])
6+
47
module.exports = (str, lang) => {
5-
if (lang === 'vue') {
6-
lang = 'html'
8+
if (lang === 'vue' || lang === 'html') {
9+
lang = 'markup'
710
}
811
if (!prism.languages[lang]) {
912
try {

lib/prepare.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async function resolveOptions (sourceDir) {
9797
// extract yaml frontmatter
9898
const frontmatter = yaml.loadFront(content)
9999
// infer title
100-
const titleMatch = frontmatter.__content.match(/^#+\s+(.*)/)
100+
const titleMatch = frontmatter.__content.trim().match(/^#+\s+(.*)/)
101101
if (titleMatch) {
102102
data.title = titleMatch[1]
103103
}
@@ -109,11 +109,13 @@ async function resolveOptions (sourceDir) {
109109
})
110110

111111
// resolve site data
112-
options.siteData = Object.assign({}, siteConfig.data, {
112+
options.siteData = {
113113
title: siteConfig.title,
114+
description: siteConfig.description,
114115
base: siteConfig.base || '/',
115-
pages: pagesData
116-
})
116+
pages: pagesData,
117+
themeConfig: siteConfig.themeConfig
118+
}
117119

118120
return options
119121
}

0 commit comments

Comments
 (0)