|
3 | 3 | @{ |
4 | 4 | ViewData["bodyClass"] = "home"; |
5 | 5 | var pgr = Model.Pager; |
6 | | - |
7 | 6 | var first3 = _db.BlogPosts.All().OrderByDescending(p => p.Published).Take(3).ToList(); |
8 | | - |
9 | | - |
10 | 7 | } |
11 | 8 | <!DOCTYPE html> |
12 | 9 | <html lang="en"> |
|
19 | 16 |
|
20 | 17 | <div class="page-content"> |
21 | 18 |
|
22 | | - |
23 | 19 | @if (Model.PostListType == PostListType.Search) |
24 | | - { |
| 20 | + { |
25 | 21 | <div class="page-search"> |
26 | 22 | <div class="container"> |
27 | 23 | <h2 class="page-search-title"><i class="fa fa-search"></i> @Model.Blog.Title</h2> |
28 | 24 | </div> |
29 | 25 | </div> |
30 | | - } |
31 | | - else if (Model.PostListType == PostListType.Author) |
32 | | - { |
| 26 | + } |
| 27 | + else if (Model.PostListType == PostListType.Author) |
| 28 | + { |
33 | 29 | <div class="page-author"> |
34 | 30 | <div class="container"> |
35 | 31 | <h2 class="page-author-title"> |
|
38 | 34 | </h2> |
39 | 35 | </div> |
40 | 36 | </div> |
41 | | - } |
42 | | - else if (Model.PostListType == PostListType.Category) |
43 | | - { |
| 37 | + } |
| 38 | + else if (Model.PostListType == PostListType.Category) |
| 39 | + { |
44 | 40 | <div class="page-category"> |
45 | 41 | <div class="container"> |
46 | 42 | <h2 class="page-category-title"><i class="fa fa-tag"></i> @ViewBag.Category</h2> |
47 | 43 | </div> |
48 | 44 | </div> |
49 | | - } |
50 | | - else |
51 | | - { |
52 | | - } |
53 | | - |
| 45 | + } |
54 | 46 |
|
55 | 47 | @if (Model.Posts != null) |
56 | | - { |
57 | | - foreach (var item in Model.Posts) |
58 | | - { |
59 | | - var img = string.IsNullOrEmpty(item.Cover) ? Model.Blog.Cover : item.Cover; |
60 | | - <article class="post"> |
61 | | - <div class="post-cover"> |
62 | | - <img src="~/@img" alt="@item.Title"> |
63 | | - |
64 | | - </div> |
65 | | - <div class="container"> |
66 | | - <div class="row"> |
67 | | - <div class="col-sm-2"></div> |
68 | | - <div class="col-sm-10"> |
69 | | - <header class="post-header"> |
70 | | - <h2 class="post-title"><a href="~/posts/@item.Slug">@item.Title</a></h2> |
71 | | - </header> |
72 | | - @if (item.Featured) |
73 | | - { |
74 | | - <span class="post-featrued-label" title="Featured" data-toggle="tooltip"><i class="fa fa-star"></i></span> |
75 | | - } |
| 48 | + { |
| 49 | + foreach (var item in Model.Posts) |
| 50 | + { |
| 51 | + var img = string.IsNullOrEmpty(item.Cover) ? Model.Blog.Cover : item.Cover; |
| 52 | + var avatar = string.IsNullOrEmpty(item.Author.Avatar) ? "lib/img/avatar.jpg" : item.Author.Avatar; |
| 53 | + <article class="post"> |
| 54 | + <div class="post-cover"> |
| 55 | + <img src="~/@img" alt="@item.Title"> |
76 | 56 | </div> |
77 | | - <div class="col-sm-2"> |
78 | | - <div class="post-meta"> |
79 | | - <a class="post-meta-author" href="~/authors/@item.Author.AppUserName"> |
80 | | - <img class="post-meta-author-avatar" src="~/@item.Author.Avatar" alt="Author: @item.Author.DisplayName" /> |
81 | | - <div class="post-meta-author-name">@item.Author.DisplayName</div> |
82 | | - </a> |
83 | | - <div class="post-meta-category"> |
84 | | - <a href="#">Technology</a> |
| 57 | + <div class="container"> |
| 58 | + <div class="row"> |
| 59 | + <div class="col-sm-2"></div> |
| 60 | + <div class="col-sm-10"> |
| 61 | + <header class="post-header"> |
| 62 | + <h2 class="post-title"><a href="~/posts/@item.Slug">@item.Title</a></h2> |
| 63 | + </header> |
| 64 | + @if (item.Featured) |
| 65 | + { |
| 66 | + <span class="post-featrued-label" title="Featured" data-toggle="tooltip"><i class="fa fa-star"></i></span> |
| 67 | + } |
| 68 | + </div> |
| 69 | + <div class="col-sm-2"> |
| 70 | + <div class="post-meta"> |
| 71 | + <a class="post-meta-author" href="~/authors/@item.Author.AppUserName"> |
| 72 | + <img class="post-meta-author-avatar" src="~/@avatar" alt="Author: @item.Author.DisplayName" /> |
| 73 | + <div class="post-meta-author-name">@item.Author.DisplayName</div> |
| 74 | + </a> |
| 75 | + <div class="post-meta-category"> |
| 76 | + <a href="#">Technology</a> |
| 77 | + </div> |
| 78 | + <time class="post-meta-time">@item.Published.ToFriendlyDateString()</time> |
| 79 | + </div> |
| 80 | + </div> |
| 81 | + <div class="col-sm-10"> |
| 82 | + <div class="post-description">@Html.Raw(Markdig.Markdown.ToHtml(item.Description))</div> |
85 | 83 | </div> |
86 | | - <time class="post-meta-time">@item.Published.ToFriendlyDateString()</time> |
87 | 84 | </div> |
88 | 85 | </div> |
89 | | - <div class="col-sm-10"> |
90 | | - <div class="post-description">@Html.Raw(Markdig.Markdown.ToHtml(item.Description))</div> |
91 | | - |
92 | | - </div> |
93 | | - </div> |
94 | | - </div> |
95 | | - </article> |
96 | | - } |
97 | | - } |
| 86 | + </article> |
| 87 | + } |
| 88 | + } |
98 | 89 |
|
99 | 90 | @if (pgr != null && (pgr.ShowOlder || pgr.ShowNewer)) |
100 | | - { |
| 91 | + { |
101 | 92 | <ul class="pagination justify-content-center"> |
102 | 93 | @if (pgr.ShowOlder) |
103 | | - { |
| 94 | + { |
104 | 95 | <li class="item item-prev"> |
105 | 96 | <a class="item-link" href="~/@pgr.LinkToOlder"> |
106 | 97 | <i class="fa fa-chevron-left"></i> |
107 | 98 | </a> |
108 | 99 | </li> |
109 | | - } |
| 100 | + } |
110 | 101 | @if (pgr.ShowNewer) |
111 | | - { |
| 102 | + { |
112 | 103 | <li class="item item-next"> |
113 | 104 | <a class="item-link" href="~/@pgr.LinkToNewer"> |
114 | 105 | <i class="fa fa-chevron-right"></i> |
115 | | - |
116 | 106 | </a> |
117 | 107 | </li> |
118 | | - } |
| 108 | + } |
119 | 109 | </ul> |
120 | | - } |
121 | | - |
| 110 | + } |
122 | 111 | </div> |
123 | 112 |
|
124 | | - |
125 | 113 | <partial name="~/Views/Themes/bridge/_Shared/_Footer.cshtml" /> |
126 | 114 |
|
127 | | - |
128 | 115 | </body> |
129 | 116 | </html> |
0 commit comments