File tree 6 files changed +35
-6
lines changed
6 files changed +35
-6
lines changed Original file line number Diff line number Diff line change
1
+ namespace StaticBlogTemplate . Helpers
2
+ {
3
+ public class ConfigurationHelper
4
+ {
5
+ public static void Initialize ( IConfiguration configuration )
6
+ {
7
+ Configuration = configuration ;
8
+ }
9
+
10
+ public static IConfiguration ? Configuration { get ; private set ; }
11
+
12
+ public static string BaseUrl
13
+ {
14
+ get
15
+ {
16
+ return Configuration ? [ "Settings:BaseUrl" ] ?? string . Empty ;
17
+ }
18
+ }
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ using StaticBlogTemplate . Helpers ;
1
2
using StaticBlogTemplate . Utilities ;
2
3
3
4
var builder = WebApplication . CreateBuilder ( args ) ;
4
5
6
+ ConfigurationHelper . Initialize ( builder . Configuration ) ;
7
+
5
8
// Add services to the container.
6
9
var mvcBuilder = builder . Services . AddControllersWithViews ( ) ;
7
10
Original file line number Diff line number Diff line change
1
+ using StaticBlogTemplate . Helpers ;
1
2
using System . Text ;
2
3
3
4
namespace StaticBlogTemplate . Utilities ;
@@ -11,10 +12,10 @@ public static void Generate()
11
12
<rss version=""2.0"" xmlns:atom=""http://www.w3.org/2005/Atom"">
12
13
<channel>
13
14
<title>My Super Blog</title>
14
- <link>https://www.YOUR_BASE_URL.com /</link>
15
+ <link>{ ConfigurationHelper . BaseUrl } /</link>
15
16
<description>The description for the blog content of my site</description>
16
17
<lastBuildDate>{ today . ToString ( "r" ) } </lastBuildDate>
17
- <atom:link href=""https://www.YOUR_BASE_URL.com /rss.xml"" rel=""self"" type=""application/rss+xml"" />
18
+ <atom:link href=""{ ConfigurationHelper . BaseUrl } /rss.xml"" rel=""self"" type=""application/rss+xml"" />
18
19
{{0}}
19
20
</channel>
20
21
</rss>" ;
@@ -23,7 +24,7 @@ public static void Generate()
23
24
24
25
foreach ( var post in PostManager . Posts )
25
26
{
26
- var fullUrl = $ "https://www.YOUR_BASE_URL.com /{ post . Value . RelativeUrl } ";
27
+ var fullUrl = $ "{ ConfigurationHelper . BaseUrl } /{ post . Value . RelativeUrl } ";
27
28
28
29
stringBuilder . Append ( $@ "
29
30
<item>
Original file line number Diff line number Diff line change
1
+ using StaticBlogTemplate . Helpers ;
1
2
using System . Text ;
2
3
3
4
namespace StaticBlogTemplate . Utilities ;
@@ -19,7 +20,7 @@ public static void Generate()
19
20
</url>" ;
20
21
21
22
var stringBuilder = new StringBuilder ( ) ;
22
- var baseUrl = $ "https://www.YOUR_BASE_URL.com /";
23
+ var baseUrl = $ "{ ConfigurationHelper . BaseUrl } /";
23
24
24
25
stringBuilder . AppendFormat ( template , baseUrl , "2023-02-10" ) ;
25
26
Original file line number Diff line number Diff line change 1
- @{
1
+ @using StaticBlogTemplate .Helpers ;
2
+ @{
2
3
var relativeUrl = ViewBag .RelativeUrl ;
3
- var fullUrl = $" https://www.YOUR_BASE_URL.com /{relativeUrl }" ;
4
+ var fullUrl = $" { ConfigurationHelper . BaseUrl } /{relativeUrl }" ;
4
5
}
5
6
6
7
<!DOCTYPE html>
Original file line number Diff line number Diff line change 5
5
"Microsoft.AspNetCore" : " Warning"
6
6
}
7
7
},
8
+ "Settings" : {
9
+ "BaseUrl" : " https://www.YOUR_BASE_URL.com"
10
+ },
8
11
"AllowedHosts" : " *"
9
12
}
You can’t perform that action at this time.
0 commit comments