-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Program.cs
44 lines (43 loc) · 1.99 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
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Octokit;
using Statiq.App;
using Statiq.Common;
using Statiq.Web;
namespace CovidSafeWatch
{
public static class Program
{
public static async Task<int> Main(string[] args) =>
await Bootstrapper.Factory
.CreateWeb(args)
.AddSetting(WebKeys.NetlifyRedirects, true)
.DeployToNetlify(
Environment.GetEnvironmentVariable("NetlifySiteId"),
Environment.GetEnvironmentVariable("NetlifyAccessToken")
)
.AddSetting(Keys.Host, "covidsafe.watch")
.AddSetting(Keys.LinksUseHttps, true)
.AddSetting(WebKeys.MirrorResources, false)
// .AddSetting(WebKeys.MirrorResources, true)
.AddSetting(
Keys.DestinationPath,
Config.FromDocument((doc, ctx) =>
{
// Only applies to the content pipeline
if (ctx.PipelineName == nameof(Statiq.Web.Pipelines.Content))
{
return doc.Source.Parent.Segments.Last().SequenceEqual("posts".AsMemory())
? new NormalizedPath("blog").Combine(doc.GetDateTime(WebKeys.Published).ToString("yyyy/MM/dd")).Combine(doc.Destination.FileName.ChangeExtension(".html"))
: doc.Destination.ChangeExtension(".html");
}
return doc.Destination;
}))
.AddSetting("EditLink", Config.FromDocument((doc, ctx) => "https://github.com/covidsafewatch/website/edit/master/input/" + doc.Source.GetRelativeInputPath()))
.AddSetting(SiteKeys.NoChildPages, Config.FromDocument(doc => doc.Destination.Segments[0].SequenceEqual("blog".AsMemory())))
.AddPipelines()
.RunAsync();
}
}