Skip to content

Commit

Permalink
Fix destPath and add placeholder blog posts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed Apr 23, 2020
1 parent 9642e68 commit 0e234f6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/build/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,19 @@ func DataSource(buildPath string) (string, string) {
}
fileContentStr := string(fileContentByte)

// Remove file extension from path.
path = strings.TrimSuffix(path, filepath.Ext(path))
// Remove the "content" folder from path.
path = strings.TrimPrefix(path, "content")

destPath := buildPath + "/" + path + ".html"

// Check for index.json outside of type declaration.
if contentType == "index.json" {
contentType = "index"
path = "/"
}

// Remove file extension from path.
path = strings.TrimSuffix(path, filepath.Ext(path))

// TODO: Need to check for path overrides from siteConfig reader.
nodeDetailsStr := "{\n" +
"\"path\": \"" + path + "\",\n" +
Expand All @@ -72,7 +76,6 @@ func DataSource(buildPath string) (string, string) {

// Create path for source .svelte template.
componentPath := "layout/content/" + contentType + ".svelte"
destPath := buildPath + "/" + path + ".html"

//encodedNodeDetails := html.EscapeString(nodeDetailsStr)
encodedNodeDetails := nodeDetailsStr
Expand Down
4 changes: 4 additions & 0 deletions defaults/content/blog/post-3_has_a_long_filename.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Post 3",
"description": "Third of the blog posts."
}
4 changes: 4 additions & 0 deletions defaults/content/blog/post1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Post 1",
"description": "First blog post."
}
4 changes: 4 additions & 0 deletions defaults/content/blog/post2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Post 2",
"description": "Second blog post."
}
12 changes: 12 additions & 0 deletions generated/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ package generated
var Defaults = map[string][]byte{
"/.gitignore": []byte(`public
node_modules`),
"/content/blog/post-3_has_a_long_filename.json": []byte(`{
"title": "Post 3",
"description": "Third of the blog posts."
}`),
"/content/blog/post1.json": []byte(`{
"title": "Post 1",
"description": "First blog post."
}`),
"/content/blog/post2.json": []byte(`{
"title": "Post 2",
"description": "Second blog post."
}`),
"/content/index.json": []byte(`{
"title": "My Site Homepage",
"intro": {
Expand Down

0 comments on commit 0e234f6

Please sign in to comment.