File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,16 @@ export default class ShowRoute extends Route {
19
19
} ,
20
20
} ;
21
21
22
+ modelCache = { } ;
23
+
22
24
model ( params ) {
23
25
// remove trailing slash
24
- let path = params . path . replace ( / \/ $ / , '' ) ;
26
+ const path = params . path . replace ( / \/ $ / , '' ) ;
27
+
28
+ // If the model is cached, return it
29
+ if ( this . modelCache [ path ] ) {
30
+ return this . modelCache [ path ] ;
31
+ }
25
32
26
33
// redirect if `index` is added to the URL
27
34
if ( path . endsWith ( '/index' ) ) {
@@ -128,7 +135,7 @@ export default class ShowRoute extends Route {
128
135
} ) ;
129
136
}
130
137
131
- return {
138
+ this . modelCache [ path ] = {
132
139
// IMPORTANT: this is the "component" ID which is used to get the correct backing class for the markdown "component"
133
140
// This ID comes from the markdown-to-json conversion (see `id: relativePath.replace(/\.md$/, '')` in `addons/field-guide/lib/markdown-to-jsonapi.js`)
134
141
id : res . data . id , // eg. 'components/alert/index'
@@ -141,6 +148,8 @@ export default class ShowRoute extends Route {
141
148
hasSidecar,
142
149
relatedComponents,
143
150
} ;
151
+
152
+ return this . modelCache [ path ] ;
144
153
} ) ;
145
154
}
146
155
You can’t perform that action at this time.
0 commit comments