Unified · Split
| @@ -66,14 +66,23 @@ class app.Router · 65 unmodified lines | ||
| 66 | 66 | |
| 67 | 67 | entry: (context, next) -> |
| 68 | 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 | 74 | context.doc = doc |
| 72 | 75 | context.entry = entry |
| 73 | 76 | @triggerRoute 'entry' |
| 74 | 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 | 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 | 87 | root: -> |
| 79 | 88 | return '/' if app.isSingleDoc() |
| @@ -53,7 +53,12 @@ page.replace = (path, state, skipDispatch, init) -> · 52 unmodified lines | ||
| 53 | 53 | context = new Context(path, state or currentState) |
| 54 | 54 | context.init = init |
| 55 | 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 | 62 | context.replaceState() |
| 58 | 63 | updateCanonicalLink() |
| 59 | 64 | track() unless skipDispatch |