forked from dotnet-foundation/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (52 loc) · 2.02 KB
/
Program.cs
File metadata and controls
55 lines (52 loc) · 2.02 KB
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using Statiq.App;
using Statiq.Common;
using Statiq.Core;
using Statiq.Web;
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(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("Title"),
Keywords = x.GetString("Keywords"),
Link = x.GetLink(),
Content = x.GetContentStringAsync().GetAwaiter().GetResult()
})
)))
)
.WithOutputWriteFiles("projects/projects.json")
)
.RunAsync();
}
}
}