Skip to content

Commit 2e2682e

Browse files
committed
add index for API pages
1 parent 86fd72e commit 2e2682e

File tree

6 files changed

+67
-25
lines changed

6 files changed

+67
-25
lines changed

source/api/directives.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,32 @@ Conditionally insert / remove the element based on the truthy-ness of the bindin
8080

8181
- This directive takes a registered asset id.
8282

83-
Compile this element as a child ViewModel with a registered component constructor. For more details see [Composing ViewModels](/guide/composition.html).
83+
Compile this element as a child ViewModel with a registered component constructor. This can be used with `v-with` to inehrit data from the parent. For more details see [Composing ViewModels](/guide/composition.html).
8484

8585
### v-with
8686

8787
- This directive requires the value to be an Object or falsy.
8888

89-
Compile this element as a child ViewModel, using the binding value as the `data` option. This can be used in combination with `v-component`.
89+
Compile this element as a child ViewModel, using the binding value as the `data` option. Inside the template you can directly access properties on the binding value. This can be used in combination with `v-component`.
90+
91+
Suppose our data looks like this:
92+
93+
``` js
94+
{
95+
user: {
96+
name: 'Foo Bar',
97+
98+
}
99+
}
100+
```
101+
102+
You can simplify the template like this:
103+
104+
``` html
105+
<div v-with="user">
106+
{&#123;name&#125;} {&#123;email&#125;}
107+
</div>
108+
```
90109

91110
### v-component-id
92111

themes/vue/layout/layout.ejs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
77
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,400italic|Source+Code+Pro' rel='stylesheet' type='text/css'>
88
<link rel="icon" href="/images/logo.png" type="image/x-icon">
9+
<script>
10+
window.PAGE_TYPE = "<%- page.type %>"
11+
</script>
912
<script src="/js/classList.js"></script>
1013
<%- css(page.index ? 'css/index' : 'css/page') %>
1114
<%- partial('partials/ga') %>
@@ -19,26 +22,6 @@
1922
<div id="main">
2023
<%- body %>
2124
</div>
22-
<script>
23-
var main = document.getElementById('main'),
24-
doc = document.documentElement,
25-
body = document.body,
26-
header = document.getElementById('header'),
27-
menu = document.querySelector('.sidebar'),
28-
menuToggle = document.querySelector('.sidebar .toggle')
29-
if (menu) {
30-
window.addEventListener('scroll', function () {
31-
var top = doc && doc.scrollTop || body.scrollTop
32-
if (top > header.offsetHeight) {
33-
main.className = 'fix-sidebar'
34-
} else {
35-
main.className = ''
36-
}
37-
})
38-
menuToggle.addEventListener('click', function () {
39-
menu.classList.toggle('open')
40-
})
41-
}
42-
</script>
25+
<script src="/js/common.js"></script>
4326
</body>
4427
</html>

themes/vue/source/css/_common.styl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import "_settings"
22
@import "_syntax"
3-
@import "_demo"
43

54
body
65
font-family $body-font

themes/vue/source/css/index.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ a.button
108108
padding 0 1em
109109
position relative
110110
background-color #fff
111-
top -.65em
111+
top -.75em
112112

113113
@media screen and (max-width: 420px)
114114
body

themes/vue/source/css/page.styl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "_common"
2+
@import "_demo"
23

34
$header-height = 40px
45

themes/vue/source/js/common.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
(function () {
2+
3+
var main = document.getElementById('main'),
4+
doc = document.documentElement,
5+
body = document.body,
6+
header = document.getElementById('header'),
7+
menu = document.querySelector('.sidebar'),
8+
menuToggle = document.querySelector('.sidebar .toggle')
9+
10+
if (menu) {
11+
window.addEventListener('scroll', function () {
12+
var top = doc && doc.scrollTop || body.scrollTop
13+
if (top > header.offsetHeight) {
14+
main.className = 'fix-sidebar'
15+
} else {
16+
main.className = ''
17+
}
18+
})
19+
menuToggle.addEventListener('click', function () {
20+
menu.classList.toggle('open')
21+
})
22+
}
23+
24+
if (PAGE_TYPE === 'api') {
25+
var h1 = document.querySelector('h1'),
26+
h3s = document.querySelectorAll('h3'),
27+
list = document.createElement('ul'),
28+
inner = '',
29+
replaceRE = /\(.*$/
30+
for (var i = 0, l = h3s.length; i < l; i++) {
31+
var h3 = h3s[i]
32+
inner += '<li><a href="#' + h3.id + '">' +
33+
h3.textContent.replace(replaceRE, '') +
34+
'</a></li>'
35+
}
36+
list.innerHTML = inner
37+
h1.parentNode.insertBefore(list, h1.nextSibling)
38+
}
39+
40+
})()

0 commit comments

Comments
 (0)