File tree Expand file tree Collapse file tree 10 files changed +98
-3
lines changed
LinkDotNet.Blog.UnitTests Expand file tree Collapse file tree 10 files changed +98
-3
lines changed Original file line number Diff line number Diff line change 47
47
<ItemGroup >
48
48
<Folder Include =" Infrastructure\Persistence" />
49
49
</ItemGroup >
50
+
51
+ <ItemGroup >
52
+ <Compile Remove =" Web\Shared\Services\LocalStorageServiceTests.cs" />
53
+ </ItemGroup >
50
54
<PropertyGroup >
51
55
<CodeAnalysisRuleSet >..\stylecop.analyzers.ruleset</CodeAnalysisRuleSet >
52
56
</PropertyGroup >
Original file line number Diff line number Diff line change 1
- using LinkDotNet . Domain ;
1
+ using LinkDotNet . Blog . Web . Shared . Services ;
2
+ using LinkDotNet . Domain ;
2
3
3
4
namespace LinkDotNet . Blog . Web
4
5
{
@@ -24,6 +25,10 @@ public record AppConfiguration
24
25
25
26
public bool IsAboutMeEnabled { get ; init ; }
26
27
27
- public ProfileInformation ProfileInformation { get ; set ; }
28
+ public ProfileInformation ProfileInformation { get ; init ; }
29
+
30
+ public Giscus Giscus { get ; init ; }
31
+
32
+ public bool IsGiscusEnabled { get ; init ; }
28
33
}
29
34
}
Original file line number Diff line number Diff line change 1
- using LinkDotNet . Domain ;
1
+ using LinkDotNet . Blog . Web . Shared . Services ;
2
+ using LinkDotNet . Domain ;
2
3
using Microsoft . Extensions . Configuration ;
3
4
4
5
namespace LinkDotNet . Blog . Web
@@ -8,6 +9,7 @@ public static class AppConfigurationFactory
8
9
public static AppConfiguration Create ( IConfiguration config )
9
10
{
10
11
var profileInformation = config . GetSection ( "AboutMeProfileInformation" ) . Get < ProfileInformation > ( ) ;
12
+ var giscus = config . GetSection ( "Giscus" ) . Get < Giscus > ( ) ;
11
13
var configuration = new AppConfiguration
12
14
{
13
15
BlogName = config [ "BlogName" ] ,
@@ -19,6 +21,8 @@ public static AppConfiguration Create(IConfiguration config)
19
21
BlogPostsPerPage = int . Parse ( config [ "BlogPostsPerPage" ] ) ,
20
22
ProfileInformation = profileInformation ,
21
23
IsAboutMeEnabled = profileInformation != null ,
24
+ Giscus = giscus ,
25
+ IsGiscusEnabled = giscus != null ,
22
26
} ;
23
27
24
28
return configuration ;
Original file line number Diff line number Diff line change 8
8
@inject IRepository <BlogPost > blogPostRepository
9
9
@inject IJSRuntime jsRuntime
10
10
@inject IUserRecordService userRecordService
11
+ @inject ICommentService commentService
11
12
@inherits MarkdownComponentBase
12
13
13
14
<div class =" page" >
40
41
</div >
41
42
</div >
42
43
<Like BlogPost =" @BlogPost" OnBlogPostLiked =" @UpdateLikes" ></Like >
44
+ <div class =" giscus" >
45
+ </div >
43
46
</div >
44
47
</div >
45
48
}
66
69
{
67
70
await userRecordService .StoreUserRecordAsync ();
68
71
await jsRuntime .InvokeVoidAsync (" hljs.highlightAll" );
72
+ await commentService .EnableCommentSection (" giscus" );
69
73
StateHasChanged ();
70
74
}
71
75
}
Original file line number Diff line number Diff line change 47
47
<script async src =" https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/js/all.min.js" integrity =" sha512-RXf+QSDCUQs5uwRKaDoXt55jygZZm2V++WUZduaU/Ui/9EGp3f/2KZVahFZBKGH0s774sd3HmrhUy+SgOFQLVQ==" crossorigin =" anonymous" referrerpolicy =" no-referrer" ></script >
48
48
<
script src =
" https://cdn.jsdelivr.net/npm/[email protected] /dist/js/bootstrap.bundle.min.js" integrity =
" sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin =
" anonymous" ></
script >
49
49
<script async src =" components/slideshow.js" ></script >
50
+ V
51
+ <script >
52
+ window .initGiscus = (divClass , giscus ) => {
53
+ const script = document .createElement (' script' );
54
+ script .src = ' https://giscus.app/client.js'
55
+ script .setAttribute (' data-repo' , giscus .repository )
56
+ script .setAttribute (' data-repo-id' , giscus .repositoryId )
57
+ script .setAttribute (' data-category' , giscus .category )
58
+ script .setAttribute (' data-category-id' , giscus .categoryId )
59
+ script .setAttribute (' data-mapping' , ' title' )
60
+ script .setAttribute (' data-reactions-enabled' , ' 0' )
61
+ script .setAttribute (' data-emit-metadata' , ' 0' )
62
+ script .setAttribute (' data-theme' , ' light' )
63
+ script .crossOrigin = ' anonymous'
64
+
65
+ const elementToAppend = document .getElementsByClassName (divClass)[0 ]
66
+ if (elementToAppend) {
67
+ elementToAppend .appendChild (script)
68
+ }
69
+ }
70
+ </script >
50
71
</body >
51
72
</html >
Original file line number Diff line number Diff line change
1
+ namespace LinkDotNet . Blog . Web . Shared . Services
2
+ {
3
+ public class Giscus
4
+ {
5
+ public string Repository { get ; set ; }
6
+
7
+ public string RepositoryId { get ; set ; }
8
+
9
+ public string Category { get ; set ; }
10
+
11
+ public string CategoryId { get ; set ; }
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ using System . Threading . Tasks ;
2
+ using Microsoft . JSInterop ;
3
+
4
+ namespace LinkDotNet . Blog . Web . Shared . Services
5
+ {
6
+ public class GiscusService : ICommentService
7
+ {
8
+ private readonly IJSRuntime jsRuntime ;
9
+
10
+ public GiscusService ( IJSRuntime jsRuntime )
11
+ {
12
+ this . jsRuntime = jsRuntime ;
13
+ }
14
+
15
+ public async Task EnableCommentSection ( string className )
16
+ {
17
+ var giscus = new Giscus
18
+ {
19
+ Repository = "linkdotnet/Blog.Discussions" ,
20
+ RepositoryId = "MDEwOlJlcG9zaXRvcnk0MDc1MzQ0OTA=" ,
21
+ Category = "General" ,
22
+ CategoryId = "DIC_kwDOGEp7ms4B_Fx_" ,
23
+ } ;
24
+
25
+ await jsRuntime . InvokeVoidAsync ( "initGiscus" , "giscus" , giscus ) ;
26
+ }
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ using System . Threading . Tasks ;
2
+
3
+ namespace LinkDotNet . Blog . Web . Shared . Services
4
+ {
5
+ public interface ICommentService
6
+ {
7
+ Task EnableCommentSection ( string className ) ;
8
+ }
9
+ }
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ public void ConfigureServices(IServiceCollection services)
54
54
services . AddSingleton < ISortOrderCalculator , SortOrderCalculator > ( ) ;
55
55
services . AddScoped < IUserRecordService , UserRecordService > ( ) ;
56
56
services . AddScoped < IDashboardService , DashboardService > ( ) ;
57
+ services . AddScoped < ICommentService , GiscusService > ( ) ;
57
58
}
58
59
59
60
public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
Original file line number Diff line number Diff line change 28
28
"Name" : " Steven Giesel" ,
29
29
"Heading" : " Software Engineer" ,
30
30
"ProfilePictureUrl" : " assets/profile-picture.webp"
31
+ },
32
+ "Giscus" : {
33
+ "Repository" : " " ,
34
+ "RepositoryId" : " " ,
35
+ "Category" : " " ,
36
+ "CategoryId" : " "
31
37
}
32
38
}
You can’t perform that action at this time.
0 commit comments