mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Merge pull request #3104 from jaswilli/route-undefined
Stay on posts.index route when no posts exist
This commit is contained in:
commit
da4fc98d47
3 changed files with 17 additions and 21 deletions
|
@ -2,7 +2,7 @@ import AuthenticatedRoute from 'ghost/routes/authenticated';
|
||||||
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var PostsIndexRoute = AuthenticatedRoute.extend(loadingIndicator, {
|
var PostsIndexRoute = AuthenticatedRoute.extend(loadingIndicator, {
|
||||||
// redirect to first post subroute
|
// redirect to first post subroute unless no posts exist
|
||||||
beforeModel: function () {
|
beforeModel: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
@ -11,7 +11,10 @@ var PostsIndexRoute = AuthenticatedRoute.extend(loadingIndicator, {
|
||||||
staticPages: 'all'
|
staticPages: 'all'
|
||||||
}).then(function (records) {
|
}).then(function (records) {
|
||||||
var post = records.get('firstObject');
|
var post = records.get('firstObject');
|
||||||
|
|
||||||
|
if (post) {
|
||||||
return self.transitionTo('posts.post', post);
|
return self.transitionTo('posts.post', post);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
6
core/client/templates/posts/index.hbs
Normal file
6
core/client/templates/posts/index.hbs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<div class="no-posts-box">
|
||||||
|
<div class="no-posts">
|
||||||
|
<h3>You Haven't Written Any Posts Yet!</h3>
|
||||||
|
{{#link-to "editor.new"}}<button class="button-add large" title="New Post">Write a new Post</button>{{/link-to}}
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,5 +1,3 @@
|
||||||
{{#if title}}
|
|
||||||
|
|
||||||
{{partial "floating-header"}}
|
{{partial "floating-header"}}
|
||||||
|
|
||||||
{{#view "content-preview-content-view" tagName="section"}}
|
{{#view "content-preview-content-view" tagName="section"}}
|
||||||
|
@ -8,14 +6,3 @@
|
||||||
{{{html}}}
|
{{{html}}}
|
||||||
</div>
|
</div>
|
||||||
{{/view}}
|
{{/view}}
|
||||||
|
|
||||||
{{else}}
|
|
||||||
|
|
||||||
<div class="no-posts-box">
|
|
||||||
<div class="no-posts">
|
|
||||||
<h3>You Haven't Written Any Posts Yet!</h3>
|
|
||||||
{{#link-to "editor.new"}}<button class="button-add large" title="New Post">Write a new Post</button>{{/link-to}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{/if}}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue