aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/tj
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2017-05-20 15:43:42 -0700
committerChristine Dodrill <me@christine.website>2017-05-20 15:43:42 -0700
commit9cbb20aea2d6b1979a47af9956dbcc8dbe2a2e08 (patch)
tree9d3b8a93d647484a490b1db5907d7b87b85081a9 /vendor/github.com/tj
parentd9e24cd8978458ee72c98ad0c13316907517e499 (diff)
downloadxesite-9cbb20aea2d6b1979a47af9956dbcc8dbe2a2e08.tar.xz
xesite-9cbb20aea2d6b1979a47af9956dbcc8dbe2a2e08.zip
add vendor dependencies
Diffstat (limited to 'vendor/github.com/tj')
-rw-r--r--vendor/github.com/tj/front/front.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/github.com/tj/front/front.go b/vendor/github.com/tj/front/front.go
new file mode 100644
index 0000000..e0382b5
--- /dev/null
+++ b/vendor/github.com/tj/front/front.go
@@ -0,0 +1,24 @@
+// Package front provides YAML frontmatter unmarshalling.
+package front
+
+import (
+ "bytes"
+
+ "gopkg.in/yaml.v1"
+)
+
+// Delimiter.
+var delim = []byte("---")
+
+// Unmarshal parses YAML frontmatter and returns the content. When no
+// frontmatter delimiters are present the original content is returned.
+func Unmarshal(b []byte, v interface{}) (content []byte, err error) {
+ if !bytes.HasPrefix(b, delim) {
+ return b, nil
+ }
+
+ parts := bytes.SplitN(b, delim, 3)
+ content = parts[2]
+ err = yaml.Unmarshal(parts[1], v)
+ return
+}