Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
89 lines (76 sloc) 3.48 KB
#recipe Blog
#t BlogTemplate
#n Wyam.Minification
System.Globalization.CultureInfo.DefaultThreadCurrentCulture
= System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
// Customize your settings and add new ones here
Settings[Keys.Host] = "blog.kabrt.cz";
Settings[BlogKeys.Title] = "Lukas Kabrt";
Settings[BlogKeys.Description] = "Lukas Kabrt";
Settings[BlogKeys.CaseInsensitiveTags] = true;
Settings[BlogKeys.IndexFullPosts] = false;
// Add any pipeline customizations here
int tagsIndex = Pipelines.IndexOf(Blog.Tags);
Pipelines.Remove(Blog.Tags);
Pipelines.Insert(tagsIndex, Blog.Tags, new Wyam.Web.Pipelines.Archive(
Blog.Tags,
new Wyam.Web.Pipelines.ArchiveSettings
{
Pipelines = new string[] { Blog.BlogPosts },
TemplateFile = ctx => "_Tag.cshtml",
Layout = "/_Layout.cshtml",
Group = (doc, ctx) => doc.List<string>(BlogKeys.Tags),
CaseInsensitiveGroupComparer = ctx => ctx.Bool(BlogKeys.CaseInsensitiveTags),
PageSize = ctx => ctx.Get(BlogKeys.TagPageSize, int.MaxValue),
Title = (doc, ctx) => doc.String(Keys.GroupKey),
RelativePath = (doc, ctx) => $"tags/{doc.String(Keys.GroupKey).ToLower()}/index.html",
GroupDocumentsMetadataKey = BlogKeys.Posts,
GroupKeyMetadataKey = BlogKeys.Tag
}));
var renderBlogsPipeline = Pipelines[Blog.RenderBlogPosts];
var renderBlogsWriteFileModuleIndex = renderBlogsPipeline.IndexOf("WriteFiles");
renderBlogsPipeline.Insert(renderBlogsWriteFileModuleIndex,
new Meta(Keys.WritePath, (doc, ctx) => doc.Get<string>(Keys.RelativeFilePath).EndsWith("index.html") ? doc.Get<string>(Keys.RelativeFilePath) : doc.Get<string>(Keys.RelativeFileDir) + "/" + System.IO.Path.GetFileNameWithoutExtension(doc.Get<string>(Keys.RelativeFilePath)) + "/index.html")
);
int renderPagesIndex = Pipelines.IndexOf(Blog.RenderPages);
Pipelines.Remove(Blog.RenderPages);
Pipelines.Insert(renderPagesIndex, Blog.RenderPages,
new ModuleCollection() {
Documents().FromPipelines(new string[] { Blog.Pages }),
new Flatten()
},
new Razor().WithLayout((doc, ctx) => "/_PageLayout.cshtml"),
new Headings(),
new Meta(Keys.WritePath, (doc, ctx) => {
var filePath = doc.Get<string>(Keys.RelativeFilePath);
var preserveFilename = doc.Get<bool>("PreserveFilename");
return preserveFilename || filePath.EndsWith("index.html") ? filePath : doc.Get<string>(Keys.RelativeFileDir) + "/" + System.IO.Path.GetFileNameWithoutExtension(filePath) + "/index.html";
}),
new WriteFiles(),
new Sort((x, y) => Comparer<string>.Default.Compare(x.String(Keys.Title), y.String(Keys.Title)))
);
int sitemapIndex = Pipelines.IndexOf("Sitemap");
Pipelines.Remove("Sitemap");
Pipelines.Insert(renderPagesIndex, "Sitemap",
new Documents(ctx => ctx.Documents.Where(d => (string)d.Metadata["Title"] != "Page not found")),
new Wyam.Core.Modules.Contents.Sitemap(),
new WriteFiles((doc, ctx) => "sitemap.xml")
);
int sassIndex = Pipelines.IndexOf("Sass");
Pipelines.Remove("Sass");
Pipelines.Insert(sassIndex, "Sass",
new ReadFiles("**/{!.git,}/**/{!_,}*.scss"),
new Wyam.Sass.Sass(),
new Concat(
ReadFiles("assets/**/*.css")
),
new Combine(),
new Wyam.Minification.MinifyCss(),
new WriteFiles((doc, ctx) => "assets/css/blog.min.css").UseWriteMetadata(false)
);
Pipelines.Add("JS",
ReadFiles("assets/**/*.js"),
OrderBy((doc, ctx) => doc["SourceFileName"]),
new Combine(),
WriteFiles((doc, ctx) => "assets/js/blog.min.js")
);
You can’t perform that action at this time.