about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--README.md8
-rw-r--r--components/documents.go2
-rw-r--r--examples/simple/simple.go2
-rw-r--r--html/elements.go6
-rw-r--r--html/elements_test.go6
5 files changed, 12 insertions, 12 deletions
diff --git a/README.md b/README.md
index cd8a887..5a8a954 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 }
 
 func Page(title, currentPath string) g.Node {
-	return Document(
+	return Doctype(
 		HTML(
 			Lang("en"),
 			Head(
@@ -94,7 +94,7 @@ import (
 	"net/http"
 
 	g "github.com/maragudk/gomponents"
-	. "github.com/maragudk/gomponents/components"
+	c "github.com/maragudk/gomponents/components"
 	. "github.com/maragudk/gomponents/html"
 )
 
@@ -107,7 +107,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 }
 
 func Page(title, currentPath string) g.Node {
-	return HTML5(HTML5Props{
+	return c.HTML5(c.HTML5Props{
 		Title:    title,
 		Language: "en",
 		Head: []g.Node{
@@ -129,7 +129,7 @@ func Navbar(currentPath string) g.Node {
 }
 
 func NavbarLink(href, name, currentPath string) g.Node {
-	return A(href, Classes{"is-active": currentPath == href}, g.Text(name))
+	return A(href, c.Classes{"is-active": currentPath == href}, g.Text(name))
 }
 ```
 
diff --git a/components/documents.go b/components/documents.go
index e2d3a22..17b421a 100644
--- a/components/documents.go
+++ b/components/documents.go
@@ -25,7 +25,7 @@ func HTML5(p HTML5Props) g.NodeFunc {
 	if p.Description != "" {
 		description = Meta(Name("description"), Content(p.Description))
 	}
-	return Document(
+	return Doctype(
 		HTML(lang,
 			Head(
 				Meta(Charset("utf-8")),
diff --git a/examples/simple/simple.go b/examples/simple/simple.go
index 535fa6e..529cf18 100644
--- a/examples/simple/simple.go
+++ b/examples/simple/simple.go
@@ -27,7 +27,7 @@ type props struct {
 }
 
 func page(p props) g.Node {
-	return h.Document(
+	return h.Doctype(
 		h.HTML(h.Lang("en"),
 			h.Head(
 				h.TitleEl(p.title),
diff --git a/html/elements.go b/html/elements.go
index 8045561..4f1a0ec 100644
--- a/html/elements.go
+++ b/html/elements.go
@@ -14,13 +14,13 @@ func A(href string, children ...g.Node) g.NodeFunc {
 	return g.El("a", g.Attr("href", href), g.Group(children))
 }
 
-// Document returns an special kind of Node that prefixes its child with the string "<!doctype html>".
-func Document(child g.Node) g.NodeFunc {
+// Doctype returns a special kind of Node that prefixes its sibling with the string "<!doctype html>".
+func Doctype(sibling g.Node) g.NodeFunc {
 	return func(w io.Writer) error {
 		if _, err := w.Write([]byte("<!doctype html>")); err != nil {
 			return err
 		}
-		return child.Render(w)
+		return sibling.Render(w)
 	}
 }
 
diff --git a/html/elements_test.go b/html/elements_test.go
index e550bfe..f89919d 100644
--- a/html/elements_test.go
+++ b/html/elements_test.go
@@ -16,13 +16,13 @@ func (w *erroringWriter) Write(p []byte) (n int, err error) {
 	return 0, errors.New("don't want to write")
 }
 
-func TestDocument(t *testing.T) {
+func TestDoctype(t *testing.T) {
 	t.Run("returns doctype and children", func(t *testing.T) {
-		assert.Equal(t, `<!doctype html><html></html>`, Document(g.El("html")))
+		assert.Equal(t, `<!doctype html><html></html>`, Doctype(g.El("html")))
 	})
 
 	t.Run("errors on write error in Render", func(t *testing.T) {
-		err := Document(g.El("html")).Render(&erroringWriter{})
+		err := Doctype(g.El("html")).Render(&erroringWriter{})
 		assert.Error(t, err)
 	})
 }