Skip to content

Commit 228b689

Browse files
committed
add title-tag support
1 parent a599eaa commit 228b689

8 files changed

Lines changed: 25 additions & 3 deletions

File tree

SnowSite/Snow/snow.config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
},{
2626
"file": "categories.cshtml => category"
2727
},{
28-
"file": "archive.cshtml"
28+
"file": "archive.cshtml",
29+
"title": "Archive"
2930
},{
3031
"file": "about.cshtml"
3132
},{

SnowSite/Snow/themes/default/_layouts/default.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@using System.Collections.Generic
33
@{
44
var keywords = String.Join(",", Model.Keywords);
5+
var title = String.Join("", Model.HeaderTitleChain);
56
}
67
<!DOCTYPE html>
78
<html dir="ltr" lang="en-US">
@@ -10,7 +11,7 @@
1011
<meta name="viewport" content="width=device-width" />
1112
<meta http-equiv="last-modified" content="@Model.GeneratedDate" />
1213
<meta name="keywords" content="@keywords" />
13-
<title>philliphaydon.com</title>
14+
<title>@title</title>
1415
<link rel="stylesheet" type="text/css" href="/stylesheets/style.css" />
1516
@Html.CanonicalUrl()
1617
</head>

src/Snow/StaticFile.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ public class StaticFile
44
{
55
public string File { get; set; }
66
public string Loop { get; set; }
7+
/// <summary>
8+
/// File title to use in header title if it's HTML. May be overridden by loop.
9+
/// </summary>
10+
public string Title { get; set; }
711
}
812
}

src/Snow/StaticFileProcessors/BaseProcessor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Globalization;
55
using System.IO;
6+
using System.Linq;
67
using Enums;
78

89
public abstract class BaseProcessor
@@ -20,6 +21,9 @@ public void Process(SnowyData snowyData, SnowSettings settings)
2021
ParseDirectories(snowyData);
2122
TestModule.StaticFile = SourceFile;
2223
TestModule.Published = Published.True;
24+
TestModule.HeaderTitleChain = new string[] { snowyData.File.Title, TestModule.Settings.BlogTitle }
25+
.Where(t => !string.IsNullOrWhiteSpace(t))
26+
.ToList();
2327

2428
Impl(snowyData, settings);
2529
}

src/Snow/StaticFileProcessors/CategoriesProcessor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ protected override void Impl(SnowyData snowyData, SnowSettings settings)
2323
var posts = GetPosts(snowyData.Files, category);
2424

2525
TestModule.Category = category;
26+
TestModule.HeaderTitleChain = new[] { category.Name, "Categories", TestModule.Settings.BlogTitle };
2627
TestModule.GeneratedUrl = settings.SiteUrl + "/category/" + category.Url + "/";
2728
TestModule.PostsInCategory = posts.ToList();
2829

src/Snow/StaticFileProcessors/DraftsProcessor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Snow.StaticFileProcessors
22
{
33
using Enums;
4+
using Snow.Models;
45

56
public class DraftsProcessor : StaticFileProcessor
67
{
@@ -12,7 +13,7 @@ public override string ProcessorName
1213
protected override void Impl(SnowyData snowyData, SnowSettings settings)
1314
{
1415
TestModule.Published = Published.Draft;
15-
16+
TestModule.HeaderTitleChain = new[] { "Drafts", TestModule.Settings.BlogTitle };
1617
base.Impl(snowyData, settings);
1718
}
1819
}

src/Snow/TestModule.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public static string GeneratedDate
1919
get { return Date; }
2020
}
2121

22+
//Title to pass to viewmodel, changes on iterations.
23+
public static IEnumerable<string> HeaderTitleChain { get; set; }
24+
2225
//Data changes on iterations
2326
public static Post Data { get; set; }
2427
public static string StaticFile { get; set; }
@@ -66,6 +69,7 @@ public TestModule()
6669
NextPage = PageNumber + 1,
6770
PreviousPage = PageNumber - 1,
6871
MonthYearList = MonthYear,
72+
HeaderTitleChain = HeaderTitleChain,
6973
GeneratedDate = GeneratedDate,
7074
Category = Category,
7175
Drafts = Drafts,
@@ -89,6 +93,7 @@ public TestModule()
8993
PostDate = Data.Date,
9094
Layout = Data.Layout,
9195
Title = Data.Title,
96+
HeaderTitleChain = new string[] { Data.Title, Settings.BlogTitle },
9297
GeneratedDate = GeneratedDate,
9398
Url = Data.Url,
9499
AllCategories = Categories,

src/Snow/ViewModels/BaseViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ namespace Snow.ViewModels
66

77
public abstract class BaseViewModel : DynamicDictionary
88
{
9+
/// <summary>
10+
/// Title of current view. Will generally be in order from most to least
11+
/// specific, with final value always being site name.
12+
/// </summary>
13+
public IEnumerable<string> HeaderTitleChain { get; set; }
914
/// <summary>
1015
/// All posts
1116
/// </summary>

0 commit comments

Comments
 (0)