File tree Expand file tree Collapse file tree 9 files changed +76
-8
lines changed Expand file tree Collapse file tree 9 files changed +76
-8
lines changed Original file line number Diff line number Diff line change @@ -30,4 +30,8 @@ public record AppConfiguration
30
30
public GiscusConfiguration GiscusConfiguration { get ; init ; }
31
31
32
32
public bool IsGiscusEnabled => GiscusConfiguration != null ;
33
- }
33
+
34
+ public DisqusConfiguration DisqusConfiguration { get ; init ; }
35
+
36
+ public bool IsDisqusEnabled => DisqusConfiguration != null ;
37
+ }
Original file line number Diff line number Diff line change 1
- using LinkDotNet . Blog . Domain ;
1
+ using System ;
2
+ using LinkDotNet . Blog . Domain ;
2
3
using LinkDotNet . Blog . Web . Shared . Services ;
3
4
using Microsoft . Extensions . Configuration ;
4
5
@@ -10,6 +11,7 @@ public static AppConfiguration Create(IConfiguration config)
10
11
{
11
12
var profileInformation = config . GetSection ( "AboutMeProfileInformation" ) . Get < ProfileInformation > ( ) ;
12
13
var giscus = config . GetSection ( "Giscus" ) . Get < GiscusConfiguration > ( ) ;
14
+ var disqus = config . GetSection ( "Disqus" ) . Get < DisqusConfiguration > ( ) ;
13
15
var configuration = new AppConfiguration
14
16
{
15
17
BlogName = config [ "BlogName" ] ,
@@ -21,8 +23,9 @@ public static AppConfiguration Create(IConfiguration config)
21
23
BlogPostsPerPage = int . Parse ( config [ "BlogPostsPerPage" ] ) ,
22
24
ProfileInformation = profileInformation ,
23
25
GiscusConfiguration = giscus ,
26
+ DisqusConfiguration = disqus ,
24
27
} ;
25
28
26
29
return configuration ;
27
30
}
28
- }
31
+ }
Original file line number Diff line number Diff line change 40
40
<InternalsVisibleTo Include =" LinkDotNet.Blog.IntegrationTests" />
41
41
</ItemGroup >
42
42
43
+ <ItemGroup >
44
+ <None Update =" Shared\Disqus.razor.js" >
45
+ <DependentUpon >Disqus.razor</DependentUpon >
46
+ </None >
47
+ </ItemGroup >
48
+
43
49
<ItemGroup >
44
- <None Update =" Shared\Giscus.razor.js" >
45
- <DependentUpon >Giscus.razor</DependentUpon >
46
- </None >
50
+ <None Update =" Shared\Giscus.razor.js" >
51
+ <DependentUpon >Giscus.razor</DependentUpon >
52
+ </None >
47
53
</ItemGroup >
54
+
48
55
<PropertyGroup >
49
56
<CodeAnalysisRuleSet >..\..\stylecop.analyzers.ruleset</CodeAnalysisRuleSet >
50
57
</PropertyGroup >
Original file line number Diff line number Diff line change 40
40
<div class =" d-flex justify-content-between py-2" >
41
41
<Like BlogPost =" @BlogPost" OnBlogPostLiked =" @UpdateLikes" ></Like >
42
42
<ShareBlogPost ></ShareBlogPost >
43
- </div >
44
- <Giscus ></Giscus >
43
+ </div >
44
+ <CommentSection ></CommentSection >
45
45
</div >
46
46
</div >
47
47
}
Original file line number Diff line number Diff line change
1
+ @inject AppConfiguration appConfiguration
2
+
3
+ @if (MultipleCommentPlugins )
4
+ {
5
+ <div class =" alert alert-danger" role =" alert" >
6
+ There are multiple comment sections configured . Please set up the configuration so that only one comment section is active .
7
+ </div >
8
+ }
9
+
10
+ @if (appConfiguration .IsDisqusEnabled )
11
+ {
12
+ <Disqus ></Disqus >
13
+ }
14
+ @if (appConfiguration .IsGiscusEnabled )
15
+ {
16
+ <Giscus ></Giscus >
17
+ }
18
+
19
+ @code {
20
+ private bool MultipleCommentPlugins => appConfiguration .IsDisqusEnabled && appConfiguration .IsGiscusEnabled ;
21
+
22
+ }
Original file line number Diff line number Diff line change
1
+ @inject IJSRuntime jsRuntime
2
+ @inject AppConfiguration appConfiguration
3
+ <div id =" disqus_thread" >
4
+ </div >
5
+
6
+ @code {
7
+ protected override async Task OnAfterRenderAsync (bool firstRender )
8
+ {
9
+ if (firstRender && appConfiguration .IsDisqusEnabled )
10
+ {
11
+ await jsRuntime .InvokeAsync <IJSObjectReference >(" import" , " ./Shared/Disqus.razor.js" );
12
+ await jsRuntime .InvokeVoidAsync (" initDisqus" , appConfiguration .DisqusConfiguration );
13
+ }
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ window . initDisqus = ( disqus ) => {
2
+ var d = document , s = d . createElement ( 'script' ) ;
3
+
4
+ s . src = `https://${ disqus . shortname } .disqus.com/embed.js` ;
5
+
6
+ s . setAttribute ( 'data-timestamp' , + new Date ( ) ) ;
7
+ d . body . appendChild ( s ) ;
8
+ }
Original file line number Diff line number Diff line change
1
+ namespace LinkDotNet . Blog . Web . Shared . Services ;
2
+
3
+ public record DisqusConfiguration
4
+ {
5
+ public string Shortname { get ; init ; }
6
+ }
Original file line number Diff line number Diff line change 34
34
"RepositoryId" : " " ,
35
35
"Category" : " " ,
36
36
"CategoryId" : " "
37
+ },
38
+ "Disqus" : {
39
+ "Shortname" : " debug-blog-test"
37
40
}
38
41
}
You can’t perform that action at this time.
0 commit comments