-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
57 lines (54 loc) · 2.21 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
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Statiq.App;
using Statiq.Common;
using Statiq.Web;
using Statiq.Core;
using Statiq.Minification;
namespace michaelburchdotnet
{
class Program
{
public static async Task<int> Main(string[] args) =>
await Bootstrapper
.Factory
.CreateWeb(args)
.AddShortcode<CaptionImage>()
.AddSetting("LinkHideExtensions", false)
.AddSetting("BlueskyUser","michaelburch.net")
.ModifyPipeline("Assets", p => p.WithProcessModules
(
// Exclude cookieconsent as it has it's own pipeline
new FilterDocuments(Config.FromDocument(doc => !doc.Source.Parent.FullPath.Contains("cookieconsent"))),
new SetDestination(Config.FromDocument(
doc =>
{
// Output folder name should be the same as input folder
// and nested under assets
var parentFolder = doc.Source.Parent.Segments[doc.Source.Parent.Segments.Length - 1].ToString();
// Except for scss
if (parentFolder == "scss")
parentFolder = "css";
// ... and images. Images are not nested under assets to match original structure
if (parentFolder == "images")
return new NormalizedPath($"./{parentFolder}/{doc.Destination.FileName}");
if (parentFolder == "input")
return new NormalizedPath($"./{doc.Destination.FileName}");
return new NormalizedPath($"./assets/{parentFolder}/{doc.Destination.FileName}");
}
)),
// Conditionally run minification
new ExecuteIf(Config.FromDocument(doc => doc.Destination.Extension == ".css"))
{
new MinifyCss()
},
new ExecuteIf(Config.FromDocument(doc => doc.Destination.Extension == ".js"))
{
new MinifyJs()
}
)
)
.RunAsync();
}
}