@@ -51,8 +51,7 @@ public void Configure(IWebHostBuilder builder) => builder
51
51
includes . LoadFrom ( "_includes" ) ;
52
52
pages . LoadFrom ( "_pages" ) ;
53
53
videos . LoadFrom ( "_videos" ) ;
54
- AppConfig . Instance . GitPagesBaseUrl ??= ResolveGitBlobBaseUrl ( appHost . ContentRootDirectory ) ;
55
- AppConfig . Instance . GitPagesRawBaseUrl ??= ResolveGitRawBlobBaseUrl ( appHost . ContentRootDirectory ) ;
54
+ AppConfig . Instance . Init ( appHost . ContentRootDirectory ) ;
56
55
} ,
57
56
afterAppHostInit : appHost =>
58
57
{
@@ -78,26 +77,23 @@ public void Configure(IWebHostBuilder builder) => builder
78
77
RazorSsg . PrerenderAsync ( appHost , razorFiles , distDir ) . GetAwaiter ( ) . GetResult ( ) ;
79
78
} ) ;
80
79
} ) ;
81
-
82
- private string ? ResolveGitBlobBaseUrl ( IVirtualDirectory contentDir )
80
+ }
81
+
82
+ public class AppConfig
83
+ {
84
+ public static AppConfig Instance { get ; } = new ( ) ;
85
+ public string Title { get ; set ; }
86
+ public string LocalBaseUrl { get ; set ; }
87
+ public string PublicBaseUrl { get ; set ; }
88
+ public string ? GitPagesBaseUrl { get ; set ; }
89
+ public string ? GitPagesRawBaseUrl { get ; set ; }
90
+
91
+ public void Init ( IVirtualDirectory contentDir )
83
92
{
84
- var srcDir = new DirectoryInfo ( contentDir . RealPath ) ;
85
- var gitConfig = new FileInfo ( Path . Combine ( srcDir . Parent ! . FullName , ".git" , "config" ) ) ;
86
- if ( gitConfig . Exists )
87
- {
88
- var txt = gitConfig . ReadAllText ( ) ;
89
- var pos = txt . IndexOf ( "url = " , StringComparison . Ordinal ) ;
90
- if ( pos >= 0 )
91
- {
92
- var url = txt [ ( pos + "url = " . Length ) ..] . LeftPart ( ".git" ) . LeftPart ( '\n ' ) . Trim ( ) ;
93
- var gitBaseUrl = url . CombineWith ( $ "blob/main/{ srcDir . Name } ") ;
94
- return gitBaseUrl ;
95
- }
96
- }
97
- return null ;
93
+ ResolveGitBlobBaseUrls ( contentDir ) ;
98
94
}
99
-
100
- private string ? ResolveGitRawBlobBaseUrl ( IVirtualDirectory contentDir )
95
+
96
+ public void ResolveGitBlobBaseUrls ( IVirtualDirectory contentDir )
101
97
{
102
98
var srcDir = new DirectoryInfo ( contentDir . RealPath ) ;
103
99
var gitConfig = new FileInfo ( Path . Combine ( srcDir . Parent ! . FullName , ".git" , "config" ) ) ;
@@ -108,24 +104,13 @@ public void Configure(IWebHostBuilder builder) => builder
108
104
if ( pos >= 0 )
109
105
{
110
106
var url = txt [ ( pos + "url = " . Length ) ..] . LeftPart ( ".git" ) . LeftPart ( '\n ' ) . Trim ( ) ;
111
- var gitBaseUrl = url . Replace ( "github.com" , "raw.githubusercontent.com" ) . CombineWith ( $ "refs/heads /main/{ srcDir . Name } ") ;
112
- return gitBaseUrl ;
107
+ GitPagesBaseUrl = url . CombineWith ( $ "blob /main/{ srcDir . Name } ") ;
108
+ GitPagesRawBaseUrl = url . Replace ( "github.com" , "raw.githubusercontent.com" ) . CombineWith ( $ "refs/heads/main/ { srcDir . Name } " ) ;
113
109
}
114
110
}
115
- return null ;
116
111
}
117
112
}
118
113
119
- public class AppConfig
120
- {
121
- public static AppConfig Instance { get ; } = new ( ) ;
122
- public string Title { get ; set ; }
123
- public string LocalBaseUrl { get ; set ; }
124
- public string PublicBaseUrl { get ; set ; }
125
- public string ? GitPagesBaseUrl { get ; set ; }
126
- public string ? GitPagesRawBaseUrl { get ; set ; }
127
- }
128
-
129
114
// Add additional frontmatter info to include
130
115
public class MarkdownFileInfo : MarkdownFileBase
131
116
{
0 commit comments