Knowledge schema:
{
"previewUrls": {},
"properties": {
"label": "Articles",
"validateOnPublish": false
},
"category": "Knowledge",
"scripts": {
"query": "",
"create": "/*var htmlContent = ctx.data.HTMLcontent.iv;\nvar result = htmlContent.match(/<h2>/);\n\nhtmlContent.replace('<h2>','<h2 id=\"article-anchor-h2-1>\"');\nfor(var i = 0; result.lenght >= i; i++){\n \n}\n//result.forEach((element, index) => `<h2 id=article-anchor-h2-${index}>`)\n\n\nctx.data.stringToHTML.iv = result[0];\nctx.data.HTMLcontent.iv = htmlContent;*/\n\n// var regexp = /(<h1.*?>|<h2.*?>)/g;\nvar str = ctx.data.HTMLcontent.iv;\n\n// var text = str.match( regexp ).toString();\n\nfunction findText(toFind, whereToFind){\n\treturn whereToFind.includes(toFind);\n}\n\nfunction getTitle(textToReplace){\n\treturn textToReplace.split('</h')[0].split('>')[1];\n}\n\nfunction getId(text){\n var regexpHeadersIds = /(id=('|\")[\\w\\d]+('|\"))/g;\n var idValue = text.match(regexpHeadersIds);\n if(idValue){\n \treturn idValue[0].split('id=')[1];\n }\n return null;\n}\n\nvar regexp = /(<h(1|2).*?>.*?<\\/h(1|2)>)/g;\n\nvar text = str.match( regexp );\nvar navigation = [];\nvar oldItem = '';\n\nfor(var counter = 0; counter < text.length; counter++){\n\tvar textToReplace = text[counter];\n var title = getTitle(textToReplace);\n var idValueReturned = getId(textToReplace);\n var hash = '';\n if(!idValueReturned){\n hash = '#' + title.replace(' ', '');\n }else{\n \thash = '#' + idValueReturned;\n }\n navigation.push({ title: title, hash: hash, children: []});\n}\n\nctx.data.pattern.iv = JSON.stringify(navigation);\nctx.data.navigation.iv = navigation;\n\nreplace();",
"update": "/*var htmlContent = ctx.data.HTMLcontent.iv;\nvar result = htmlContent.match(/<h2>/);\n\nhtmlContent.replace('<h2>','<h2 id=\"article-anchor-h2-1>\"');\nfor(var i = 0; result.lenght >= i; i++){\n \n}\n//result.forEach((element, index) => `<h2 id=article-anchor-h2-${index}>`)\n\n\nctx.data.stringToHTML.iv = result[0];\nctx.data.HTMLcontent.iv = htmlContent;*/\n\n// var regexp = /(<h1.*?>|<h2.*?>)/g;\nvar str = ctx.data.HTMLcontent.iv;\n\n// var text = str.match( regexp ).toString();\n\nfunction findText(toFind, whereToFind){\n\treturn whereToFind.includes(toFind);\n}\n\nfunction getTitle(textToReplace){\n\treturn textToReplace.split('</h')[0].split('>')[1];\n}\n\nfunction getId(text){\n var regexpHeadersIds = /(id=('|\")[\\w\\d]+('|\"))/g;\n var idValue = text.match(regexpHeadersIds);\n if(idValue){\n \treturn idValue[0].split('id=')[1];\n }\n return null;\n}\n\nvar regexp = /(<h(1|2).*?>.*?<\\/h(1|2)>)/g;\n\nvar text = str.match( regexp );\nvar navigation = [];\nvar oldItem = '';\n\nfor(var counter = 0; counter < text.length; counter++){\n\tvar textToReplace = text[counter];\n var title = getTitle(textToReplace);\n var idValueReturned = getId(textToReplace);\n var hash = '';\n if(!idValueReturned){\n hash = '#' + title.replace(' ', '');\n }else{\n \thash = '#' + idValueReturned;\n }\n navigation.push({ title: title, hash: hash, children: []});\n}\n\nctx.data.pattern.iv = JSON.stringify(navigation);\nctx.data.navigation.iv = navigation;\n\nreplace();"
},
"isPublished": true,
"fieldRules": [
{
"action": "Hide",
"field": "HTMLcontent",
"condition": "data.type.iv != 'HTML'"
},
{
"action": "Hide",
"field": "direct-url",
"condition": "data.type.iv != 'Direct URL'"
},
{
"action": "Hide",
"field": "document-content",
"condition": "data.type.iv != 'Document'"
}
],
"fieldsInLists": [],
"fieldsInReferences": [],
"fields": [
{
"name": "page-title-question",
"properties": {
"isRequired": true,
"isRequiredOnPublish": true,
"isHalfWidth": false,
"fieldType": "String",
"createEnum": false,
"editor": "Input",
"inlineEditable": false,
"isEmbeddable": false,
"isUnique": true,
"contentType": "Unspecified",
"label": "Page Title (Question)"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "type",
"properties": {
"isRequired": true,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "String",
"createEnum": false,
"editor": "Dropdown",
"inlineEditable": false,
"isEmbeddable": false,
"isUnique": false,
"allowedValues": [
"HTML",
"Document",
"Direct URL"
],
"contentType": "Unspecified",
"label": "Type"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "HTMLcontent",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "String",
"createEnum": false,
"editor": "RichText",
"inlineEditable": false,
"isEmbeddable": false,
"isUnique": false,
"contentType": "Html",
"label": "HTML Content",
"editorUrl": ""
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "document-content",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "Assets",
"previewMode": "ImageAndFileName",
"resolveFirst": true,
"minItems": 1,
"maxItems": 1,
"mustBeImage": false,
"resolveImage": true,
"allowedExtensions": [
"png",
"docx",
"pdf"
],
"allowDuplicates": false,
"label": "Document content"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "direct-url",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "String",
"createEnum": false,
"editor": "Input",
"inlineEditable": false,
"isEmbeddable": false,
"isUnique": false,
"pattern": "^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:\\/?#%[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$",
"contentType": "Unspecified",
"label": "Direct URL"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "tags",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "Tags",
"createEnum": false,
"editor": "Tags",
"label": "Tags"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "category",
"properties": {
"isRequired": true,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "String",
"createEnum": false,
"editor": "Dropdown",
"inlineEditable": false,
"isEmbeddable": false,
"isUnique": false,
"allowedValues": [
"Article",
"Document",
"FAQ",
"Video"
],
"contentType": "Unspecified",
"label": "Category",
"hints": "Category for filtering"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "public",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "Boolean",
"editor": "Checkbox",
"inlineEditable": false,
"defaultValue": false,
"label": "Public ",
"hints": "Non logged in users can access the content"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "retailer-access",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "Boolean",
"editor": "Checkbox",
"inlineEditable": false,
"defaultValue": false,
"label": "Retailer Access",
"hints": "A logged in user with the role 'Retailer' can access the content"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "supplier-access",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "Boolean",
"editor": "Checkbox",
"inlineEditable": false,
"defaultValue": false,
"label": "Supplier Access",
"hints": "A logged in user with the role 'Supplier' can access the content"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "asdada",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "Json"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "pattern",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "String",
"createEnum": false,
"editor": "TextArea",
"inlineEditable": false,
"isEmbeddable": false,
"isUnique": false,
"contentType": "Unspecified",
"label": "Pattern"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
},
{
"name": "navigation",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "Json",
"label": "Navigation"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant"
}
],
"type": "Default"
}