Skip to content

Commit

Permalink
assets dir is part of staticFiles slice
Browse files Browse the repository at this point in the history
  • Loading branch information
kazhuravlev authored and avelino committed Apr 3, 2023
1 parent 13af833 commit f0dbbd1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ type Object struct {

// Source
const readmePath = "README.md"
const assetsDir = "tmpl/assets"

// NOTE: this files should be copied as is to outDir directory
var staticFiles = []string{
"tmpl/assets",
"tmpl/_redirects",
"tmpl/robots.txt",
}

// Templates
const tplPath = "tmpl/tmpl.html"
Expand All @@ -40,7 +46,6 @@ const tmplSitemap = "tmpl/sitemap-tmpl.xml"
// NOTE: trailing slash is required
const outDir = "out/"

var outAssetsDir = filepath.Join(outDir, "assets")
var outIndexFile = filepath.Join(outDir, "index.html")
var outSitemapFile = filepath.Join(outDir, "sitemap.xml")

Expand Down Expand Up @@ -95,8 +100,12 @@ func main() {

makeSitemap(objs)

if err := cp.Copy(assetsDir, outAssetsDir); err != nil {
panic(err)
for _, srcFilename := range staticFiles {
dstFilename := filepath.Join(outDir, filepath.Base(srcFilename))
fmt.Printf("Copy static file: %s -> %s\n", srcFilename, dstFilename)
if err := cp.Copy(srcFilename, dstFilename); err != nil {
panic(err)
}
}
}

Expand Down

0 comments on commit f0dbbd1

Please sign in to comment.