Skip to content

Commit 1d90cba

Browse files
committed
set up hash redirects for all old components sections
1 parent e3d6f7d commit 1d90cba

File tree

3 files changed

+93
-2
lines changed

3 files changed

+93
-2
lines changed

_config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,3 @@ alias:
187187
examples/svg.html: v2/examples/svg.html
188188
examples/todomvc.html: v2/examples/todomvc.html
189189
examples/tree-view.html: v2/examples/tree-view.html
190-

src/v2/guide/components.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ Now `v-model` should work perfectly with this component:
434434

435435
That's all you need to know about custom component events for now, but once you've finished reading this page and feel comfortable with its content, we recommend coming back later to read the full guide on [Custom Events](components-custom-events.html).
436436

437-
## Slots
437+
## Content Distribution with Slots
438438

439439
Just like with HTML elements, it's often useful to be able to pass content to a component, like this:
440440

@@ -564,6 +564,8 @@ In the example above, `currentTabComponent` can contain either:
564564

565565
See [this fiddle](https://jsfiddle.net/chrisvfritz/o3nycadu/) to experiment with the full code, or [this version](https://jsfiddle.net/chrisvfritz/b2qj69o1/) for an example binding to a component's options object, instead of its registered name.
566566

567+
That's all you need to know about dynamic components for now, but once you've finished reading this page and feel comfortable with its content, we recommend coming back later to read the full guide on [Dynamic & Async Components](components-dynamic-async.html).
568+
567569
## DOM Template Parsing Caveats
568570

569571
Some HTML elements, such as `<ul>`, `<ol>`, `<table>` and `<select>` have restrictions on what elements can appear inside them, and some elements such as `<li>` and `<option>` can only appear inside certain other elements.

themes/vue/source/js/common.js

+90
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(function () {
2+
initHashLevelRedirects()
23
initMobileMenu()
34
initVideoModal()
45
if (PAGE_TYPE) {
@@ -8,6 +9,95 @@
89
initLocationHashFuzzyMatching()
910
}
1011

12+
// Most redirects should be specified in Hexo's
13+
// _config.yml. However, it can't handle hash-level
14+
// redirects, such as:
15+
//
16+
// /foo#hello -> /bar#hello
17+
//
18+
// For these cases where a section on one page has
19+
// moved to a perhaps differently-named section on
20+
// another page, we need this.
21+
function initHashLevelRedirects() {
22+
checkForHashRedirect(/components\.html$/, {
23+
'What-are-Components': '/v2/guide/components.html',
24+
'Using-Components': '/v2/guide/components-registration.html',
25+
'Global-Registration':
26+
'/v2/guide/components-registration.html#Global-Registration',
27+
'Local-Registration':
28+
'/v2/guide/components-registration.html#Local-Registration',
29+
'Composing-Components':
30+
'/v2/guide/components.html#Organizing-Components',
31+
Props:
32+
'/v2/guide/components.html#Passing-Data-to-Child-Components-with-Props',
33+
'Passing-Data-with-Props':
34+
'/v2/guide/components.html#Passing-Data-to-Child-Components-with-Props',
35+
'camelCase-vs-kebab-case':
36+
'/v2/guide/components-props.html#Prop-Casing-camelCase-vs-kebab-case',
37+
'Dynamic-Props':
38+
'/v2/guide/components-props.html#Static-and-Dynamic-Props',
39+
'Literal-vs-Dynamic':
40+
'/v2/guide/components-props.html#Static-and-Dynamic-Props',
41+
'One-Way-Data-Flow':
42+
'/v2/guide/components-props.html#One-Way-Data-Flow',
43+
'Prop-Validation': '/v2/guide/components-props.html#Prop-Validation',
44+
'Non-Prop-Attributes':
45+
'/v2/guide/components-props.html#Non-Prop-Attributes',
46+
'Replacing-Merging-with-Existing-Attributes':
47+
'/v2/guide/components-props.html#Replacing-Merging-with-Existing-Attributes',
48+
'Custom-Events':
49+
'/v2/guide/components.html#Sending-Messages-to-Parents-with-Events',
50+
'Using-v-on-with-Custom-Events':
51+
'/v2/guide/components.html#Sending-Messages-to-Parents-with-Events',
52+
'Binding-Native-Events-to-Components':
53+
'/v2/guide/components-custom-events.html#Binding-Native-Events-to-Components',
54+
'sync-Modifier':
55+
'/v2/guide/components-custom-events.html#sync-Modifier',
56+
'Form-Input-Components-using-Custom-Events':
57+
'/v2/guide/components-custom-events.html#Binding-Native-Events-to-Components',
58+
'Customizing-Component-v-model':
59+
'/v2/guide/components-custom-events.html#Customizing-Component-v-model',
60+
'Non-Parent-Child-Communication': '/v2/guide/state-management.html',
61+
'Compilation-Scope':
62+
'/v2/guide/components-slots.html#Compilation-Scope',
63+
'Single-Slot': '/v2/guide/components-slots.html#Slot-Content',
64+
'Named-Slots': '/v2/guide/components-slots.html#Named-Slots',
65+
'Scoped-Slots': '/v2/guide/components-slots.html#Scoped-Slots',
66+
'Dynamic-Components': '/v2/guide/components.html#Dynamic-Components',
67+
'keep-alive':
68+
'/v2/guide/components-dynamic-async.html#keep-alive-with-Dynamic-Components',
69+
Misc: '/v2/guide/components-edge-cases.html',
70+
'Authoring-Reusable-Components':
71+
'/v2/guide/components.html#Organizing-Components',
72+
'Child-Component-Refs':
73+
'/v2/guide/components-edge-cases.html#Accessing-Child-Component-Instances-amp-Child-Elements',
74+
'Async-Components':
75+
'/v2/guide/components-dynamic-async.html#Async-Components',
76+
'Advanced-Async-Components':
77+
'/v2/guide/components-dynamic-async.html#Handling-Loading-State',
78+
'Component-Naming-Conventions':
79+
'/v2/guide/components-registration.html#Component-Names',
80+
'Recursive-Components':
81+
'/v2/guide/components-edge-cases.html#Recursive-Components',
82+
'Circular-References-Between-Components':
83+
'/v2/guide/components-edge-cases.html#Circular-References-Between-Components',
84+
'Inline-Templates':
85+
'/v2/guide/components-edge-cases.html#Inline-Templates',
86+
'X-Templates': '/v2/guide/components-edge-cases.html#X-Templates',
87+
'Cheap-Static-Components-with-v-once':
88+
'/v2/guide/components-edge-cases.html#Cheap-Static-Components-with-v-once'
89+
})
90+
function checkForHashRedirect(pageRegex, redirects) {
91+
// Abort if the current page doesn't match the page regex
92+
if (!pageRegex.test(window.location.pathname)) return
93+
94+
var redirectPath = redirects[window.location.hash.slice(1)]
95+
if (redirectPath) {
96+
window.location.href = window.location.origin + redirectPath
97+
}
98+
}
99+
}
100+
11101
function initApiSpecLinks () {
12102
var apiContent = document.querySelector('.content.api')
13103
if (apiContent) {

0 commit comments

Comments
 (0)