Merge pull request #6361 from sisp/fix/analytics-schema

Fixed `extra:analytics` schema for custom providers
This commit is contained in:
Martin Donath 2023-11-19 10:22:44 +01:00 committed by GitHub
commit 1cc4aca43a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,99 +13,75 @@
"title": "Analytics provider", "title": "Analytics provider",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
"type": "object", "type": "object",
"properties": { "allOf": [
"provider": { {
"title": "Analytics provider", "if": {
"anyOf": [ "properties": {
{ "provider": {
"title": "Google Analytics", "enum": [
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", "google"
"enum": [
"google"
]
},
{
"type": "string"
}
]
},
"property": {
"anyOf": [
{
"title": "Google Analytics 4",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
"pattern": "^G-\\w{10}$"
},
{
"title": "Universal Analytics",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
"pattern": "^UA-\\w{9}-\\w$"
},
{
"title": "Unknown property",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
"type": "string"
}
]
},
"feedback": {
"title": "Was this page helpful?",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
"type": "object",
"properties": {
"title": {
"title": "Feedback widget title",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
"type": "string",
"default": "Was this page helpful?"
},
"ratings": {
"title": "Feedback ratings",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
"type": "array",
"items": {
"title": "Feedback rating",
"type": "object",
"properties": {
"icon": {
"$ref": "#/$defs/icon"
},
"name": {
"title": "Feedback rating name",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.name",
"type": "string"
},
"data": {
"title": "Feedback rating data",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.data",
"type": "number"
},
"note": {
"title": "Feedback rating data",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.note",
"type": "string"
}
},
"additionalProperties": false,
"required": [
"icon",
"name",
"data",
"note"
] ]
} }
} }
}, },
"additionalProperties": false, "then": {
"required": [ "properties": {
"title" "provider": {
] "title": "Google Analytics",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
"enum": [
"google"
]
},
"property": {
"anyOf": [
{
"title": "Google Analytics 4",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
"pattern": "^G-\\w{10}$"
},
{
"title": "Unknown property",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics",
"type": "string"
}
]
},
"feedback": {
"$ref": "#/$defs/feedback"
}
},
"required": [
"provider",
"property"
],
"additionalProperties": false
}
},
{
"if": {
"properties": {
"provider": {
"type": "string"
}
}
},
"then": {
"properties": {
"provider": {
"title": "Custom analytics provider",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#custom-site-analytics",
"type": "string"
},
"feedback": {
"$ref": "#/$defs/feedback"
}
},
"required": [
"provider"
]
}
} }
},
"additionalProperties": false,
"required": [
"provider",
"property"
], ],
"defaultSnippets": [ "defaultSnippets": [
{ {
@ -406,6 +382,59 @@
"type": "string" "type": "string"
} }
] ]
},
"feedback": {
"title": "Was this page helpful?",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
"type": "object",
"properties": {
"title": {
"title": "Feedback widget title",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
"type": "string",
"default": "Was this page helpful?"
},
"ratings": {
"title": "Feedback ratings",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful",
"type": "array",
"items": {
"title": "Feedback rating",
"type": "object",
"properties": {
"icon": {
"$ref": "#/$defs/icon"
},
"name": {
"title": "Feedback rating name",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.name",
"type": "string"
},
"data": {
"title": "Feedback rating data",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.data",
"type": "number"
},
"note": {
"title": "Feedback rating data",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.note",
"type": "string"
}
},
"additionalProperties": false,
"required": [
"icon",
"name",
"data",
"note"
]
}
}
},
"additionalProperties": false,
"required": [
"title"
]
} }
}, },
"defaultSnippets": [ "defaultSnippets": [
@ -414,7 +443,7 @@
"body": { "body": {
"analytics": { "analytics": {
"provider": "${1:google}", "provider": "${1:google}",
"property": "${2:UA-XXXXXXXX-X}" "property": "${2:G-XXXXXXXXXX}"
} }
} }
} }