aboutsummaryrefslogtreecommitdiff
path: root/internal/front
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-12-09 10:48:40 -0500
committerGitHub <noreply@github.com>2019-12-09 10:48:40 -0500
commiteb26857c1d5973bedc91c3fc1acaf4434809bbd5 (patch)
tree926be802355da24afb3cf6ed8496a2b2d656e1a1 /internal/front
parent583cf248b3fe7ebb06d89ba32fddeee70fb14c2c (diff)
downloadxesite-eb26857c1d5973bedc91c3fc1acaf4434809bbd5.tar.xz
xesite-eb26857c1d5973bedc91c3fc1acaf4434809bbd5.zip
Within package layout (#102)
* blog: go package layout * eat my own dogfood * internal: test date * blog/go-package-layout: streamline * oops
Diffstat (limited to 'internal/front')
-rw-r--r--internal/front/LICENSE19
-rw-r--r--internal/front/front.go24
-rw-r--r--internal/front/front_test.go42
3 files changed, 0 insertions, 85 deletions
diff --git a/internal/front/LICENSE b/internal/front/LICENSE
deleted file mode 100644
index e8152bb..0000000
--- a/internal/front/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2017 TJ Holowaychuk <tj@vision-media.ca>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE. \ No newline at end of file
diff --git a/internal/front/front.go b/internal/front/front.go
deleted file mode 100644
index b2c7f0e..0000000
--- a/internal/front/front.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Package front provides YAML frontmatter unmarshalling.
-package front
-
-import (
- "bytes"
-
- "gopkg.in/yaml.v2"
-)
-
-// 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
-}
diff --git a/internal/front/front_test.go b/internal/front/front_test.go
deleted file mode 100644
index 42094f5..0000000
--- a/internal/front/front_test.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package front_test
-
-import (
- "fmt"
- "log"
-
- "christine.website/internal/front"
-)
-
-var markdown = []byte(`---
-title: Ferrets
-authors:
- - Tobi
- - Loki
- - Jane
----
-Some content here, so
-interesting, you just
-want to keep reading.`)
-
-type article struct {
- Title string
- Authors []string
-}
-
-func Example() {
- var a article
-
- content, err := front.Unmarshal(markdown, &a)
- if err != nil {
- log.Fatalf("error unmarshalling: %s", err)
- }
-
- fmt.Printf("%#v\n", a)
- fmt.Printf("%s\n", string(content))
- // Output:
- // front_test.article{Title:"Ferrets", Authors:[]string{"Tobi", "Loki", "Jane"}}
- //
- // Some content here, so
- // interesting, you just
- // want to keep reading.
-}