Skip to content

Commit e5222f2

Browse files
ngdangtu-vnpre-commit-ci[bot]hyperupcall
authored
add new Hugo theme JSON schema (#3174)
* add new Hugo theme JSON schema - add a JSON schema for `theme.toml` - add a catalog - add test cases: 2-positive, 3-negative - add an unknown keyword (Taplo extension) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove fileMatch of Hugo Theme Co-authored-by: Edwin Kofler <[email protected]> * Update catalog.json --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Edwin Kofler <[email protected]>
1 parent 08861af commit e5222f2

File tree

8 files changed

+238
-0
lines changed

8 files changed

+238
-0
lines changed

src/api/json/catalog.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5109,6 +5109,12 @@
51095109
"fileMatch": [],
51105110
"url": "https://json.schemastore.org/unist.json"
51115111
},
5112+
{
5113+
"name": "Hugo Theme",
5114+
"description": "Hugo theme config file",
5115+
"fileMatch": [],
5116+
"url": "https://json.schemastore.org/hugo-theme.json"
5117+
},
51125118
{
51135119
"name": "Hugo",
51145120
"description": "Hugo static site generator config file",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
license = "MIT"
2+
licenselink = "https://example.com/mit"
3+
description = "Theme description"
4+
homepage = "https://example.com/theme"
5+
tags = ["blog", "company"]
6+
features = ["some", "awesome", "features"]
7+
8+
[author]
9+
name = "awesomeness"
10+
homepage = "https://example.com/awesomeness"
11+
12+
# If porting an existing theme
13+
[original]
14+
author = "Name of original author"
15+
homepage = "https://example.com/origin-author"
16+
repo = "https://example.com/origin-theme"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name = 100
2+
license = false
3+
licenselink = "Link to theme's license"
4+
description = ["Theme description"]
5+
homepage = "Website of your theme"
6+
tags = ["blog", 29082023]
7+
features = ["some", 9999, "features"]
8+
min_version = "0.59"
9+
10+
authors = [
11+
"awesomeness<https://example.com/awesomeness>",
12+
{ name = "awesomeless", homepage = "Website of author" },
13+
]
14+
15+
[author]
16+
name = 2023
17+
homepage = "Your website"
18+
19+
# If porting an existing theme
20+
[original]
21+
author = 2022
22+
homepage = "His/Her website"
23+
repo = "Link to source code of original theme"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name = "Theme Name"
2+
license = "MIT"
3+
licenselink = "https://example.com/mit"
4+
description = "Theme description"
5+
homepage = "https://example.com/theme"
6+
tags = ["blog", "company"]
7+
features = ["some", "awesome", "features"]
8+
min_version = "0.59.1"
9+
10+
author = [
11+
{ name = "awesomeness", homepage = "https://example.com/awesomeness" },
12+
{ name = "awesomeless", homepage = "https://example.com/awesomeless" },
13+
]
14+
15+
[authors]
16+
name = "awesomeness"
17+
homepage = "https://example.com/awesomeness"

src/schema-validation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,11 @@
585585
"unknownKeywords": ["examples"]
586586
}
587587
},
588+
{
589+
"hugo-theme.json": {
590+
"unknownKeywords": ["x-taplo-info"]
591+
}
592+
},
588593
{
589594
"huskyrc.json": {
590595
"unknownKeywords": [

src/schemas/json/hugo-theme.json

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"$comment": "https://github.com/gohugoio/hugoThemes#themetoml",
3+
"$id": "https://json.schemastore.org/hugo-theme.json",
4+
"$schema": "http://json-schema.org/draft-07/schema#",
5+
"additionalProperties": false,
6+
"definitions": {
7+
"author-data": {
8+
"additionalProperties": false,
9+
"default": {
10+
"name": ""
11+
},
12+
"properties": {
13+
"homepage": {
14+
"format": "uri",
15+
"title": "author website",
16+
"type": "string"
17+
},
18+
"name": {
19+
"title": "author name",
20+
"type": "string"
21+
}
22+
},
23+
"required": ["name"],
24+
"type": "object"
25+
}
26+
},
27+
"description": "This file contains metadata about the theme and its creator or creators. Hugo only recognizes theme.toml file, any other files are not accepted. Learn more at https://github.com/gohugoio/hugoThemes#themetoml",
28+
"properties": {
29+
"$schema": {
30+
"$comment": "Because the theme config file (`theme.toml`) only works with TOML format, so we don't need to support this property.",
31+
"description": "Hugo will not recognize the theme config file if it is JSON or YAML format. Please use theme.toml file.",
32+
"type": "null"
33+
},
34+
"authors": {
35+
"description": "For themes that have multiple authors",
36+
"items": {
37+
"$ref": "#/definitions/author-data"
38+
},
39+
"minItems": 2,
40+
"type": "array",
41+
"title": "theme authors"
42+
},
43+
"author": {
44+
"description": "For themes that have single author",
45+
"$ref": "#/definitions/author-data",
46+
"title": "theme author"
47+
},
48+
"description": {
49+
"description": "This info is used by Hugo theme store: https://themes.gohugo.io",
50+
"title": "theme description",
51+
"type": "string"
52+
},
53+
"features": {
54+
"items": {
55+
"type": "string"
56+
},
57+
"title": "theme features",
58+
"type": "array"
59+
},
60+
"homepage": {
61+
"default": "https://",
62+
"description": "This info is used by Hugo theme store: https://themes.gohugo.io",
63+
"format": "uri",
64+
"title": "website of the theme",
65+
"type": "string"
66+
},
67+
"license": {
68+
"description": "Reference: https://choosealicense.com",
69+
"title": "Theme License",
70+
"type": "string"
71+
},
72+
"licenselink": {
73+
"default": "https://",
74+
"format": "uri",
75+
"title": "Link to theme's license",
76+
"type": "string"
77+
},
78+
"min_version": {
79+
"description": "Since the version **0.54.0**, Hugo started using full semver. Therefore, it is required to be `X.Y.Z` format. For instance: `0.54` is incorrect, `0.54.0` is correct.",
80+
"minLength": 5,
81+
"pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
82+
"title": "Minimum Hugo Version",
83+
"type": "string"
84+
},
85+
"name": {
86+
"description": "This info is used by Hugo theme store: https://themes.gohugo.io",
87+
"title": "Theme Name",
88+
"type": "string"
89+
},
90+
"original": {
91+
"additionalProperties": false,
92+
"default": {
93+
"author": "",
94+
"repo": "https://"
95+
},
96+
"description": "For themes that port an existing theme",
97+
"properties": {
98+
"author": {
99+
"title": "name of original author",
100+
"type": "string"
101+
},
102+
"homepage": {
103+
"format": "uri",
104+
"title": "his/her website",
105+
"type": "string"
106+
},
107+
"repo": {
108+
"description": "Link to source code of original theme",
109+
"format": "uri",
110+
"title": "author website",
111+
"type": "string"
112+
}
113+
},
114+
"required": ["author", "repo"],
115+
"title": "original theme",
116+
"type": "object"
117+
},
118+
"tags": {
119+
"description": "This info is used by Hugo theme store: https://themes.gohugo.io",
120+
"items": {
121+
"type": "string"
122+
},
123+
"title": "theme tags",
124+
"type": "array"
125+
}
126+
},
127+
"required": ["name", "min_version"],
128+
"title": "Hugo theme config file schema",
129+
"type": "object",
130+
"x-taplo-info": {
131+
"authors": ["ngdangtu (https://gitlab.com/ngdangtu)"],
132+
"patterns": ["^(theme.toml)$"]
133+
}
134+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name = "Theme Name"
2+
license = "MIT"
3+
licenselink = "https://example.com/mit"
4+
description = "Theme description"
5+
homepage = "https://example.com/theme"
6+
tags = ["blog", "company"]
7+
features = ["some", "awesome", "features"]
8+
min_version = "0.59.1"
9+
10+
authors = [
11+
{ name = "awesomeness", homepage = "https://example.com/awesomeness" },
12+
{ name = "awesomeless", homepage = "https://example.com/awesomeless" },
13+
]
14+
15+
# If porting an existing theme
16+
[original]
17+
author = "Name of original author"
18+
homepage = "https://example.com/origin-author"
19+
repo = "https://example.com/origin-theme"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name = "Theme Name"
2+
license = "MIT"
3+
licenselink = "https://example.com/mit"
4+
description = "Theme description"
5+
homepage = "https://example.com/theme"
6+
tags = ["blog", "company"]
7+
features = ["some", "awesome", "features"]
8+
min_version = "0.59.1"
9+
10+
[author]
11+
name = "awesomeness"
12+
homepage = "https://example.com/awesomeness"
13+
14+
# If porting an existing theme
15+
[original]
16+
author = "Name of original author"
17+
homepage = "https://example.com/origin-author"
18+
repo = "https://example.com/origin-theme"

0 commit comments

Comments
 (0)