Repository navigation
Expand file tree
/
Copy pathBlog.cshtml
More file actions
186 lines (183 loc) · 9.83 KB
/
Copy pathBlog.cshtml
File metadata and controls
186 lines (183 loc) · 9.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
@page "/blog"
@attribute [RenderStatic]
@inject MarkdownBlog Blog
@{
ViewData["Title"] = "MyApp Blog";
}
<div class="container mx-auto px-5 mt-24 mb-24">
@{
var posts = Blog.GetPosts();
var primaryPost = posts.FirstOrDefault();
if (primaryPost != null)
{
var authorHref = Blog.GetAuthorLink(primaryPost.Author);
<section>
<div class="mb-8 md:mb-16">
<div class="sm:mx-0">
<a aria-label="@primaryPost.Title" href="@Blog.GetPostLink(primaryPost)">
<img src="@primaryPost.Image" alt="Cover Image for @primaryPost.Title" class="shadow-sm hover:shadow-2xl transition-shadow duration-200">
</a>
</div>
</div>
<div class="md:grid md:grid-cols-2 md:gap-x-16 lg:gap-x-8 mb-20 md:mb-28">
<div>
<h3 class="mb-4 text-4xl lg:text-6xl leading-tight">
<a class="hover:underline" href="@Blog.GetPostLink(primaryPost)">@primaryPost.Title</a>
</h3>
<div class="mb-4 md:mb-0 text-lg">
<time datetime="@Blog.GetDateTimestamp(primaryPost.Date)">@Blog.GetDateLabel(primaryPost.Date)</time>
</div>
</div>
<div>
<p class="text-lg leading-relaxed mb-4">@primaryPost.Summary</p>
@if (authorHref != null)
{
<a class="flex items-center text-xl font-bold" href="@authorHref">
<img src="@Blog.GetAuthorProfileUrl(primaryPost.Author)" class="w-12 h-12 rounded-full mr-4" alt="Author">
<span>@primaryPost.Author</span>
</a>
}
else
{
<span class="flex items-center text-xl font-bold">
<img src="@Blog.GetAuthorProfileUrl(primaryPost.Author)" class="w-12 h-12 rounded-full mr-4" alt="Author">
<span>@primaryPost.Author</span>
</span>
}
</div>
</div>
</section>
}
var gridPosts = posts.Skip(1).Take(6).ToList();
if (gridPosts.Count > 0)
{
<section>
<h2 class="mb-8 text-6xl md:text-7xl font-bold tracking-tighter leading-tight">More from the blog</h2>
<div class="mx-auto mt-12 grid max-w-lg gap-5 lg:max-w-none lg:grid-cols-3">
@foreach (var post in gridPosts)
{
var authorHref = Blog.GetAuthorLink(post.Author);
<div class="flex flex-col overflow-hidden rounded-lg shadow-lg">
<div class="flex-shrink-0">
<a href="@Blog.GetPostLink(post)">
<img class="h-48 w-full object-cover" src="@Blog.GetSplashImage(post)" alt="">
</a>
</div>
<div class="flex flex-1 flex-col justify-between bg-white dark:bg-black p-6">
<div class="flex-1">
<p class="text-sm font-medium text-indigo-600 dark:text-indigo-300">
Article
</p>
<a href="@Blog.GetPostLink(post)" class="mt-2 block">
<p class="text-xl font-semibold text-gray-900 dark:text-gray-50">@post.Title</p>
<p class="mt-3 text-base text-gray-500">@post.Summary</p>
</a>
</div>
<div class="mt-6 flex items-center">
<div class="flex-shrink-0">
<span>
<span class="sr-only">@post.Author</span>
<img class="h-10 w-10 rounded-full" src="@Blog.GetAuthorProfileUrl(post.Author)" alt="@post.Title background">
</span>
</div>
<div class="ml-3">
<p class="text-sm font-medium text-gray-900">
@if (authorHref != null)
{
<a href="@Blog.GetAuthorLink(post.Author!)" class="hover:underline">@post.Author</a>
}
else
{
<span>@post.Author</span>
}
</p>
<div class="flex space-x-1 text-sm text-gray-500">
<time datetime="@Blog.GetDateTimestamp(post.Date)">@Blog.GetDateLabel(post.Date)</time>
<span aria-hidden="true">·</span>
<span>@Blog.MinutesToRead(post.WordCount) min read</span>
</div>
</div>
</div>
</div>
</div>
}
</div>
</section>
}
var remainingPosts = posts.Skip(7).Take(15).ToList();
if (remainingPosts.Count > 0)
{
<section class="mt-24 flex justify-center">
<div class="flex max-w-screen-lg">
<div class="w-2/3">
@foreach (var post in remainingPosts)
{
var authorHref = Blog.GetAuthorLink(post.Author);
<div class="border-b pb-4 mb-4">
<div class="flex justify-between">
<div class="w-3/4">
<a href="@Blog.GetPostLink(post)" class="mt-2 block">
<p class="text-xl font-semibold text-gray-900 dark:text-gray-50">@post.Title</p>
<p class="mt-3 text-base text-gray-500">@post.Summary</p>
</a>
<div class="mt-6 flex items-center">
<div class="flex-shrink-0">
<span>
<span class="sr-only">@post.Author</span>
<img class="h-10 w-10 rounded-full" src="@Blog.GetAuthorProfileUrl(post.Author)" alt="@post.Title background">
</span>
</div>
<div class="ml-3">
<p class="text-sm font-medium text-gray-900">
@if (authorHref != null)
{
<a href="@Blog.GetAuthorLink(post.Author!)" class="hover:underline">@post.Author</a>
}
else
{
<span>@post.Author</span>
}
</p>
<div class="flex space-x-1 text-sm text-gray-500">
<time datetime="@Blog.GetDateTimestamp(post.Date)">@Blog.GetDateLabel(post.Date)</time>
<span aria-hidden="true">·</span>
<span>@Blog.MinutesToRead(post.WordCount) min read</span>
</div>
</div>
</div>
</div>
<div class="w-1/4">
<a href="@Blog.GetPostLink(post)" class="pt-4">
<img class="w-full object-cover max-h-[130px]" src="@Blog.GetSplashImage(post)" alt="">
</a>
</div>
</div>
</div>
}
@if (remainingPosts.Count >= 15)
{
<div class="mt-8 text-center">
<a class="text-sm font-semibold hover:underline" href="@Blog.GetPostsLink()">view all posts</a>
</div>
}
</div>
<div class="w-1/3">
<div class="pl-8">
<div class="flex items-center">
<img class="w-8 h-8" src="img/logo.svg" alt="MyApp logo">
<span class="hidden sm:block text-lg font-semibold">MyApp</span>
</div>
<div class="p-2">
<p class="text-gray-500">I’m Spencer Sharp. I live in New York City, where I design the future.</p>
<a href="about" class="text-sm font-medium text-gray-900 hover:underline">more information</a>
</div>
<div class="p-4">
@await Html.PartialAsync("FollowLinks")
</div>
</div>
</div>
</div>
</section>
}
}
</div>