forked from dotnet-foundation/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
64 lines (62 loc) · 2.64 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Statiq.App;
using Statiq.Common;
using Statiq.Core;
using Statiq.Web;
using System;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
namespace DotnetFoundationWeb
{
public static class Program
{
public static async Task<int> Main(string[] args)
{
Func<string, string> formatter = null;
if (!string.IsNullOrWhiteSpace(AppSettings.ServerUrl))
{
var formatterString = AppSettings.ServerUrl + "/{0}";
formatter = f => string.Format(formatterString, f);
}
return await Bootstrapper.Factory
.CreateWeb(args)
.AddSetting(WebKeys.InputFiles, new [] { "**/{!_,}*", "_redirects" })
.AddSetting(Keys.Host, "dotnetfoundation.org")
.AddSetting(Keys.LinksUseHttps, true)
.AddSetting(WebKeys.MirrorResources, true)
.AddSetting(WebKeys.ExcludedPaths, "api/node_modules")
.BuildPipeline(
"GenerateProjectsJson",
builder => builder
.WithDependencies(nameof(Statiq.Web.Pipelines.Content))
.WithProcessModules(
new ReplaceDocuments(nameof(Statiq.Web.Pipelines.Content)),
new FlattenTree(),
new FilterSources("projects/data/*.md"),
new ExecuteConfig(Config.FromContext(ctx =>
JsonSerializer.Serialize(ctx.Inputs.Select(x => new
{
Title = x.GetString(WebKeys.Title),
Keywords = x.GetString(SiteKeys.Keywords),
Link = x.GetLink(),
Content = x.GetContentStringAsync().GetAwaiter().GetResult()
})
)))
)
.WithOutputWriteFiles("projects/projects.json")
)
.ModifyPipeline(
nameof(Statiq.Web.Pipelines.Content),
x => x.ProcessModules.Add(
// Modules for speakers
new ExecuteSources("community/speakers/*.md")
{
new GeocodeLocations(Config.FromSetting(SiteKeys.AzureMapsSubscriptionKey)),
new GetBlogFeeds(),
new SpeakerImage()
}
))
.RunAsync();
}
}
}