# Test the convert commands.

hugo convert -h
stdout 'Convert front matter to another format'
hugo convert toJSON -h
stdout 'to use JSON for the front matter'
hugo convert toTOML -h
stdout 'to use TOML for the front matter'
hugo convert toYAML -h
stdout 'to use YAML for the front matter'

cd project

# toJSON
hugo convert toJSON -o output/json
stdout 'processing 6 content files'
! stderr .
grep '^{' output/json/content/json.fr.md
grep '^{' output/json/content/toml.en.md
grep '^{' output/json/content/yaml.md
grep '^{' output/json/content/bundle/index.en.md
grep '^{' output/json/content/bundle/index.fr.md
grep '^{' output/json/internal/internal-mount.md
exists output/json/content/bundle/data.txt
exists output/json/content/bundle/nested/asset.dat
exists output/json/content/_content.gotmpl
! exists output/json/external

# toTOML
hugo convert toTOML -o output/toml
stdout 'processing 6 content files'
! stderr .
grep '^\+\+\+' output/toml/content/json.fr.md
grep '^\+\+\+' output/toml/content/toml.en.md
grep '^\+\+\+' output/toml/content/yaml.md
grep '^\+\+\+' output/toml/content/bundle/index.en.md
grep '^\+\+\+' output/toml/content/bundle/index.fr.md
grep '^\+\+\+' output/toml/internal/internal-mount.md
exists output/toml/content/bundle/data.txt
exists output/toml/content/bundle/nested/asset.dat
exists output/toml/content/_content.gotmpl
! exists output/toml/external

# toYAML
hugo convert toYAML -o output/yaml
stdout 'processing 6 content files'
! stderr .
grep '^---' output/yaml/content/json.fr.md
grep '^---' output/yaml/content/toml.en.md
grep '^---' output/yaml/content/yaml.md
grep '^---' output/yaml/content/bundle/index.en.md
grep '^---' output/yaml/content/bundle/index.fr.md
grep '^---' output/yaml/internal/internal-mount.md
exists output/yaml/content/bundle/data.txt
exists output/yaml/content/bundle/nested/asset.dat
exists output/yaml/content/_content.gotmpl
! exists output/yaml/external


-- project/hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = true
[languages]
  [languages.en]
    weight = 1
  [languages.fr]
    weight = 2
[[module.mounts]]
  source = 'content'
  target = 'content'
[[module.mounts]]
  source = 'internal'
  target = 'content'
  [module.mounts.sites.matrix]
    languages = ['en']
[[module.mounts]]
  source = '../external'
  target = 'content'
  [module.mounts.sites.matrix]
    languages = ['en']
-- project/layouts/page.html --
{{ .Title }}
-- project/content/_content.gotmpl --
{{ $content := dict "mediaType" "text/markdown" "value" "Content created by content adapter" }}
{{ .AddPage (dict "path" "created-by-content-adapter" "title" "Created by content adapter" "content" $content) }}
{{ .EnableAllDimensions }}
-- project/content/json.fr.md --
{
  "title": "JSON"
}
JSON content
-- project/content/toml.en.md --
+++
title = 'TOML'
+++
TOML content
-- project/content/yaml.md --
---
title: YAML
sites:
  matrix:
    languages: ['**']
---
YAML content
-- project/content/bundle/index.en.md --
---
title: Bundle EN
---
Bundle EN content
-- project/content/bundle/index.fr.md --
---
title: Bundle FR
---
Bundle FR content
-- project/content/bundle/data.txt --
bundle resource
-- project/content/bundle/nested/asset.dat --
nested resource
-- project/internal/internal-mount.md --
---
title: Internal Mount
---
Internal mount content
-- external/external-mount.md --
---
title: External Mount
---
External mount content
