Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Pretzel.Logic/Templating/Context/PageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public PageContext(PageContext context)
{
Title = context.Title;
OutputPath = context.OutputPath;
Bag = context.Bag;
Bag = new Dictionary<string, object>(context.Bag);
Content = context.Content;
Site = context.Site;
Page = context.Page;
Expand Down
4 changes: 3 additions & 1 deletion src/Pretzel.Logic/Templating/JekyllEngineBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ private void ProcessFile(string outputDirectory, Page page, Page previous, Page
prevLink = link;

var path = Path.Combine(outputDirectory, link.ToRelativeFile());
pageContexts.Add(new PageContext(pageContext) { Paginator = newPaginator, OutputPath = path });
var context = new PageContext(pageContext) { Paginator = newPaginator, OutputPath = path };
context.Bag["url"] = link;
pageContexts.Add(context);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Pretzel.Tests/Templating/Jekyll/LiquidEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ public void No_Pages_Should_Be_Generated()

public class When_Paginate_With_Default_Pagelink : BakingEnvironment<LiquidEngine>
{
private const string TemplateContents = "<html><head><title>{{ page.title }}</title></head><body>{{ content }}</body></html>";
private const string TemplateContents = "<html><head><title>{{ page.title }}</title><link rel=\"canonical\" href=\"{{ page.url }}\" /></head><body>{{ content }}</body></html>";
private const string PostContents = "---\r\n layout: default \r\n title: 'Post'\r\n---\r\n\r\n## Hello World!";
private const string IndexContents = "---\r\n layout: default \r\n paginate: 1 \r\n title: 'A different title'\r\n---\r\n\r\n<h2>Hello World!</h2><p>{{ paginator.previous_page }} / {{ paginator.page }} / {{ paginator.next_page }}</p>";
private const string ExpectedfileContents = "<html><head><title>A different title</title></head><body><h2>Hello World!</h2><p>{0} / {1} / {2}</p></body></html>";
private const string ExpectedfileContents = "<html><head><title>A different title</title><link rel=\"canonical\" href=\"{3}\" /></head><body><h2>Hello World!</h2><p>{0} / {1} / {2}</p></body></html>";

public override LiquidEngine Given()
{
Expand Down Expand Up @@ -269,7 +269,7 @@ public void Four_Pages_Should_Be_Generated()
for (var i = 2; i <= 5; i++)
{
var fileName = String.Format(@"C:\website\_site\page\{0}\index.html", i);
var expectedContents = string.Format(ExpectedfileContents, i - 1, i, i + 1);
var expectedContents = string.Format(ExpectedfileContents, i - 1, i, i + 1, "/page/" + i + "/index.html");
Assert.Equal(expectedContents, FileSystem.File.ReadAllText(fileName).RemoveWhiteSpace());
}
}
Expand All @@ -283,7 +283,7 @@ public void Page1_Is_Not_Generated()
[Fact]
public void But_Index_Is_Generated()
{
var expectedContents = string.Format(ExpectedfileContents, 0, 1, 2);
var expectedContents = string.Format(ExpectedfileContents, 0, 1, 2, "/index.html");
Assert.Equal(expectedContents, FileSystem.File.ReadAllText(@"C:\website\_site\index.html").RemoveWhiteSpace());
}
}
Expand Down