diff --git a/README.md b/README.md index fee68d4c42252d32e2d3de3f56ce37b5813e31f3..44b914bb0529656ab1df17aad5a951b2fa1b94fb 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Furthermore, it will parse the templates for images, anchors, and text. ##### Generate -This will generate HTML files from the prepared templates. +This will generate HTML files from the prepared templates and data YAML. ```bash bob html generate --input ./output/ --output ./output/ diff --git a/application/source/html/generate.go b/application/source/html/generate.go index a8a5c6541401950ae13eae0b251f35de858e1968..0739aa7bbb7ce20a676401b04dd5fca677130435 100644 --- a/application/source/html/generate.go +++ b/application/source/html/generate.go @@ -30,7 +30,12 @@ func GenerateFiles(dataPath, out string) error { return err } - outFile := path.Join(out, name) + outFile := path.Join(out, page.Export) + + dir := path.Dir(outFile) + if err := os.MkdirAll(dir, 0755); err != nil { + return err + } err = os.WriteFile(outFile, []byte(html), 0644) if err != nil { diff --git a/application/source/template/prepare.go b/application/source/template/prepare.go index a1424ad7bd7e5b75e247432d4be38828a997f253..1afea22144e3e784f6591752f5eb531134cf60c8 100644 --- a/application/source/template/prepare.go +++ b/application/source/template/prepare.go @@ -307,7 +307,9 @@ func PrepareHtmlFile(from, to string, storage types.PageDataStorage) error { prepareAnchors(node, pd) prepareTextNodes(node, pd) + pd.Export = path.Join(pd.Lang, path.Base(from)) to = path.Join(to, path.Base(from)) + return util.SaveHtml(to, node) } diff --git a/application/source/types/page-data.go b/application/source/types/page-data.go index 0432fea76c4fcb3c410960ce8f1fb71d8d73d4da..51137463dd468bff94325f3bf35ee95d9db73ba3 100644 --- a/application/source/types/page-data.go +++ b/application/source/types/page-data.go @@ -26,6 +26,7 @@ type PageData struct { Images []Image `yaml:"images"` Anchors []Anchor `yaml:"anchors"` Text []Text `yaml:"text"` + Export string `yaml:"export"` } func NewPageData() *PageData {