| 1 |
# Test the convert commands. |
| 2 |
|
| 3 |
hugo convert -h |
| 4 |
stdout 'Convert front matter to another format' |
| 5 |
hugo convert toJSON -h |
| 6 |
stdout 'to use JSON for the front matter' |
| 7 |
hugo convert toTOML -h |
| 8 |
stdout 'to use TOML for the front matter' |
| 9 |
hugo convert toYAML -h |
| 10 |
stdout 'to use YAML for the front matter' |
| 11 |
|
| 12 |
cd project |
| 13 |
|
| 14 |
# toJSON |
| 15 |
hugo convert toJSON -o output/json |
| 16 |
stdout 'processing 6 content files' |
| 17 |
! stderr . |
| 18 |
grep '^{' output/json/content/json.fr.md |
| 19 |
grep '^{' output/json/content/toml.en.md |
| 20 |
grep '^{' output/json/content/yaml.md |
| 21 |
grep '^{' output/json/content/bundle/index.en.md |
| 22 |
grep '^{' output/json/content/bundle/index.fr.md |
| 23 |
grep '^{' output/json/internal/internal-mount.md |
| 24 |
exists output/json/content/bundle/data.txt |
| 25 |
exists output/json/content/bundle/nested/asset.dat |
| 26 |
exists output/json/content/_content.gotmpl |
| 27 |
! exists output/json/external |
| 28 |
|
| 29 |
# toTOML |
| 30 |
hugo convert toTOML -o output/toml |
| 31 |
stdout 'processing 6 content files' |
| 32 |
! stderr . |
| 33 |
grep '^\+\+\+' output/toml/content/json.fr.md |
| 34 |
grep '^\+\+\+' output/toml/content/toml.en.md |
| 35 |
grep '^\+\+\+' output/toml/content/yaml.md |
| 36 |
grep '^\+\+\+' output/toml/content/bundle/index.en.md |
| 37 |
grep '^\+\+\+' output/toml/content/bundle/index.fr.md |
| 38 |
grep '^\+\+\+' output/toml/internal/internal-mount.md |
| 39 |
exists output/toml/content/bundle/data.txt |
| 40 |
exists output/toml/content/bundle/nested/asset.dat |
| 41 |
exists output/toml/content/_content.gotmpl |
| 42 |
! exists output/toml/external |
| 43 |
|
| 44 |
# toYAML |
| 45 |
hugo convert toYAML -o output/yaml |
| 46 |
stdout 'processing 6 content files' |
| 47 |
! stderr . |
| 48 |
grep '^---' output/yaml/content/json.fr.md |
| 49 |
grep '^---' output/yaml/content/toml.en.md |
| 50 |
grep '^---' output/yaml/content/yaml.md |
| 51 |
grep '^---' output/yaml/content/bundle/index.en.md |
| 52 |
grep '^---' output/yaml/content/bundle/index.fr.md |
| 53 |
grep '^---' output/yaml/internal/internal-mount.md |
| 54 |
exists output/yaml/content/bundle/data.txt |
| 55 |
exists output/yaml/content/bundle/nested/asset.dat |
| 56 |
exists output/yaml/content/_content.gotmpl |
| 57 |
! exists output/yaml/external |
| 58 |
|
| 59 |
|
| 60 |
-- project/hugo.toml -- |
| 61 |
disableKinds = ['home','rss','section','sitemap','taxonomy','term'] |
| 62 |
defaultContentLanguage = 'en' |
| 63 |
defaultContentLanguageInSubdir = true |
| 64 |
[languages] |
| 65 |
[languages.en] |
| 66 |
weight = 1 |
| 67 |
[languages.fr] |
| 68 |
weight = 2 |
| 69 |
[[module.mounts]] |
| 70 |
source = 'content' |
| 71 |
target = 'content' |
| 72 |
[[module.mounts]] |
| 73 |
source = 'internal' |
| 74 |
target = 'content' |
| 75 |
[module.mounts.sites.matrix] |
| 76 |
languages = ['en'] |
| 77 |
[[module.mounts]] |
| 78 |
source = '../external' |
| 79 |
target = 'content' |
| 80 |
[module.mounts.sites.matrix] |
| 81 |
languages = ['en'] |
| 82 |
-- project/layouts/page.html -- |
| 83 |
{{ .Title }} |
| 84 |
-- project/content/_content.gotmpl -- |
| 85 |
{{ $content := dict "mediaType" "text/markdown" "value" "Content created by content adapter" }} |
| 86 |
{{ .AddPage (dict "path" "created-by-content-adapter" "title" "Created by content adapter" "content" $content) }} |
| 87 |
{{ .EnableAllDimensions }} |
| 88 |
-- project/content/json.fr.md -- |
| 89 |
{ |
| 90 |
"title": "JSON" |
| 91 |
} |
| 92 |
JSON content |
| 93 |
-- project/content/toml.en.md -- |
| 94 |
+++ |
| 95 |
title = 'TOML' |
| 96 |
+++ |
| 97 |
TOML content |
| 98 |
-- project/content/yaml.md -- |
| 99 |
--- |
| 100 |
title: YAML |
| 101 |
sites: |
| 102 |
matrix: |
| 103 |
languages: ['**'] |
| 104 |
--- |
| 105 |
YAML content |
| 106 |
-- project/content/bundle/index.en.md -- |
| 107 |
--- |
| 108 |
title: Bundle EN |
| 109 |
--- |
| 110 |
Bundle EN content |
| 111 |
-- project/content/bundle/index.fr.md -- |
| 112 |
--- |
| 113 |
title: Bundle FR |
| 114 |
--- |
| 115 |
Bundle FR content |
| 116 |
-- project/content/bundle/data.txt -- |
| 117 |
bundle resource |
| 118 |
-- project/content/bundle/nested/asset.dat -- |
| 119 |
nested resource |
| 120 |
-- project/internal/internal-mount.md -- |
| 121 |
--- |
| 122 |
title: Internal Mount |
| 123 |
--- |
| 124 |
Internal mount content |
| 125 |
-- external/external-mount.md -- |
| 126 |
--- |
| 127 |
title: External Mount |
| 128 |
--- |
| 129 |
External mount content |