diff --git a/README.md b/README.md index 62dfb69..4a6a518 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,9 @@ The attributes listed below are used in *contentObject.json*, *articles.json*, * ### \_search (object): Container object for the `keywords` setting +### \title (string): +Alternative title for search result. + #### keywords (array): A list of search keywords/phrases to be associated with the contentObject/article/block/component. Each item in the array must be a string. **NOTE**: Keywords are exported with the `grunt translate:export` command. When localising content, use a process that ensures translated keywords are found in the actual translated course content. @@ -60,7 +63,7 @@ A list of search keywords/phrases to be associated with the contentObject/articl No known limitations. ---------------------------- -**Version number:** 4.1.0 adapt learning logo +**Version number:** 4.2.0 adapt learning logo **Framework versions:** 5.8+ **Author / maintainer:** Kineo and community with [contributors](https://github.com/cgkineo/adapt-search/graphs/contributors) **Accessibility support:** WAI AA diff --git a/bower.json b/bower.json index 4a9dd9a..c61e447 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,7 @@ "type": "git", "url": "git://github.com/cgkineo/adapt-search" }, - "version": "4.1.0", + "version": "4.2.0", "framework": ">=5.8", "homepage": "https://github.com/cgkineo/adapt-search", "issues": "https://github.com/cgkineo/adapt-search/issues/", diff --git a/example.json b/example.json index dbbc5bf..50f2e79 100644 --- a/example.json +++ b/example.json @@ -1,6 +1,7 @@ // on each searchable contentObject, article, block or component "_search": { "_isEnabled": true, + "title": "Alternative title", "keywords": [ "sentences which can be used", "to better enhance the component descriptions", diff --git a/js/searchResultsView.js b/js/searchResultsView.js index c71e77b..9c9f8d8 100644 --- a/js/searchResultsView.js +++ b/js/searchResultsView.js @@ -71,7 +71,7 @@ export default class SearchResultsView extends Backbone.View { * of matching multilanguage words, which are sometimes a single character */ const bodyPrettify = new RegExp(`(([^${WORD_CHARACTERS}]*[${WORD_CHARACTERS}]{1}){1,${numberOfPreviewWords * 2}}|.{0,${numberOfPreviewCharacters * 2}})`, 'i'); - const title = stripHTMLAndHandlebars(result.model.get('title')) || stripHTMLAndHandlebars(result.model.get('displayTitle')) || 'No title found'; + const title = stripHTMLAndHandlebars(result.model.get('_search')?.title || '') || stripHTMLAndHandlebars(result.model.get('title')) || stripHTMLAndHandlebars(result.model.get('displayTitle')) || 'No title found'; const safeTitle = replaceAccents(title); const body = stripHTMLAndHandlebars(result.model.get('body')) || ''; const hasNoFoundPhrases = (result.foundPhrases.length === 0); diff --git a/properties.schema b/properties.schema index fc81604..f4cfbee 100644 --- a/properties.schema +++ b/properties.schema @@ -27,6 +27,15 @@ "validators": [], "help": "" }, + "title": { + "type": "string", + "default": "", + "required": false, + "title": "Alternative title", + "inputType": "Text", + "validators": [], + "translatable": true + }, "keywords": { "type": "string", "default": "", @@ -57,6 +66,15 @@ "validators": [], "help": "" }, + "title": { + "type": "string", + "default": "", + "required": false, + "title": "Alternative title", + "inputType": "Text", + "validators": [], + "translatable": true + }, "keywords": { "type": "string", "default": "", @@ -87,6 +105,15 @@ "validators": [], "help": "" }, + "title": { + "type": "string", + "default": "", + "required": false, + "title": "Alternative title", + "inputType": "Text", + "validators": [], + "translatable": true + }, "keywords": { "type": "string", "default": "", @@ -117,6 +144,15 @@ "validators": [], "help": "" }, + "title": { + "type": "string", + "default": "", + "required": false, + "title": "Alternative title", + "inputType": "Text", + "validators": [], + "translatable": true + }, "keywords": { "type": "string", "default": "",