From 8816a85cb80b0843a0629dbac0b5a9b6e8f86c1f Mon Sep 17 00:00:00 2001 From: onadrog Date: Mon, 30 Jan 2023 15:53:43 +0100 Subject: [PATCH] Fix: change path to `src/content` to match astro v2 conent collections --- README.md | 2 +- cmd/root.go | 2 +- helpers/files.go | 2 +- helpers/files_test.go | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 37873be..da5b483 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Create page with auto generated frontmatter. ### Usage Make sure you run the command inside the root directory of your site projet. -It will create a file in the src/pages path. +It will create a file in the src/content path. ```bash # $ astroadd [path] diff --git a/cmd/root.go b/cmd/root.go index c75f4e1..5a3ae5e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -32,7 +32,7 @@ var rootCmd = &cobra.Command{ Use: "astroadd [path]", Short: "Create a new file", Long: `Create a new file. - Goes to src/pages + Goes to src/content Based on the given path. Automatically add the frontmatter (title, date, draft). Ensure you run this within the root directory of your site.`, diff --git a/helpers/files.go b/helpers/files.go index 50f44ce..23ef9b9 100644 --- a/helpers/files.go +++ b/helpers/files.go @@ -11,7 +11,7 @@ import ( // Get the os platform separator var sep = os.PathSeparator -var basePath = fmt.Sprintf("src%cpages%c", sep, sep) +var basePath = fmt.Sprintf("src%ccontent%c", sep, sep) // Return the title without dashes and the directory path for the given path. // Or an error diff --git a/helpers/files_test.go b/helpers/files_test.go index d7bc955..6bc1749 100644 --- a/helpers/files_test.go +++ b/helpers/files_test.go @@ -8,12 +8,12 @@ func TestSanitizer(t *testing.T) { arg string expected string }{ - {"pages/posts.md", "Posts"}, - {"pages/posts-1.md", "Posts 1"}, - {"pages/posts_2.md", "Posts 2"}, - {"pages/posts@3.md", "Posts 3"}, - {"pages/posts_blog@4.md", "Posts blog 4"}, - {"pages/posts_blog@/4.md", "4"}, + {"content/posts.md", "Posts"}, + {"content/posts-1.md", "Posts 1"}, + {"content/posts_2.md", "Posts 2"}, + {"content/posts@3.md", "Posts 3"}, + {"content/posts_blog@4.md", "Posts blog 4"}, + {"content/posts_blog@/4.md", "4"}, } for _, tc := range cases {