Skip to content

Commit db4a5e9

Browse files
author
Maciej Lechowski
committed
Ability to copy any files/dir based on the configuration
1 parent a072e6d commit db4a5e9

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Static website generator in Golang
2525
{{@<page-slug>}}
2626
2727
{{#include <template.html>}}
28+
```
2829

30+
## Source files variables
2931

3032
```
33+
{{#include file.html}}
34+
```

config.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ import (
99
)
1010

1111
type config struct {
12-
Url string
13-
Rss rssConfig
14-
Posts postsConfig
12+
Url string
13+
Rss rssConfig
14+
Posts postsConfig
15+
Static staticConfig
16+
}
17+
18+
type staticConfig struct {
19+
Copy []map[string]string
1520
}
1621

1722
type rssConfig struct {

project.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ func buildProject(project string, conf *config) {
426426
generateArticleHtml(project, "default", "posts.html", postArticle, articles, conf, templates)
427427
}
428428

429-
copyStaticDirectories(project)
429+
copyStaticDirectories(project, conf)
430430
}
431431

432-
func copyStaticDirectories(project string) {
432+
func copyStaticDirectories(project string, conf *config) {
433433
staticFrom := filepath.Join(project, "themes", "default", "static")
434434
staticTo := filepath.Join(project, "build")
435435

@@ -438,4 +438,10 @@ func copyStaticDirectories(project string) {
438438

439439
copyDirectory(staticFrom, staticTo)
440440
copyDirectory(dataFrom, dataTo)
441+
442+
for _, dirData := range conf.Static.Copy {
443+
from := filepath.Join(project, "source", dirData["from"])
444+
to := filepath.Join(project, "build", dirData["to"])
445+
copyDirectory(from, to)
446+
}
441447
}

0 commit comments

Comments
 (0)