summaryrefslogtreecommitdiffstats
path: root/hugolib/page_test.go
diff options
context:
space:
mode:
authorRoss Lawley <ross.lawley@gmail.com>2013-08-21 10:37:14 +0100
committerNoah Campbell <noahcampbell@gmail.com>2013-08-23 16:46:19 -0700
commit9930011ea2732d75ed62fae53d03cc13ffd25b15 (patch)
tree8309b18ce3bc345d7989c7e1b925a71f5f30c43b /hugolib/page_test.go
parent7b1f0960e3b7b31017dce5925e455bd43df86efb (diff)
Wordpress summaries
Allow full control of summaries which can be rendered as html rather than text. Using a `<!--more-->` html comment in your markdown / rst you can indiciate where the summary should end and have the summary converted to html. Signed-off-by: Noah Campbell <noahcampbell@gmail.com> Conflicts: hugolib/page_test.go
Diffstat (limited to 'hugolib/page_test.go')
-rw-r--r--hugolib/page_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/hugolib/page_test.go b/hugolib/page_test.go
index d55edac62..ec1695fb7 100644
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -91,6 +91,15 @@ layout: buzfoo
---
type and layout set`
+var SIMPLE_PAGE_WITH_SUMMARY_DELIMITER = `---
+title: Simple
+---
+Simple Page
+
+<!--more-->
+Some more text
+`
+
func checkError(t *testing.T, err error, expected string) {
if err == nil {
t.Fatalf("err is nil")
@@ -130,6 +139,12 @@ func checkPageContent(t *testing.T, page *Page, content string) {
}
}
+func checkPageSummary(t *testing.T, page *Page, summary string) {
+ if page.Summary != template.HTML(summary) {
+ t.Fatalf("Page summary is: `%s`. Expected `%s`", page.Summary, summary)
+ }
+}
+
func checkPageType(t *testing.T, page *Page, pageType string) {
if page.Type() != pageType {
t.Fatalf("Page type is: %s. Expected: %s", page.Type(), pageType)
@@ -149,6 +164,19 @@ func TestCreateNewPage(t *testing.T) {
}
checkPageTitle(t, p, "Simple")
checkPageContent(t, p, "<p>Simple Page</p>\n")
+ checkPageSummary(t, p, "Simple Page")
+ checkPageType(t, p, "page")
+ checkPageLayout(t, p, "page/single.html")
+}
+
+func TestPageWithDelimiter(t *testing.T) {
+ p, err := ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SUMMARY_DELIMITER), "simple")
+ if err != nil {
+ t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
+ }
+ checkPageTitle(t, p, "Simple")
+ checkPageContent(t, p, "<p>Simple Page</p>\n\n<!--more-->\n\n<p>Some more text</p>\n")
+ checkPageSummary(t, p, "<p>Simple Page</p>\n")
checkPageType(t, p, "page")
checkPageLayout(t, p, "page/single.html")
}