14
14
@inject IOptions <ApplicationConfiguration > AppConfiguration
15
15
@inject IOptions <ProfileInformation > ProfileInformation
16
16
@inject IOptions <SupportMeConfiguration > SupportConfiguration
17
+ @inject AuthenticationStateProvider AuthenticationStateProvider
17
18
18
19
@if (isLoading )
19
20
{
@@ -45,6 +46,8 @@ else if (BlogPost is not null)
45
46
46
47
<div class =" d-flex justify-content-center pt-2 blog-outer-box" >
47
48
<div class =" blog-container" >
49
+ @if (hasPermission )
50
+ {
48
51
<div class =" blog-inner-content" >
49
52
<header class =" text-center" >
50
53
<h1 class =" fw-bold" >@BlogPost.Title </h1 ></header >
@@ -79,6 +82,13 @@ else if (BlogPost is not null)
79
82
@( EnrichWithShortCodes (BlogPost .Content ))
80
83
</div >
81
84
</div >
85
+ }
86
+ else
87
+ {
88
+ <div class =" alert alert-warning text-center" role =" alert" >
89
+ <h1 class =" fs-3" >This content is only available for members .</h1 >
90
+ </div >
91
+ }
82
92
<div class =" d-flex justify-content-between py-2 border-top border-bottom align-items-center" >
83
93
<Like BlogPost =" @BlogPost" OnBlogPostLiked =" @UpdateLikes" ></Like >
84
94
<ShareBlogPost ></ShareBlogPost >
@@ -89,9 +99,58 @@ else if (BlogPost is not null)
89
99
}
90
100
@if (AppConfiguration .Value .ShowSimilarPosts )
91
101
{
92
- <SimilarBlogPostSection BlogPost =" @BlogPost" />
102
+ <div class =" blog-inner-content" >
103
+ <header class =" text-center" >
104
+ <h1 class =" fw-bold" >@BlogPost.Title </h1 ></header >
105
+ <div class =" text-dark-emphasis d-flex flex-wrap gap-2" >
106
+ <div class =" me-2" >
107
+ <span class =" date" ></span >
108
+ <span class =" ms-1" >@BlogPost.UpdatedDate.ToShortDateString() </span >
109
+ </div >
110
+ @if (BlogPost .Tags is not null && BlogPost .Tags .Any ())
111
+ {
112
+ <div class =" d-flex align-items-center" >
113
+ <span class =" blogpost-tag me-2" ></span >
114
+ <div class =" d-flex flex-wrap gap-2" >
115
+ @foreach ( var tag in BlogPost .Tags )
116
+ {
117
+ <a class =" goto-tag badge bg-primary rounded-pill text-decoration-none" href =" /searchByTag/@(Uri.EscapeDataString(tag))" >@tag </a >
118
+ }
119
+ </div >
120
+ </div >
121
+ }
122
+ </div >
123
+
124
+ <div class =" pt-2" >
125
+ <BlogPostAdminActions BlogPostId =" @BlogPostId" ></BlogPostAdminActions >
126
+ </div >
127
+
128
+ <div class =" pt-2" >
129
+ <TableOfContents Content =" @BlogPost.Content" CurrentUri =" @NavigationManager.Uri" ></TableOfContents >
130
+ </div >
131
+
132
+ <div class =" blogpost-content" >
133
+ @( EnrichWithShortCodes (BlogPost .Content ))
134
+ </div >
135
+ </div >
136
+ <div class =" d-flex justify-content-between py-2 border-top border-bottom align-items-center" >
137
+ <Like BlogPost =" @BlogPost" OnBlogPostLiked =" @UpdateLikes" ></Like >
138
+ <ShareBlogPost ></ShareBlogPost >
139
+ </div >
140
+ <DonationSection ></DonationSection >
141
+ @if (AppConfiguration .Value .ShowSimilarPosts )
142
+ {
143
+ <SimilarBlogPostSection BlogPost =" @BlogPost" />
144
+ }
145
+
146
+ <CommentSection ></CommentSection >
147
+ }
148
+ else
149
+ {
150
+ <div class =" alert alert-warning text-center" role =" alert" >
151
+ <h1 class =" fs-3" >This content is only available for members .</h1 >
152
+ </div >
93
153
}
94
- <CommentSection ></CommentSection >
95
154
</div >
96
155
</div >
97
156
@@ -113,6 +172,7 @@ else if (BlogPost is not null)
113
172
private string OgDataImage => BlogPost ! .PreviewImageUrlFallback ?? BlogPost .PreviewImageUrl ;
114
173
private string BlogPostCanoncialUrl => $" blogPost/{BlogPost ? .Id }" ;
115
174
private IReadOnlyCollection <ShortCode > shortCodes = [];
175
+ private bool hasPermission ;
116
176
117
177
private BlogPost ? BlogPost { get ; set ; }
118
178
@@ -125,6 +185,15 @@ else if (BlogPost is not null)
125
185
{
126
186
isLoading = true ;
127
187
BlogPost = await BlogPostRepository .GetByIdAsync (BlogPostId );
188
+ if (BlogPost ? .IsMembersOnly ?? false )
189
+ {
190
+ var state = await AuthenticationStateProvider .GetAuthenticationStateAsync ();
191
+ hasPermission = state .User .IsInRole (" Admin" ) || state .User .IsInRole (" Member" );
192
+ }
193
+ else
194
+ {
195
+ hasPermission = true ;
196
+ }
128
197
isLoading = false ;
129
198
}
130
199
0 commit comments