Skip to content

Commit 1cc4aca

Browse files
authored
Merge pull request #6361 from sisp/fix/analytics-schema
Fixed `extra:analytics` schema for custom providers
2 parents 5a42f9f + f528598 commit 1cc4aca

File tree

1 file changed

+114
-85
lines changed

1 file changed

+114
-85
lines changed

docs/schema/extra.json

Lines changed: 114 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -13,99 +13,75 @@
1313
"title": "Analytics provider",
1414
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
1515
"type": "object",
16-
"properties": {
17-
"provider": {
18-
"title": "Analytics provider",
19-
"anyOf": [
20-
{
21-
"title": "Google Analytics",
22-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
23-
"enum": [
24-
"google"
25-
]
26-
},
27-
{
28-
"type": "string"
29-
}
30-
]
31-
},
32-
"property": {
33-
"anyOf": [
34-
{
35-
"title": "Google Analytics 4",
36-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
37-
"pattern": "^G-\\w{10}$"
38-
},
39-
{
40-
"title": "Universal Analytics",
41-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
42-
"pattern": "^UA-\\w{9}-\\w$"
43-
},
44-
{
45-
"title": "Unknown property",
46-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
47-
"type": "string"
16+
"allOf": [
17+
{
18+
"if": {
19+
"properties": {
20+
"provider": {
21+
"enum": [
22+
"google"
23+
]
24+
}
4825
}
49-
]
50-
},
51-
"feedback": {
52-
"title": "Was this page helpful?",
53-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
54-
"type": "object",
55-
"properties": {
56-
"title": {
57-
"title": "Feedback widget title",
58-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
59-
"type": "string",
60-
"default": "Was this page helpful?"
61-
},
62-
"ratings": {
63-
"title": "Feedback ratings",
64-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
65-
"type": "array",
66-
"items": {
67-
"title": "Feedback rating",
68-
"type": "object",
69-
"properties": {
70-
"icon": {
71-
"$ref": "#/$defs/icon"
72-
},
73-
"name": {
74-
"title": "Feedback rating name",
75-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.name",
76-
"type": "string"
77-
},
78-
"data": {
79-
"title": "Feedback rating data",
80-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.data",
81-
"type": "number"
26+
},
27+
"then": {
28+
"properties": {
29+
"provider": {
30+
"title": "Google Analytics",
31+
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
32+
"enum": [
33+
"google"
34+
]
35+
},
36+
"property": {
37+
"anyOf": [
38+
{
39+
"title": "Google Analytics 4",
40+
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
41+
"pattern": "^G-\\w{10}$"
8242
},
83-
"note": {
84-
"title": "Feedback rating data",
85-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.note",
43+
{
44+
"title": "Unknown property",
45+
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
8646
"type": "string"
8747
}
88-
},
89-
"additionalProperties": false,
90-
"required": [
91-
"icon",
92-
"name",
93-
"data",
94-
"note"
9548
]
49+
},
50+
"feedback": {
51+
"$ref": "#/$defs/feedback"
52+
}
53+
},
54+
"required": [
55+
"provider",
56+
"property"
57+
],
58+
"additionalProperties": false
59+
}
60+
},
61+
{
62+
"if": {
63+
"properties": {
64+
"provider": {
65+
"type": "string"
9666
}
9767
}
9868
},
99-
"additionalProperties": false,
100-
"required": [
101-
"title"
102-
]
69+
"then": {
70+
"properties": {
71+
"provider": {
72+
"title": "Custom analytics provider",
73+
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#custom-site-analytics",
74+
"type": "string"
75+
},
76+
"feedback": {
77+
"$ref": "#/$defs/feedback"
78+
}
79+
},
80+
"required": [
81+
"provider"
82+
]
83+
}
10384
}
104-
},
105-
"additionalProperties": false,
106-
"required": [
107-
"provider",
108-
"property"
10985
],
11086
"defaultSnippets": [
11187
{
@@ -406,6 +382,59 @@
406382
"type": "string"
407383
}
408384
]
385+
},
386+
"feedback": {
387+
"title": "Was this page helpful?",
388+
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
389+
"type": "object",
390+
"properties": {
391+
"title": {
392+
"title": "Feedback widget title",
393+
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
394+
"type": "string",
395+
"default": "Was this page helpful?"
396+
},
397+
"ratings": {
398+
"title": "Feedback ratings",
399+
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
400+
"type": "array",
401+
"items": {
402+
"title": "Feedback rating",
403+
"type": "object",
404+
"properties": {
405+
"icon": {
406+
"$ref": "#/$defs/icon"
407+
},
408+
"name": {
409+
"title": "Feedback rating name",
410+
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.name",
411+
"type": "string"
412+
},
413+
"data": {
414+
"title": "Feedback rating data",
415+
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.data",
416+
"type": "number"
417+
},
418+
"note": {
419+
"title": "Feedback rating data",
420+
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.note",
421+
"type": "string"
422+
}
423+
},
424+
"additionalProperties": false,
425+
"required": [
426+
"icon",
427+
"name",
428+
"data",
429+
"note"
430+
]
431+
}
432+
}
433+
},
434+
"additionalProperties": false,
435+
"required": [
436+
"title"
437+
]
409438
}
410439
},
411440
"defaultSnippets": [
@@ -414,7 +443,7 @@
414443
"body": {
415444
"analytics": {
416445
"provider": "${1:google}",
417-
"property": "${2:UA-XXXXXXXX-X}"
446+
"property": "${2:G-XXXXXXXXXX}"
418447
}
419448
}
420449
}

0 commit comments

Comments
 (0)