Skip to content

Instantly share code, notes, and snippets.

@shortbloke
Last active August 21, 2022 17:11
Show Gist options
  • Save shortbloke/de13dd33c0b12409353a3116dd8ce84c to your computer and use it in GitHub Desktop.
Save shortbloke/de13dd33c0b12409353a3116dd8ce84c to your computer and use it in GitHub Desktop.
Statiq Pipelines
using Statiq.Minification;
namespace HighlightHelp.pipelines
{
public class JavaScript : Pipeline
{
public JavaScript()
{
InputModules = new ModuleList
{
new ReadFiles("help/**/*.js")
};
PostProcessModules = new ModuleList
{
new MinifyJs(),
new SetDestination(".js")
};
OutputModules = new ModuleList
{
new WriteFiles()
};
}
}
}
using Statiq.Minification;
namespace HighlightHelp
{
class Program
{
public static async Task<int> Main(string[] args) =>
await Bootstrapper
.Factory
.CreateWeb(args)
/* ** HACK ** Clearing the file list for all the standard pipelines.
* Was unable to get existing piplines to minifi JS or HTML without acting on the wrong file types
* Was unable to stop analyzers - All the links were generating relative link errors.
*/
.AddSetting(WebKeys.InputFiles, "")
//.ModifyPipeline(nameof(Statiq.Web.Pipelines.Assets), p => p.PostProcessModules.Add(new MinifyJs()))
//.AddSetting(Keys.ValidateRelativeLinks, false)
.RunAsync();
}
}
using HighlightHelp.Modules.HLTemplate;
using Statiq.Minification;
using Statiq.Razor;
using Statiq.Yaml;
namespace HighlightHelp.pipelines
{
public class RazorPages : Pipeline
{
public RazorPages()
{
InputModules = new ModuleList
{
new ReadFiles("help/**/{!_,}*.cshtml")
};
ProcessModules = new ModuleList
{
new ExtractFrontMatter(new ParseYaml()),
new HLTemplate(),
new RenderRazor(),
new SetDestination(".html")
};
PostProcessModules = new ModuleList
{
new MinifyHtml()
};
OutputModules = new ModuleList
{
new WriteFiles()
};
}
}
}
namespace HighlightHelp.pipelines
{
public class Resources : Pipeline
{
public Resources()
{
InputModules = new ModuleList
{
new ReadFiles()
};
ProcessModules = new ModuleList
{
// Images
new CopyFiles("help/**/*.{png,gif,svg,jpg}"),
// Documents
new CopyFiles("help/**/*.pdf"),
new CopyFiles("help/**/*.xl{t,s}x"),
// Other
new CopyFiles("**/*web.config"),
new CopyFiles("help/favicon.ico")
};
}
}
}
using Statiq.Sass;
namespace HighlightHelp.pipelines
{
public class Sass : Pipeline
{
public Sass()
{
InputModules = new ModuleList
{
new ReadFiles("help/styles/main.scss")
};
ProcessModules = new ModuleList
{
new CompileSass()
.GenerateSourceMap()
.WithCompressedOutputStyle()
};
OutputModules = new ModuleList
{
new WriteFiles()
};
}
}
}
using Statiq.Lunr;
namespace HighlightHelp.pipelines
{
public class SearchIndex : Pipeline
{
public SearchIndex()
{
Dependencies.AddRange(nameof(RazorPages));
PostProcessModules = new ModuleList
{
new ReplaceDocuments(nameof(RazorPages)),
new GenerateLunrIndex()
.WithField("Description", FieldType.Result)
.WithField("Tags", FieldType.Result)
.WithClientName("searchModule")
.WithStopWordsFromFile("StopWords.txt")
.WithScriptPath("help/scripts/searchindex.js")
.ZipResultsFile(false)
};
OutputModules = new ModuleList
{
new WriteFiles()
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment