Unified · Split
| @@ -66,14 +66,23 @@ class app.Router · 65 unmodified lines | |||
| 66 | 66 | ||
| 67 | entry: (context, next) -> | 67 | entry: (context, next) -> |
| 68 | doc = app.docs.findBySlug(context.params.doc) | 68 | doc = app.docs.findBySlug(context.params.doc) |
| 69 | return next() unless doc | ||
| 70 | path = context.params.path | ||
| 71 | hash = context.hash | ||
| 69 | 72 | ||
| 70 | if entry = doc?.findEntryByPathAndHash(context.params.path, context.hash) | 73 | if entry = doc.findEntryByPathAndHash(path, hash) |
| 71 | context.doc = doc | 74 | context.doc = doc |
| 72 | context.entry = entry | 75 | context.entry = entry |
| 73 | @triggerRoute 'entry' | 76 | @triggerRoute 'entry' |
| 74 | return | 77 | return |
| 78 | else if path.slice(-6) is '/index' | ||
| 79 | path = path.substr(0, path.length - 6) | ||
| 80 | return entry.fullPath() if entry = doc.findEntryByPathAndHash(path, hash) | ||
| 75 | else | 81 | else |
| 76 | return next() | 82 | path = "#{path}/index" |
| 83 | return entry.fullPath() if entry = doc.findEntryByPathAndHash(path, hash) | ||
| 84 | |||
| 85 | return next() | ||
| 77 | 86 | ||
| 78 | root: -> | 87 | root: -> |
| 79 | return '/' if app.isSingleDoc() | 88 | return '/' if app.isSingleDoc() |
| @@ -53,7 +53,12 @@ page.replace = (path, state, skipDispatch, init) -> · 52 unmodified lines | |||
| 53 | context = new Context(path, state or currentState) | 53 | context = new Context(path, state or currentState) |
| 54 | context.init = init | 54 | context.init = init |
| 55 | currentState = context.state | 55 | currentState = context.state |
| 56 | page.dispatch(context) unless skipDispatch | 56 | result = page.dispatch(context) unless skipDispatch |
| 57 | if result | ||
| 58 | context = new Context(result) | ||
| 59 | context.init = init | ||
| 60 | currentState = context.state | ||
| 61 | page.dispatch(context) | ||
| 57 | context.replaceState() | 62 | context.replaceState() |
| 58 | updateCanonicalLink() | 63 | updateCanonicalLink() |
| 59 | track() unless skipDispatch | 64 | track() unless skipDispatch |