axyseo 2.0.0-alpha.0.0.19 → 2.0.0-alpha.0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/parsedPaper/assess/assessments/Assessment.js +14 -2
- package/build/parsedPaper/assess/assessments/Assessment.js.map +1 -1
- package/build/scoring/assessments/assessment.js +5 -1
- package/build/scoring/assessments/assessment.js.map +1 -1
- package/build/scoring/assessments/readability/ParagraphTooLongAssessment.js +5 -1
- package/build/scoring/assessments/readability/ParagraphTooLongAssessment.js.map +1 -1
- package/build/scoring/assessments/readability/SentenceBeginningsAssessment.js +5 -1
- package/build/scoring/assessments/readability/SentenceBeginningsAssessment.js.map +1 -1
- package/build/scoring/assessments/readability/SentenceLengthInTextAssessment.js +5 -1
- package/build/scoring/assessments/readability/SentenceLengthInTextAssessment.js.map +1 -1
- package/build/scoring/assessments/readability/TransitionWordsAssessment.js +5 -1
- package/build/scoring/assessments/readability/TransitionWordsAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/ImageCountAssessment.js +5 -1
- package/build/scoring/assessments/seo/ImageCountAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/InternalLinksAssessment.js +5 -1
- package/build/scoring/assessments/seo/InternalLinksAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/IntroductionKeywordAssessment.js +5 -1
- package/build/scoring/assessments/seo/IntroductionKeywordAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/KeyphraseAssessment.js +5 -1
- package/build/scoring/assessments/seo/KeyphraseAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/KeyphraseLengthAssessment.js +5 -1
- package/build/scoring/assessments/seo/KeyphraseLengthAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/KeywordDensityAssessment.js +6 -2
- package/build/scoring/assessments/seo/KeywordDensityAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/MetaDescriptionKeywordAssessment.js +5 -1
- package/build/scoring/assessments/seo/MetaDescriptionKeywordAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/MetaDescriptionLengthAssessment.js +5 -1
- package/build/scoring/assessments/seo/MetaDescriptionLengthAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/MetaTitleKeywordAssessment.js +5 -1
- package/build/scoring/assessments/seo/MetaTitleKeywordAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/NumberInMetaTitleAssessment.js +5 -1
- package/build/scoring/assessments/seo/NumberInMetaTitleAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/OutboundLinksAssessment.js +5 -1
- package/build/scoring/assessments/seo/OutboundLinksAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/PageTitleWidthAssessment.js +5 -1
- package/build/scoring/assessments/seo/PageTitleWidthAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/SingleH1Assessment.js +5 -1
- package/build/scoring/assessments/seo/SingleH1Assessment.js.map +1 -1
- package/build/scoring/assessments/seo/SingleTitleAssessment.js +5 -1
- package/build/scoring/assessments/seo/SingleTitleAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/SubHeadingsKeywordAssessment.js +5 -1
- package/build/scoring/assessments/seo/SubHeadingsKeywordAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/TextImagesAssessment.js +5 -1
- package/build/scoring/assessments/seo/TextImagesAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/TextLengthAssessment.js +5 -1
- package/build/scoring/assessments/seo/TextLengthAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/UrlKeywordAssessment.js +5 -1
- package/build/scoring/assessments/seo/UrlKeywordAssessment.js.map +1 -1
- package/build/scoring/assessments/seo/UrlLengthAssessment.js +5 -1
- package/build/scoring/assessments/seo/UrlLengthAssessment.js.map +1 -1
- package/build/scoring/assessors/assessor.js +20 -7
- package/build/scoring/assessors/assessor.js.map +1 -1
- package/build/scoring/assessors/avadaAssessor.js +5 -4
- package/build/scoring/assessors/avadaAssessor.js.map +1 -1
- package/build/scoring/assessors/contentAssessor.js +3 -3
- package/build/scoring/assessors/contentAssessor.js.map +1 -1
- package/build/scoring/assessors/seoAssessor.js +3 -3
- package/build/scoring/assessors/seoAssessor.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextImagesAssessment.js","names":["_lodash","require","_polaris","_react","_interopRequireDefault","_assessment","_AssessmentResult","_helpers","_polarisIcons","e","__esModule","default","TextImagesAssessment","Assessment","constructor","config","defaultConfig","id","ctaType","docUrl","fixPosition","icon","ExternalIcon","priority","title","content","good","improve","bad","identifier","_config","merge","getResult","paper","researcher","i18n","assessmentResult","AssessmentResult","altTagsProperties","getResearch","imageCount","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","imagesNoAlt","noAlt","getScore","createElement","Text","as","href","target","rel","fix","shop","data","console","log","altText","name","parser","DOMParser","doc","parseFromString","imgTags","querySelectorAll","forEach","img","hasAttribute","getAttribute","setAttribute","innerHTML","isApplicable","hasText","exports"],"sources":["../../../../src/scoring/assessments/seo/TextImagesAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport {Text} from '@shopify/polaris';\nimport React from 'react';\n\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {checkMissingAlt} from '../../../helpers';\nimport {ExternalIcon} from '@shopify/polaris-icons';\n\n/**\n * Represents the assessment that assesses the SEO title width and gives the feedback accordingly.\n */\nexport default class TextImagesAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'textImages',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#alt-text',\n fixPosition: 'description',\n icon: ExternalIcon,\n priority: 'high',\n title: 'Alt text',\n content: {\n good: 'All images have descriptive and relevant alt text.',\n improve: '',\n bad: 'Missing alt text. Add descriptive alt text for accessibility and SEO.'\n }\n };\n\n this.identifier = 'textImages';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Runs the h1 research and based on this returns an assessment result with a score.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param {Researcher} researcher The researcher used for calling the research.\n * @param i18n\n * @returns {AssessmentResult} The assessment result.\n */\n getResult(paper, researcher, i18n) {\n const assessmentResult = new AssessmentResult({config: this._config});\n this.altTagsProperties = researcher.getResearch('altTagCount');\n this.imageCount = researcher.getResearch('imageCount');\n\n const calculatedResult = this.calculateResult(paper, i18n);\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n *\n * @param paper\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, i18n) {\n const imagesNoAlt = this.altTagsProperties.noAlt;\n\n let status = '';\n if (imagesNoAlt === this.imageCount || imagesNoAlt > 0) {\n status = 'bad';\n } else {\n status = 'good';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n Learn more\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n *\n * @param shop\n * @param data\n * @returns {string}\n */\n fix({shop, data}) {\n if (!shop) {\n console.log('Shop is missing');\n return data.body || '';\n }\n\n if (!data.body) {\n console.log('body is missing');\n return '';\n }\n\n const altText = shop?.name || 'Shop' + ' | ' + data?.title || 'Title';\n\n const parser = new DOMParser();\n const doc = parser.parseFromString(data.body, 'text/html');\n\n const imgTags = doc.querySelectorAll('img');\n\n imgTags.forEach(img => {\n if (!img.hasAttribute('alt') || img.getAttribute('alt') === '') {\n img.setAttribute('alt', altText);\n }\n });\n\n return doc.body.innerHTML;\n }\n\n /**\n * Checks whether the paper has a text.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param researcher\n * @returns {boolean} True when there is text.\n */\n isApplicable(paper, researcher) {\n this.imageCount = researcher.getResearch('imageCount');\n return paper.hasText() && this.imageCount > 0;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,iBAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AAAoD,SAAAG,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEpD;AACA;AACA;AACe,MAAMG,oBAAoB,SAASC,mBAAU,CAAC;EAC3D;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,YAAY;MAChBC,OAAO,EAAE,KAAK;MACdC,MAAM,EACJ,sFAAsF;MACxFC,WAAW,EAAE,aAAa;MAC1BC,IAAI,EAAEC,0BAAY;MAClBC,QAAQ,EAAE,MAAM;MAChBC,KAAK,EAAE,UAAU;MACjBC,OAAO,EAAE;QACPC,IAAI,EAAE,oDAAoD;QAC1DC,OAAO,EAAE,EAAE;QACXC,GAAG,EAAE;MACP;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,YAAY;IAC9B,IAAI,CAACC,OAAO,GAAG,IAAAC,aAAK,EAACf,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEiB,SAASA,
|
|
1
|
+
{"version":3,"file":"TextImagesAssessment.js","names":["_lodash","require","_polaris","_react","_interopRequireDefault","_assessment","_AssessmentResult","_helpers","_polarisIcons","e","__esModule","default","TextImagesAssessment","Assessment","constructor","config","defaultConfig","id","ctaType","docUrl","fixPosition","icon","ExternalIcon","priority","title","content","good","improve","bad","identifier","_config","merge","getResult","paper","researcher","i18n","assessmentResult","AssessmentResult","altTagsProperties","getResearch","imageCount","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","imagesNoAlt","noAlt","getScore","createElement","Text","as","href","target","rel","fix","shop","data","console","log","altText","name","parser","DOMParser","doc","parseFromString","imgTags","querySelectorAll","forEach","img","hasAttribute","getAttribute","setAttribute","innerHTML","isApplicable","hasText","exports"],"sources":["../../../../src/scoring/assessments/seo/TextImagesAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport {Text} from '@shopify/polaris';\nimport React from 'react';\n\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {checkMissingAlt} from '../../../helpers';\nimport {ExternalIcon} from '@shopify/polaris-icons';\n\n/**\n * Represents the assessment that assesses the SEO title width and gives the feedback accordingly.\n */\nexport default class TextImagesAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'textImages',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#alt-text',\n fixPosition: 'description',\n icon: ExternalIcon,\n priority: 'high',\n title: 'Alt text',\n content: {\n good: 'All images have descriptive and relevant alt text.',\n improve: '',\n bad: 'Missing alt text. Add descriptive alt text for accessibility and SEO.'\n }\n };\n\n this.identifier = 'textImages';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Runs the h1 research and based on this returns an assessment result with a score.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param {Researcher} researcher The researcher used for calling the research.\n * @param i18n\n * @returns {AssessmentResult} The assessment result.\n */\n getResult({paper, researcher, i18n}) {\n const assessmentResult = new AssessmentResult({config: this._config});\n this.altTagsProperties = researcher.getResearch('altTagCount');\n this.imageCount = researcher.getResearch('imageCount');\n\n const calculatedResult = this.calculateResult(paper, i18n);\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n *\n * @param paper\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, i18n) {\n const imagesNoAlt = this.altTagsProperties.noAlt;\n\n let status = '';\n if (imagesNoAlt === this.imageCount || imagesNoAlt > 0) {\n status = 'bad';\n } else {\n status = 'good';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n Learn more\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n *\n * @param shop\n * @param data\n * @returns {string}\n */\n fix({shop, data}) {\n if (!shop) {\n console.log('Shop is missing');\n return data.body || '';\n }\n\n if (!data.body) {\n console.log('body is missing');\n return '';\n }\n\n const altText = shop?.name || 'Shop' + ' | ' + data?.title || 'Title';\n\n const parser = new DOMParser();\n const doc = parser.parseFromString(data.body, 'text/html');\n\n const imgTags = doc.querySelectorAll('img');\n\n imgTags.forEach(img => {\n if (!img.hasAttribute('alt') || img.getAttribute('alt') === '') {\n img.setAttribute('alt', altText);\n }\n });\n\n return doc.body.innerHTML;\n }\n\n /**\n * Checks whether the paper has a text.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param researcher\n * @returns {boolean} True when there is text.\n */\n isApplicable(paper, researcher) {\n this.imageCount = researcher.getResearch('imageCount');\n return paper.hasText() && this.imageCount > 0;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA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AAE;MACTE,OAAO,CAACC,GAAG,CAAC,iBAAiB,CAAC;MAC9B,OAAOF,IAAI,CAACZ,IAAI,IAAI,EAAE;IACxB;IAEA,IAAI,CAACY,IAAI,CAACZ,IAAI,EAAE;MACda,OAAO,CAACC,GAAG,CAAC,iBAAiB,CAAC;MAC9B,OAAO,EAAE;IACX;IAEA,MAAMC,OAAO,GAAGJ,IAAI,EAAEK,IAAI,IAAI,MAAM,GAAG,KAAK,GAAGJ,IAAI,EAAEpC,KAAK,IAAI,OAAO;IAErE,MAAMyC,MAAM,GAAG,IAAIC,SAAS,CAAC,CAAC;IAC9B,MAAMC,GAAG,GAAGF,MAAM,CAACG,eAAe,CAACR,IAAI,CAACZ,IAAI,EAAE,WAAW,CAAC;IAE1D,MAAMqB,OAAO,GAAGF,GAAG,CAACG,gBAAgB,CAAC,KAAK,CAAC;IAE3CD,OAAO,CAACE,OAAO,CAACC,GAAG,IAAI;MACrB,IAAI,CAACA,GAAG,CAACC,YAAY,CAAC,KAAK,CAAC,IAAID,GAAG,CAACE,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE;QAC9DF,GAAG,CAACG,YAAY,CAAC,KAAK,EAAEZ,OAAO,CAAC;MAClC;IACF,CAAC,CAAC;IAEF,OAAOI,GAAG,CAACnB,IAAI,CAAC4B,SAAS;EAC3B;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,YAAYA,CAAC5C,KAAK,EAAEC,UAAU,EAAE;IAC9B,IAAI,CAACM,UAAU,GAAGN,UAAU,CAACK,WAAW,CAAC,YAAY,CAAC;IACtD,OAAON,KAAK,CAAC6C,OAAO,CAAC,CAAC,IAAI,IAAI,CAACtC,UAAU,GAAG,CAAC;EAC/C;AACF;AAACuC,OAAA,CAAApE,OAAA,GAAAC,oBAAA","ignoreList":[]}
|
|
@@ -50,7 +50,11 @@ class TextLengthAssessment extends _assessment.default {
|
|
|
50
50
|
* @param i18n
|
|
51
51
|
* @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.
|
|
52
52
|
*/
|
|
53
|
-
getResult(
|
|
53
|
+
getResult({
|
|
54
|
+
paper,
|
|
55
|
+
researcher,
|
|
56
|
+
i18n
|
|
57
|
+
}) {
|
|
54
58
|
const calculatedResult = this.calculateResult(paper, i18n);
|
|
55
59
|
const assessmentResult = new _AssessmentResult.default({
|
|
56
60
|
config: this._config
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextLengthAssessment.js","names":["_lodash","require","_react","_interopRequireDefault","_polaris","_assessment","_AssessmentResult","_helpers","e","__esModule","default","TextLengthAssessment","Assessment","constructor","config","defaultConfig","id","ctaType","docUrl","priority","fixPosition","title","content","good","improve","bad","identifier","_config","merge","getResult","paper","researcher","i18n","calculatedResult","calculateResult","assessmentResult","AssessmentResult","setScore","score","setStatus","status","setBody","body","wordCount","charCount","countWordInHtml","getText","getScore","createElement","Text","as","href","target","rel","exports"],"sources":["../../../../src/scoring/assessments/seo/TextLengthAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\n\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {countWordInHtml} from '@axyseo/helpers';\n\n/**\n * Represents an assessment that checks the length of the text and gives feedback accordingly.\n */\nexport default class TextLengthAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'textLength',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#text-length',\n priority: 'high',\n fixPosition: 'description',\n title: 'Text length',\n content: {\n good: 'Text length is optimized.',\n improve:\n 'Content length is acceptable, but could be expanded to 2,500 characters for more value.',\n bad:\n 'Insufficient content. Aim for at least 600 words to provide value and rank well in search results.'\n }\n };\n\n this.identifier = 'textLength';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Executes the Assessment and returns a result.\n *\n * @param {Paper} paper The Paper object to assess.\n * @param {Researcher} researcher The Researcher object containing all available researches.\n *\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.\n */\n getResult(paper, researcher, i18n) {\n const calculatedResult = this.calculateResult(paper, i18n);\n\n const assessmentResult = new AssessmentResult({config: this._config});\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n *\n * @param paper\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, i18n) {\n const {wordCount, charCount} = countWordInHtml(paper.getText(), true);\n let status = 'bad';\n if (charCount < 2500 && wordCount >= 600) {\n status = 'improve';\n }\n if (wordCount < 600 && charCount < 2500) {\n status = 'bad';\n }\n if (charCount >= 2500 && wordCount >= 600) {\n status = 'good';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n Learn more\n </a>\n )}\n </Text>\n )\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,iBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAAgD,SAAAE,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhD;AACA;AACA;AACe,MAAMG,oBAAoB,SAASC,mBAAU,CAAC;EAC3D;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,YAAY;MAChBC,OAAO,EAAE,KAAK;MACdC,MAAM,EACJ,yFAAyF;MAC3FC,QAAQ,EAAE,MAAM;MAChBC,WAAW,EAAE,aAAa;MAC1BC,KAAK,EAAE,aAAa;MACpBC,OAAO,EAAE;QACPC,IAAI,EAAE,2BAA2B;QACjCC,OAAO,EACL,yFAAyF;QAC3FC,GAAG,EACD;MACJ;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,YAAY;IAC9B,IAAI,CAACC,OAAO,GAAG,IAAAC,aAAK,EAACb,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEe,SAASA,
|
|
1
|
+
{"version":3,"file":"TextLengthAssessment.js","names":["_lodash","require","_react","_interopRequireDefault","_polaris","_assessment","_AssessmentResult","_helpers","e","__esModule","default","TextLengthAssessment","Assessment","constructor","config","defaultConfig","id","ctaType","docUrl","priority","fixPosition","title","content","good","improve","bad","identifier","_config","merge","getResult","paper","researcher","i18n","calculatedResult","calculateResult","assessmentResult","AssessmentResult","setScore","score","setStatus","status","setBody","body","wordCount","charCount","countWordInHtml","getText","getScore","createElement","Text","as","href","target","rel","exports"],"sources":["../../../../src/scoring/assessments/seo/TextLengthAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\n\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport {countWordInHtml} from '@axyseo/helpers';\n\n/**\n * Represents an assessment that checks the length of the text and gives feedback accordingly.\n */\nexport default class TextLengthAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} [config] The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'textLength',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#text-length',\n priority: 'high',\n fixPosition: 'description',\n title: 'Text length',\n content: {\n good: 'Text length is optimized.',\n improve:\n 'Content length is acceptable, but could be expanded to 2,500 characters for more value.',\n bad:\n 'Insufficient content. Aim for at least 600 words to provide value and rank well in search results.'\n }\n };\n\n this.identifier = 'textLength';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Executes the Assessment and returns a result.\n *\n * @param {Paper} paper The Paper object to assess.\n * @param {Researcher} researcher The Researcher object containing all available researches.\n *\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.\n */\n getResult({paper, researcher, i18n}) {\n const calculatedResult = this.calculateResult(paper, i18n);\n\n const assessmentResult = new AssessmentResult({config: this._config});\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n *\n * @param paper\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, i18n) {\n const {wordCount, charCount} = countWordInHtml(paper.getText(), true);\n let status = 'bad';\n if (charCount < 2500 && wordCount >= 600) {\n status = 'improve';\n }\n if (wordCount < 600 && charCount < 2500) {\n status = 'bad';\n }\n if (charCount >= 2500 && wordCount >= 600) {\n status = 'good';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n Learn more\n </a>\n )}\n </Text>\n )\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,iBA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P,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACED,eAAeA,CAACJ,KAAK,EAAEE,IAAI,EAAE;IAC3B,MAAM;MAACW,SAAS;MAAEC;IAAS,CAAC,GAAG,IAAAC,wBAAe,EAACf,KAAK,CAACgB,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC;IACrE,IAAIN,MAAM,GAAG,KAAK;IAClB,IAAII,SAAS,GAAG,IAAI,IAAID,SAAS,IAAI,GAAG,EAAE;MACxCH,MAAM,GAAG,SAAS;IACpB;IACA,IAAIG,SAAS,GAAG,GAAG,IAAIC,SAAS,GAAG,IAAI,EAAE;MACvCJ,MAAM,GAAG,KAAK;IAChB;IACA,IAAII,SAAS,IAAI,IAAI,IAAID,SAAS,IAAI,GAAG,EAAE;MACzCH,MAAM,GAAG,MAAM;IACjB;IAEA,MAAMF,KAAK,GAAG,IAAI,CAACS,QAAQ,CAAC,IAAI,CAACpB,OAAO,CAACR,QAAQ,EAAEqB,MAAM,CAAC;IAE1D,OAAO;MACLF,KAAK;MACLE,MAAM;MACNE,IAAI,eACFxC,MAAA,CAAAQ,OAAA,CAAAsC,aAAA,CAAC5C,QAAA,CAAA6C,IAAI;QAACC,EAAE,EAAE;MAAO,GACd,IAAI,CAACvB,OAAO,CAACL,OAAO,CAACkB,MAAM,CAAC,EAAE,GAAG,EACjC,IAAI,CAACb,OAAO,CAACT,MAAM,iBAClBhB,MAAA,CAAAQ,OAAA,CAAAsC,aAAA;QAAGG,IAAI,EAAE,IAAI,CAACxB,OAAO,CAACT,MAAO;QAACkC,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAY,GAAC,YAE5D,CAED;IAEV,CAAC;EACH;AACF;AAACC,OAAA,CAAA5C,OAAA,GAAAC,oBAAA","ignoreList":[]}
|
|
@@ -48,7 +48,11 @@ class SlugKeywordAssessment extends _assessment.default {
|
|
|
48
48
|
* @param i18n
|
|
49
49
|
* @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.
|
|
50
50
|
*/
|
|
51
|
-
getResult(
|
|
51
|
+
getResult({
|
|
52
|
+
paper,
|
|
53
|
+
researcher,
|
|
54
|
+
i18n
|
|
55
|
+
}) {
|
|
52
56
|
this._keywordInSlug = researcher.getResearch('keywordCountInSlug');
|
|
53
57
|
const assessmentResult = new _AssessmentResult.default({
|
|
54
58
|
config: this._config
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlKeywordAssessment.js","names":["_react","_interopRequireDefault","require","_polaris","_lodash","_assessment","_AssessmentResult","e","__esModule","default","SlugKeywordAssessment","Assessment","constructor","config","defaultConfig","id","docUrl","fixPosition","ctaType","priority","title","content","good","improve","bad","identifier","_config","merge","getResult","paper","researcher","i18n","_keywordInSlug","getResearch","assessmentResult","AssessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","isApplicable","isFrontPage","hasKeyword","hasSlug","hasResearch","keyphraseLength","percentWordMatches","getScore","createElement","Text","as","href","target","rel","_default","exports"],"sources":["../../../../src/scoring/assessments/seo/UrlKeywordAssessment.js"],"sourcesContent":["import React from 'react';\nimport {Text} from '@shopify/polaris';\nimport {merge} from 'lodash';\n\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\n\n/**\n * Represents the Slug keyword assessment. This assessment checks if the keyword is present in the slug.\n */\nclass SlugKeywordAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} config The configuration to use.\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'slugKeyword',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#keyword-in-url',\n fixPosition: 'url handle',\n ctaType: 'fix',\n priority: 'medium',\n title: 'Keyword in URL',\n content: {\n good: 'Keyword is included in URL.',\n improve: '',\n bad: 'Missing keyword in URL. Include it for relevance and better SEO.'\n }\n };\n\n this.identifier = 'slugKeyword';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Executes the Assessment and returns a result.\n *\n * @param {Paper} paper The Paper object to assess.\n * @param {Researcher} researcher The Researcher object containing all available researches.\n *\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.\n */\n getResult(paper, researcher, i18n) {\n this._keywordInSlug = researcher.getResearch('keywordCountInSlug');\n\n const assessmentResult = new AssessmentResult({config: this._config});\n\n const calculatedResult = this.calculateResult(i18n);\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n return assessmentResult;\n }\n\n /**\n * Checks whether the paper has a keyword and a slug.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} True if the paper contains a keyword and a slug, and if the keywordCountInSlug research is available on the researcher.\n */\n isApplicable(paper, researcher) {\n return (\n !paper.isFrontPage() &&\n paper.hasKeyword() &&\n paper.hasSlug() &&\n researcher.hasResearch('keywordCountInSlug')\n );\n }\n\n /**\n *\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(i18n) {\n const status = (() => {\n if (this._keywordInSlug.keyphraseLength < 3) {\n return this._keywordInSlug.percentWordMatches === 100 ? 'good' : 'bad';\n }\n return this._keywordInSlug.percentWordMatches > 50 ? 'good' : 'bad';\n })();\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n Learn more\n </a>\n )}\n </Text>\n )\n };\n }\n}\n\nexport default SlugKeywordAssessment;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,iBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAAgE,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhE;AACA;AACA;AACA,MAAMG,qBAAqB,SAASC,mBAAU,CAAC;EAC7C;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,aAAa;MACjBC,MAAM,EACJ,4FAA4F;MAC9FC,WAAW,EAAE,YAAY;MACzBC,OAAO,EAAE,KAAK;MACdC,QAAQ,EAAE,QAAQ;MAClBC,KAAK,EAAE,gBAAgB;MACvBC,OAAO,EAAE;QACPC,IAAI,EAAE,6BAA6B;QACnCC,OAAO,EAAE,EAAE;QACXC,GAAG,EAAE;MACP;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,aAAa;IAC/B,IAAI,CAACC,OAAO,GAAG,IAAAC,aAAK,EAACb,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEe,SAASA,
|
|
1
|
+
{"version":3,"file":"UrlKeywordAssessment.js","names":["_react","_interopRequireDefault","require","_polaris","_lodash","_assessment","_AssessmentResult","e","__esModule","default","SlugKeywordAssessment","Assessment","constructor","config","defaultConfig","id","docUrl","fixPosition","ctaType","priority","title","content","good","improve","bad","identifier","_config","merge","getResult","paper","researcher","i18n","_keywordInSlug","getResearch","assessmentResult","AssessmentResult","calculatedResult","calculateResult","setScore","score","setStatus","status","setBody","body","isApplicable","isFrontPage","hasKeyword","hasSlug","hasResearch","keyphraseLength","percentWordMatches","getScore","createElement","Text","as","href","target","rel","_default","exports"],"sources":["../../../../src/scoring/assessments/seo/UrlKeywordAssessment.js"],"sourcesContent":["import React from 'react';\nimport {Text} from '@shopify/polaris';\nimport {merge} from 'lodash';\n\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\n\n/**\n * Represents the Slug keyword assessment. This assessment checks if the keyword is present in the slug.\n */\nclass SlugKeywordAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {Object} config The configuration to use.\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'slugKeyword',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#keyword-in-url',\n fixPosition: 'url handle',\n ctaType: 'fix',\n priority: 'medium',\n title: 'Keyword in URL',\n content: {\n good: 'Keyword is included in URL.',\n improve: '',\n bad: 'Missing keyword in URL. Include it for relevance and better SEO.'\n }\n };\n\n this.identifier = 'slugKeyword';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Executes the Assessment and returns a result.\n *\n * @param {Paper} paper The Paper object to assess.\n * @param {Researcher} researcher The Researcher object containing all available researches.\n *\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.\n */\n getResult({paper, researcher, i18n}) {\n this._keywordInSlug = researcher.getResearch('keywordCountInSlug');\n\n const assessmentResult = new AssessmentResult({config: this._config});\n\n const calculatedResult = this.calculateResult(i18n);\n\n assessmentResult.setScore(calculatedResult.score);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n return assessmentResult;\n }\n\n /**\n * Checks whether the paper has a keyword and a slug.\n *\n * @param {Paper} paper The paper to use for the assessment.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} True if the paper contains a keyword and a slug, and if the keywordCountInSlug research is available on the researcher.\n */\n isApplicable(paper, researcher) {\n return (\n !paper.isFrontPage() &&\n paper.hasKeyword() &&\n paper.hasSlug() &&\n researcher.hasResearch('keywordCountInSlug')\n );\n }\n\n /**\n *\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(i18n) {\n const status = (() => {\n if (this._keywordInSlug.keyphraseLength < 3) {\n return this._keywordInSlug.percentWordMatches === 100 ? 'good' : 'bad';\n }\n return this._keywordInSlug.percentWordMatches > 50 ? 'good' : 'bad';\n })();\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n Learn more\n </a>\n )}\n </Text>\n )\n };\n }\n}\n\nexport default SlugKeywordAssessment;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,iBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAAgE,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhE;AACA;AACA;AACA,MAAMG,qBAAqB,SAASC,mBAAU,CAAC;EAC7C;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,aAAa;MACjBC,MAAM,EACJ,4FAA4F;MAC9FC,WAAW,EAAE,YAAY;MACzBC,OAAO,EAAE,KAAK;MACdC,QAAQ,EAAE,QAAQ;MAClBC,KAAK,EAAE,gBAAgB;MACvBC,OAAO,EAAE;QACPC,IAAI,EAAE,6BAA6B;QACnCC,OAAO,EAAE,EAAE;QACXC,GAAG,EAAE;MACP;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,aAAa;IAC/B,IAAI,CAACC,OAAO,GAAG,IAAAC,aAAK,EAACb,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;A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O,CAACP,QAAQ,EAAEsB,MAAM,CAAC;IAE1D,OAAO;MACLF,KAAK;MACLE,MAAM;MACNE,IAAI,eACF3C,MAAA,CAAAS,OAAA,CAAA2C,aAAA,CAACjD,QAAA,CAAAkD,IAAI;QAACC,EAAE,EAAE;MAAO,GACd,IAAI,CAAC5B,OAAO,CAACL,OAAO,CAACoB,MAAM,CAAC,EAAE,GAAG,EACjC,IAAI,CAACf,OAAO,CAACV,MAAM,iBAClBhB,MAAA,CAAAS,OAAA,CAAA2C,aAAA;QAAGG,IAAI,EAAE,IAAI,CAAC7B,OAAO,CAACV,MAAO;QAACwC,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAY,GAAC,YAE5D,CAED;IAEV,CAAC;EACH;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAlD,OAAA,GAEcC,qBAAqB","ignoreList":[]}
|
|
@@ -75,7 +75,11 @@ class UrlLengthAssessment extends _assessment.default {
|
|
|
75
75
|
* @param i18n
|
|
76
76
|
* @returns {AssessmentResult}
|
|
77
77
|
*/
|
|
78
|
-
getResult(
|
|
78
|
+
getResult({
|
|
79
|
+
paper,
|
|
80
|
+
researcher,
|
|
81
|
+
i18n
|
|
82
|
+
}) {
|
|
79
83
|
const calculatedResult = this.calculateResult(paper, i18n);
|
|
80
84
|
const assessmentResult = new _AssessmentResult.default({
|
|
81
85
|
config: this._config
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlLengthAssessment.js","names":["_lodash","require","_react","_interopRequireDefault","_polaris","_AssessmentResult","_assessment","e","__esModule","default","UrlLengthAssessment","Assessment","constructor","config","defaultConfig","id","priority","docUrl","fixPosition","ctaType","title","content","good","improve","bad","identifier","_config","merge","calculateResult","paper","i18n","status","length","getDomain","getSlug","score","getScore","body","createElement","Text","as","href","target","rel","getResult","researcher","calculatedResult","assessmentResult","AssessmentResult","setStatus","setBody","isApplicable","exports"],"sources":["../../../../src/scoring/assessments/seo/UrlLengthAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\n/**\n * Represents the assessment that checks whether there are three or more consecutive sentences beginning with the same word.\n */\nexport default class UrlLengthAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'urlLength',\n priority: 'high',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#url-length',\n fixPosition: 'url handle',\n ctaType: 'fix',\n title: 'URL length',\n content: {\n good: 'URL length is optimized, less than 75 characters.',\n improve: '',\n bad: 'Keep it less than 75 characters for better readability and SEO.'\n }\n };\n\n this.identifier = 'urlLength';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param paper\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, i18n) {\n let status = '';\n const length = paper.getDomain().length + paper.getSlug().length + 11;\n\n if (length < 75) {\n status = 'good';\n } else {\n status = 'bad';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n Learn more\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult(paper, researcher, i18n) {\n const calculatedResult = this.calculateResult(paper, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the sentence beginnings assessment is applicable to the paper.\n *\n * @param {Object} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available and the paper is not empty.\n */\n isApplicable(paper, researcher) {\n return true;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvC;AACA;AACA;AACe,MAAMG,mBAAmB,SAASC,mBAAU,CAAC;EAC1D;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,WAAW;MACfC,QAAQ,EAAE,MAAM;MAChBC,MAAM,EACJ,wFAAwF;MAC1FC,WAAW,EAAE,YAAY;MACzBC,OAAO,EAAE,KAAK;MACdC,KAAK,EAAE,YAAY;MACnBC,OAAO,EAAE;QACPC,IAAI,EAAE,mDAAmD;QACzDC,OAAO,EAAE,EAAE;QACXC,GAAG,EAAE;MACP;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,WAAW;IAC7B,IAAI,CAACC,OAAO,GAAG,IAAAC,aAAK,EAACb,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEe,eAAeA,CAACC,KAAK,EAAEC,IAAI,EAAE;IAC3B,IAAIC,MAAM,GAAG,EAAE;IACf,MAAMC,MAAM,GAAGH,KAAK,CAACI,SAAS,CAAC,CAAC,CAACD,MAAM,GAAGH,KAAK,CAACK,OAAO,CAAC,CAAC,CAACF,MAAM,GAAG,EAAE;IAErE,IAAIA,MAAM,GAAG,EAAE,EAAE;MACfD,MAAM,GAAG,MAAM;IACjB,CAAC,MAAM;MACLA,MAAM,GAAG,KAAK;IAChB;IAEA,MAAMI,KAAK,GAAG,IAAI,CAACC,QAAQ,CAAC,IAAI,CAACV,OAAO,CAACV,QAAQ,EAAEe,MAAM,CAAC;IAE1D,OAAO;MACLI,KAAK;MACLJ,MAAM;MACNM,IAAI,eACFnC,MAAA,CAAAO,OAAA,CAAA6B,aAAA,CAAClC,QAAA,CAAAmC,IAAI;QAACC,EAAE,EAAE;MAAO,GACd,IAAI,CAACd,OAAO,CAACL,OAAO,CAACU,MAAM,CAAC,EAAE,GAAG,EACjC,IAAI,CAACL,OAAO,CAACT,MAAM,iBAClBf,MAAA,CAAAO,OAAA,CAAA6B,aAAA;QAAGG,IAAI,EAAE,IAAI,CAACf,OAAO,CAACT,MAAO;QAACyB,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAY,GAAC,YAE5D,CAED;IAEV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,SAASA,
|
|
1
|
+
{"version":3,"file":"UrlLengthAssessment.js","names":["_lodash","require","_react","_interopRequireDefault","_polaris","_AssessmentResult","_assessment","e","__esModule","default","UrlLengthAssessment","Assessment","constructor","config","defaultConfig","id","priority","docUrl","fixPosition","ctaType","title","content","good","improve","bad","identifier","_config","merge","calculateResult","paper","i18n","status","length","getDomain","getSlug","score","getScore","body","createElement","Text","as","href","target","rel","getResult","researcher","calculatedResult","assessmentResult","AssessmentResult","setStatus","setBody","isApplicable","exports"],"sources":["../../../../src/scoring/assessments/seo/UrlLengthAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\n/**\n * Represents the assessment that checks whether there are three or more consecutive sentences beginning with the same word.\n */\nexport default class UrlLengthAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'urlLength',\n priority: 'high',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#url-length',\n fixPosition: 'url handle',\n ctaType: 'fix',\n title: 'URL length',\n content: {\n good: 'URL length is optimized, less than 75 characters.',\n improve: '',\n bad: 'Keep it less than 75 characters for better readability and SEO.'\n }\n };\n\n this.identifier = 'urlLength';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param paper\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, i18n) {\n let status = '';\n const length = paper.getDomain().length + paper.getSlug().length + 11;\n\n if (length < 75) {\n status = 'good';\n } else {\n status = 'bad';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n Learn more\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const calculatedResult = this.calculateResult(paper, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the sentence beginnings assessment is applicable to the paper.\n *\n * @param {Object} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available and the paper is not empty.\n */\n isApplicable(paper, researcher) {\n return true;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAF,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,IAAI,eACFnC,MAAA,CAAAO,OAAA,CAAA6B,aAAA,CAAClC,QAAA,CAAAmC,IAAI;QAACC,EAAE,EAAE;MAAO,GACd,IAAI,CAACd,OAAO,CAACL,OAAO,CAACU,MAAM,CAAC,EAAE,GAAG,EACjC,IAAI,CAACL,OAAO,CAACT,MAAM,iBAClBf,MAAA,CAAAO,OAAA,CAAA6B,aAAA;QAAGG,IAAI,EAAE,IAAI,CAACf,OAAO,CAACT,MAAO;QAACyB,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAY,GAAC,YAE5D,CAED;IAEV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,SAASA,CAAC;IAACf,KAAK;IAAEgB,UAAU;IAAEf;EAAI,CAAC,EAAE;IACnC,MAAMgB,gBAAgB,GAAG,IAAI,CAAClB,eAAe,CAACC,KAAK,EAAEC,IAAI,CAAC;IAC1D,MAAMiB,gBAAgB,GAAG,IAAIC,yBAAgB,CAAC;MAACnC,MAAM,EAAE,IAAI,CAACa;IAAO,CAAC,CAAC;IAErEqB,gBAAgB,CAACE,SAAS,CAACH,gBAAgB,CAACf,MAAM,CAAC;IACnDgB,gBAAgB,CAACE,SAAS,CAACH,gBAAgB,CAACf,MAAM,CAAC;IACnDgB,gBAAgB,CAACG,OAAO,CAACJ,gBAAgB,CAACT,IAAI,CAAC;IAE/C,OAAOU,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEI,YAAYA,CAACtB,KAAK,EAAEgB,UAAU,EAAE;IAC9B,OAAO,IAAI;EACb;AACF;AAACO,OAAA,CAAA3C,OAAA,GAAAC,mBAAA","ignoreList":[]}
|
|
@@ -25,13 +25,13 @@ class Assessor {
|
|
|
25
25
|
/**
|
|
26
26
|
* Creates a new Assessor instance.
|
|
27
27
|
* @param {Researcher} researcher The researcher to use.
|
|
28
|
-
* @param {Object} [
|
|
28
|
+
* @param {Object} [config] The assessor config.
|
|
29
29
|
*/
|
|
30
|
-
constructor(researcher,
|
|
30
|
+
constructor(researcher, config) {
|
|
31
31
|
this.type = 'assessor';
|
|
32
32
|
this.setResearcher(researcher);
|
|
33
33
|
this._assessments = [];
|
|
34
|
-
this.
|
|
34
|
+
this._config = config || {};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -79,7 +79,7 @@ class Assessor {
|
|
|
79
79
|
* @returns {boolean} Whether or not the assessment has a marker.
|
|
80
80
|
*/
|
|
81
81
|
hasMarker(assessment) {
|
|
82
|
-
return (0, _lodash.isFunction)(this.
|
|
82
|
+
return (0, _lodash.isFunction)(this._config.marker) && (assessment.hasOwnProperty('getMarks') || typeof assessment.getMarks === 'function');
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
@@ -88,7 +88,7 @@ class Assessor {
|
|
|
88
88
|
* @returns {Function} The specific marker for this assessor.
|
|
89
89
|
*/
|
|
90
90
|
getSpecificMarker() {
|
|
91
|
-
return this.
|
|
91
|
+
return this._config.marker;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -143,8 +143,21 @@ class Assessor {
|
|
|
143
143
|
}) {
|
|
144
144
|
let result;
|
|
145
145
|
try {
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
if (i18n) {
|
|
147
|
+
assessment._config.title = i18n.translate(`Axyseo.${assessment._config.id}.title`);
|
|
148
|
+
assessment._config.content = {
|
|
149
|
+
good: i18n.translate(`Axyseo.${assessment._config.id}.good`),
|
|
150
|
+
improve: i18n.translate(`Axyseo.${assessment._config.id}.improve`),
|
|
151
|
+
bad: i18n.translate(`Axyseo.${assessment._config.id}.bad`)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
result = assessment.getResult({
|
|
155
|
+
paper,
|
|
156
|
+
researcher,
|
|
157
|
+
config: this._config,
|
|
158
|
+
i18n
|
|
159
|
+
});
|
|
160
|
+
result.setIdentifier(assessment._config.id);
|
|
148
161
|
} catch (assessmentError) {
|
|
149
162
|
(0, _errors.showTrace)(assessmentError);
|
|
150
163
|
result = new _AssessmentResult.default();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assessor.js","names":["_lodash","require","_AssessmentResult","_interopRequireDefault","_build","_LanguageProcessor","_missingArgument","_errors","e","__esModule","default","ScoreRating","Assessor","constructor","researcher","options","type","setResearcher","_assessments","_options","isUndefined","MissingArgument","_researcher","getAvailableAssessments","isApplicable","assessment","paper","hasOwnProperty","hasMarker","isFunction","marker","getMarks","getSpecificMarker","getPaper","_lastPaper","assess","i18n","setPaper","languageProcessor","LanguageProcessor","shortcodes","_attributes","setTree","build","assessments","results","filter","bind","map","executeAssessment","result","getResult","setIdentifier","identifier","assessmentError","showTrace","AssessmentResult","setScore","getValidResults","isValidResult","assessmentResult","hasScore","hasText","calculateOverallScore","totalScore","reduce","total","getScore","Math","round","length","addAssessment","name","getAssessment","removeAssessment","push","toDelete","findIndex","splice","find","getApplicableAssessments","availableAssessments","availableAssessment","_default","exports"],"sources":["../../../src/scoring/assessors/assessor.js"],"sourcesContent":["// External dependencies.\nimport {filter, find, findIndex, isFunction, isUndefined, map} from 'lodash';\n\n// Internal dependencies.\nimport AssessmentResult from '../../values/AssessmentResult.js';\nimport {build} from '../../parse/build';\nimport LanguageProcessor from '../../parse/language/LanguageProcessor.js';\nimport MissingArgument from '../../errors/missingArgument.js';\nimport {showTrace} from '../../helpers/errors.js';\n\n// The maximum score of individual assessment is 9. This is why we set the \"score rating\" here to 9.\nconst ScoreRating = 9;\n\n/**\n * The Assessor is a base class for all assessors.\n */\nclass Assessor {\n /**\n * Creates a new Assessor instance.\n * @param {Researcher}\tresearcher\tThe researcher to use.\n * @param {Object}\t\t[options]\tThe assessor options.\n */\n constructor(researcher, options) {\n this.type = 'assessor';\n this.setResearcher(researcher);\n this._assessments = [];\n\n this._options = options || {};\n }\n\n /**\n * Checks if the researcher is defined and sets it.\n *\n * @param {Researcher} researcher The researcher to use in the assessor.\n *\n * @throws {MissingArgument} Parameter needs to be a valid researcher object.\n * @returns {void}\n */\n setResearcher(researcher) {\n if (isUndefined(researcher)) {\n throw new MissingArgument('The assessor requires a researcher.');\n }\n this._researcher = researcher;\n }\n\n /**\n * Gets all available assessments.\n * @returns {Assessment[]} assessment\n */\n getAvailableAssessments() {\n return this._assessments;\n }\n\n /**\n * Checks whether the Assessment is applicable.\n *\n * @param {Assessment} assessment The Assessment object that needs to be checked.\n * @param {Paper} paper The Paper object to check against.\n * @param {Researcher} [researcher] The Researcher object containing additional information.\n * @returns {boolean} Whether or not the Assessment is applicable.\n */\n isApplicable(assessment, paper, researcher) {\n if (\n assessment.hasOwnProperty('isApplicable') ||\n typeof assessment.isApplicable === 'function'\n ) {\n return assessment.isApplicable(paper, researcher);\n }\n\n return true;\n }\n\n /**\n * Determines whether an assessment has a marker.\n *\n * @param {Assessment} assessment The assessment to check for.\n * @returns {boolean} Whether or not the assessment has a marker.\n */\n hasMarker(assessment) {\n return (\n isFunction(this._options.marker) &&\n (assessment.hasOwnProperty('getMarks') || typeof assessment.getMarks === 'function')\n );\n }\n\n /**\n * Returns the specific marker for this assessor.\n *\n * @returns {Function} The specific marker for this assessor.\n */\n getSpecificMarker() {\n return this._options.marker;\n }\n\n /**\n * Returns the paper that was most recently assessed.\n *\n * @returns {Paper} The paper that was most recently assessed.\n */\n getPaper() {\n return this._lastPaper;\n }\n\n /**\n * Runs the researches defined in the task list or the default researches.\n *\n * @param {Paper} paper The paper to run assessments on.\n * @param i18n\n * @returns {void}\n */\n assess(paper, i18n) {\n this._researcher.setPaper(paper);\n\n const languageProcessor = new LanguageProcessor(this._researcher);\n const shortcodes = paper._attributes && paper._attributes.shortcodes;\n paper.setTree(build(paper, languageProcessor, shortcodes));\n\n let assessments = this.getAvailableAssessments();\n this.results = [];\n\n assessments = filter(\n assessments,\n function(assessment) {\n return this.isApplicable(assessment, paper, this._researcher);\n }.bind(this)\n );\n\n this.results = map(assessments, assessment =>\n this.executeAssessment({\n paper,\n researcher: this._researcher,\n assessment,\n i18n\n })\n );\n this._lastPaper = paper;\n }\n\n /**\n * Executes an assessment and returns the AssessmentResult.\n *\n * @param {Paper} paper The paper to pass to the assessment.\n * @param {Researcher} researcher The researcher to pass to the assessment.\n * @param {Assessment} assessment The assessment to execute.\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment.\n */\n executeAssessment({paper, researcher, assessment, i18n}) {\n let result;\n\n try {\n result = assessment.getResult(paper, researcher, i18n);\n result.setIdentifier(assessment.identifier);\n } catch (assessmentError) {\n showTrace(assessmentError);\n\n result = new AssessmentResult();\n\n result.setScore(-1);\n }\n return result;\n }\n\n /**\n * Filters out all assessment results that have no score and no text.\n *\n * @returns {AssessmentResult[]} The array with all the valid assessments.\n */\n getValidResults() {\n return filter(\n this.results,\n function(result) {\n return this.isValidResult(result);\n }.bind(this)\n );\n }\n\n /**\n * Returns if an assessmentResult is valid.\n *\n * @param {AssessmentResult} assessmentResult The assessmentResult to validate.\n * @returns {boolean} whether or not the result is valid.\n */\n isValidResult(assessmentResult) {\n return assessmentResult.hasScore() && assessmentResult.hasText();\n }\n\n /**\n * Returns the overall score. Calculates the total score by adding all scores and dividing these\n * by the number of results times the ScoreRating.\n *\n * @returns {number} The overall score.\n */\n calculateOverallScore() {\n const results = this.getValidResults();\n\n const totalScore = results.reduce(\n (total, assessmentResult) => total + assessmentResult.getScore(),\n 0\n );\n\n return Math.round((totalScore / (results.length * ScoreRating)) * 100) || 0;\n }\n\n /**\n * Registers an assessment and adds it to the internal assessments object.\n *\n * @param {string} name The name of the assessment.\n * @param {Assessment} assessment The object containing function to run as an assessment and it's requirements.\n * @returns {boolean} Whether registering the assessment was successful.\n */\n addAssessment(name, assessment) {\n if (!assessment.hasOwnProperty('identifier')) {\n assessment.identifier = name;\n }\n // If the assessor already has the same assessment, remove it and replace it with the new assessment with the same identifier.\n if (this.getAssessment(assessment.identifier)) {\n this.removeAssessment(assessment.identifier);\n }\n\n this._assessments.push(assessment);\n return true;\n }\n\n /**\n * Removes a specific Assessment from the list of Assessments.\n *\n * @param {string} name The Assessment to remove from the list of assessments.\n * @returns {void}\n */\n removeAssessment(name) {\n const toDelete = findIndex(this._assessments, function(assessment) {\n return assessment.hasOwnProperty('identifier') && name === assessment.identifier;\n });\n\n if (-1 !== toDelete) {\n this._assessments.splice(toDelete, 1);\n }\n }\n\n /**\n * Returns an assessment by identifier\n *\n * @param {string} identifier The identifier of the assessment.\n * @returns {undefined|Assessment} The object if found, otherwise undefined.\n */\n getAssessment(identifier) {\n return find(this._assessments, function(assessment) {\n return assessment.hasOwnProperty('identifier') && identifier === assessment.identifier;\n });\n }\n\n /**\n * Checks which of the available assessments are applicable and returns an array with applicable assessments.\n *\n * @returns {Assessment[]} The array with applicable assessments.\n */\n getApplicableAssessments() {\n const availableAssessments = this.getAvailableAssessments();\n return filter(\n availableAssessments,\n function(availableAssessment) {\n return this.isApplicable(availableAssessment, this.getPaper(), this._researcher);\n }.bind(this)\n );\n }\n}\n\nexport default Assessor;\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,gBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAAkD,SAAAE,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AARlD;;AAGA;;AAOA;AACA,MAAMG,WAAW,GAAG,CAAC;;AAErB;AACA;AACA;AACA,MAAMC,QAAQ,CAAC;EACb;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACC,UAAU,EAAEC,OAAO,EAAE;IAC/B,IAAI,CAACC,IAAI,GAAG,UAAU;IACtB,IAAI,CAACC,aAAa,CAACH,UAAU,CAAC;IA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interopRequireDefault","_build","_LanguageProcessor","_missingArgument","_errors","e","__esModule","default","ScoreRating","Assessor","constructor","researcher","config","type","setResearcher","_assessments","_config","isUndefined","MissingArgument","_researcher","getAvailableAssessments","isApplicable","assessment","paper","hasOwnProperty","hasMarker","isFunction","marker","getMarks","getSpecificMarker","getPaper","_lastPaper","assess","i18n","setPaper","languageProcessor","LanguageProcessor","shortcodes","_attributes","setTree","build","assessments","results","filter","bind","map","executeAssessment","result","title","translate","id","content","good","improve","bad","getResult","setIdentifier","assessmentError","showTrace","AssessmentResult","setScore","getValidResults","isValidResult","assessmentResult","hasScore","hasText","calculateOverallScore","totalScore","reduce","total","getScore","Math","round","length","addAssessment","name","identifier","getAssessment","removeAssessment","push","toDelete","findIndex","splice","find","getApplicableAssessments","availableAssessments","availableAssessment","_default","exports"],"sources":["../../../src/scoring/assessors/assessor.js"],"sourcesContent":["// External dependencies.\nimport {filter, find, findIndex, isFunction, isUndefined, map} from 'lodash';\n\n// Internal dependencies.\nimport AssessmentResult from '../../values/AssessmentResult.js';\nimport {build} from '../../parse/build';\nimport LanguageProcessor from '../../parse/language/LanguageProcessor.js';\nimport MissingArgument from '../../errors/missingArgument.js';\nimport {showTrace} from '../../helpers/errors.js';\n\n// The maximum score of individual assessment is 9. This is why we set the \"score rating\" here to 9.\nconst ScoreRating = 9;\n\n/**\n * The Assessor is a base class for all assessors.\n */\nclass Assessor {\n /**\n * Creates a new Assessor instance.\n * @param {Researcher}\tresearcher\tThe researcher to use.\n * @param {Object}\t\t[config]\tThe assessor config.\n */\n constructor(researcher, config) {\n this.type = 'assessor';\n this.setResearcher(researcher);\n this._assessments = [];\n\n this._config = config || {};\n }\n\n /**\n * Checks if the researcher is defined and sets it.\n *\n * @param {Researcher} researcher The researcher to use in the assessor.\n *\n * @throws {MissingArgument} Parameter needs to be a valid researcher object.\n * @returns {void}\n */\n setResearcher(researcher) {\n if (isUndefined(researcher)) {\n throw new MissingArgument('The assessor requires a researcher.');\n }\n this._researcher = researcher;\n }\n\n /**\n * Gets all available assessments.\n * @returns {Assessment[]} assessment\n */\n getAvailableAssessments() {\n return this._assessments;\n }\n\n /**\n * Checks whether the Assessment is applicable.\n *\n * @param {Assessment} assessment The Assessment object that needs to be checked.\n * @param {Paper} paper The Paper object to check against.\n * @param {Researcher} [researcher] The Researcher object containing additional information.\n * @returns {boolean} Whether or not the Assessment is applicable.\n */\n isApplicable(assessment, paper, researcher) {\n if (\n assessment.hasOwnProperty('isApplicable') ||\n typeof assessment.isApplicable === 'function'\n ) {\n return assessment.isApplicable(paper, researcher);\n }\n\n return true;\n }\n\n /**\n * Determines whether an assessment has a marker.\n *\n * @param {Assessment} assessment The assessment to check for.\n * @returns {boolean} Whether or not the assessment has a marker.\n */\n hasMarker(assessment) {\n return (\n isFunction(this._config.marker) &&\n (assessment.hasOwnProperty('getMarks') || typeof assessment.getMarks === 'function')\n );\n }\n\n /**\n * Returns the specific marker for this assessor.\n *\n * @returns {Function} The specific marker for this assessor.\n */\n getSpecificMarker() {\n return this._config.marker;\n }\n\n /**\n * Returns the paper that was most recently assessed.\n *\n * @returns {Paper} The paper that was most recently assessed.\n */\n getPaper() {\n return this._lastPaper;\n }\n\n /**\n * Runs the researches defined in the task list or the default researches.\n *\n * @param {Paper} paper The paper to run assessments on.\n * @param i18n\n * @returns {void}\n */\n assess(paper, i18n) {\n this._researcher.setPaper(paper);\n\n const languageProcessor = new LanguageProcessor(this._researcher);\n const shortcodes = paper._attributes && paper._attributes.shortcodes;\n paper.setTree(build(paper, languageProcessor, shortcodes));\n\n let assessments = this.getAvailableAssessments();\n this.results = [];\n\n assessments = filter(\n assessments,\n function(assessment) {\n return this.isApplicable(assessment, paper, this._researcher);\n }.bind(this)\n );\n\n this.results = map(assessments, assessment =>\n this.executeAssessment({\n paper,\n researcher: this._researcher,\n assessment,\n i18n\n })\n );\n this._lastPaper = paper;\n }\n\n /**\n * Executes an assessment and returns the AssessmentResult.\n *\n * @param {Paper} paper The paper to pass to the assessment.\n * @param {Researcher} researcher The researcher to pass to the assessment.\n * @param {Assessment} assessment The assessment to execute.\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment.\n */\n executeAssessment({paper, researcher, assessment, i18n}) {\n let result;\n\n try {\n if (i18n) {\n assessment._config.title = i18n.translate(`Axyseo.${assessment._config.id}.title`);\n assessment._config.content = {\n good: i18n.translate(`Axyseo.${assessment._config.id}.good`),\n improve: i18n.translate(`Axyseo.${assessment._config.id}.improve`),\n bad: i18n.translate(`Axyseo.${assessment._config.id}.bad`)\n };\n }\n result = assessment.getResult({paper, researcher, config: this._config, i18n});\n result.setIdentifier(assessment._config.id);\n } catch (assessmentError) {\n showTrace(assessmentError);\n\n result = new AssessmentResult();\n\n result.setScore(-1);\n }\n return result;\n }\n\n /**\n * Filters out all assessment results that have no score and no text.\n *\n * @returns {AssessmentResult[]} The array with all the valid assessments.\n */\n getValidResults() {\n return filter(\n this.results,\n function(result) {\n return this.isValidResult(result);\n }.bind(this)\n );\n }\n\n /**\n * Returns if an assessmentResult is valid.\n *\n * @param {AssessmentResult} assessmentResult The assessmentResult to validate.\n * @returns {boolean} whether or not the result is valid.\n */\n isValidResult(assessmentResult) {\n return assessmentResult.hasScore() && assessmentResult.hasText();\n }\n\n /**\n * Returns the overall score. Calculates the total score by adding all scores and dividing these\n * by the number of results times the ScoreRating.\n *\n * @returns {number} The overall score.\n */\n calculateOverallScore() {\n const results = this.getValidResults();\n\n const totalScore = results.reduce(\n (total, assessmentResult) => total + assessmentResult.getScore(),\n 0\n );\n\n return Math.round((totalScore / (results.length * ScoreRating)) * 100) || 0;\n }\n\n /**\n * Registers an assessment and adds it to the internal assessments object.\n *\n * @param {string} name The name of the assessment.\n * @param {Assessment} assessment The object containing function to run as an assessment and it's requirements.\n * @returns {boolean} Whether registering the assessment was successful.\n */\n addAssessment(name, assessment) {\n if (!assessment.hasOwnProperty('identifier')) {\n assessment.identifier = name;\n }\n // If the assessor already has the same assessment, remove it and replace it with the new assessment with the same identifier.\n if (this.getAssessment(assessment.identifier)) {\n this.removeAssessment(assessment.identifier);\n }\n\n this._assessments.push(assessment);\n return true;\n }\n\n /**\n * Removes a specific Assessment from the list of Assessments.\n *\n * @param {string} name The Assessment to remove from the list of assessments.\n * @returns {void}\n */\n removeAssessment(name) {\n const toDelete = findIndex(this._assessments, function(assessment) {\n return assessment.hasOwnProperty('identifier') && name === assessment.identifier;\n });\n\n if (-1 !== toDelete) {\n this._assessments.splice(toDelete, 1);\n }\n }\n\n /**\n * Returns an assessment by identifier\n *\n * @param {string} identifier The identifier of the assessment.\n * @returns {undefined|Assessment} The object if found, otherwise undefined.\n */\n getAssessment(identifier) {\n return find(this._assessments, function(assessment) {\n return assessment.hasOwnProperty('identifier') && identifier === assessment.identifier;\n });\n }\n\n /**\n * Checks which of the available assessments are applicable and returns an array with applicable assessments.\n *\n * @returns {Assessment[]} The array with applicable assessments.\n */\n getApplicableAssessments() {\n const availableAssessments = this.getAvailableAssessments();\n return filter(\n availableAssessments,\n function(availableAssessment) {\n return this.isApplicable(availableAssessment, this.getPaper(), this._researcher);\n }.bind(this)\n );\n }\n}\n\nexport default Assessor;\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,gBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAAkD,SAAAE,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AARlD;;AAGA;;AAOA;AACA,MAAMG,WAAW,GAAG,CAAC;;AAErB;AACA;AACA;AACA,MAAMC,QAAQ,CAAC;EACb;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACC,UAAU,EAAEC,MAAM,EAAE;IAC9B,IAAI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AE;MAClD,OAAOA,UAAU,CAACE,cAAc,CAAC,YAAY,CAAC,IAAIoD,UAAU,KAAKtD,UAAU,CAACsD,UAAU;IACxF,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;EACEQ,wBAAwBA,CAAA,EAAG;IACzB,MAAMC,oBAAoB,GAAG,IAAI,CAACjE,uBAAuB,CAAC,CAAC;IAC3D,OAAO,IAAAuB,cAAM,EACX0C,oBAAoB,EACpB,UAASC,mBAAmB,EAAE;MAC5B,OAAO,IAAI,CAACjE,YAAY,CAACiE,mBAAmB,EAAE,IAAI,CAACxD,QAAQ,CAAC,CAAC,EAAE,IAAI,CAACX,WAAW,CAAC;IAClF,CAAC,CAACyB,IAAI,CAAC,IAAI,CACb,CAAC;EACH;AACF;AAAC,IAAA2C,QAAA,GAAAC,OAAA,CAAAjF,OAAA,GAEcE,QAAQ","ignoreList":[]}
|
|
@@ -13,14 +13,15 @@ class AvadaAssessor {
|
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new AvadaAssessor instance.
|
|
15
15
|
* @param {Researcher} researcher The researcher to use.
|
|
16
|
-
* @param {Object} [
|
|
16
|
+
* @param {Object} [config] The assessor config.
|
|
17
17
|
*/
|
|
18
|
-
constructor(researcher,
|
|
19
|
-
const seoAssessor = new _index.SEOAssessor(researcher,
|
|
20
|
-
const contentAssessor = new _index.ContentAssessor(researcher,
|
|
18
|
+
constructor(researcher, config) {
|
|
19
|
+
const seoAssessor = new _index.SEOAssessor(researcher, config);
|
|
20
|
+
const contentAssessor = new _index.ContentAssessor(researcher, config);
|
|
21
21
|
this.seoAssessor = seoAssessor;
|
|
22
22
|
this.contentAssessor = contentAssessor;
|
|
23
23
|
this.researcher = researcher;
|
|
24
|
+
this.config = config;
|
|
24
25
|
}
|
|
25
26
|
assess(paper, i18n) {
|
|
26
27
|
this.seoAssessor.assess(paper, i18n);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avadaAssessor.js","names":["_index","require","_helpers","AvadaAssessor","constructor","researcher","
|
|
1
|
+
{"version":3,"file":"avadaAssessor.js","names":["_index","require","_helpers","AvadaAssessor","constructor","researcher","config","seoAssessor","SEOAssessor","contentAssessor","ContentAssessor","assess","paper","i18n","assessments","results","map","assessment","body","status","score","title","getResult","groupBy","getScore","groupAssessmentsByCategory","groupAssessmentsByStatus","point","forEach","maxPoint","getMaxPoint","Math","round","exports","default"],"sources":["../../../src/scoring/assessors/avadaAssessor.js"],"sourcesContent":["import {ContentAssessor, SEOAssessor} from '@axyseo/scoring/assessors/index';\nimport {getMaxPoint, groupAssessmentsByCategory, groupAssessmentsByStatus} from '../helpers';\n\n/**\n * The AvadaAssessor class is used for the general SEO analysis.\n */\nexport default class AvadaAssessor {\n /**\n * Creates a new AvadaAssessor instance.\n * @param {Researcher} researcher The researcher to use.\n * @param {Object} [config] The assessor config.\n */\n constructor(researcher, config) {\n const seoAssessor = new SEOAssessor(researcher, config);\n const contentAssessor = new ContentAssessor(researcher, config);\n this.seoAssessor = seoAssessor;\n this.contentAssessor = contentAssessor;\n this.researcher = researcher;\n this.config = config;\n }\n\n assess(paper, i18n) {\n this.seoAssessor.assess(paper, i18n);\n this.contentAssessor.assess(paper, i18n);\n\n let assessments = [...this.seoAssessor.results, ...this.contentAssessor.results];\n assessments = assessments.map(assessment => ({\n ...assessment.config,\n body: assessment.body,\n status: assessment.status,\n score: assessment.score,\n title: assessment.title || assessment.config.title\n }));\n this.assessments = assessments;\n }\n\n getResult(groupBy = 'category', getScore = true) {\n let assessments = [];\n switch (groupBy) {\n case 'category':\n assessments = groupAssessmentsByCategory(this.assessments);\n break;\n case 'status':\n assessments = groupAssessmentsByStatus(this.assessments);\n break;\n }\n\n return {\n assessments,\n ...(getScore ? {score: this.getScore()} : {})\n };\n }\n\n getScore() {\n let point = 0;\n\n this.assessments.forEach(assessment => {\n point += assessment.score;\n });\n\n const maxPoint = getMaxPoint(this.assessments);\n return Math.round((point * 100) / maxPoint);\n }\n}\n"],"mappings":";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QAAQS,OAAO;MACb,KAAK,UAAU;QACbT,WAAW,GAAG,IAAAW,mCAA0B,EAAC,IAAI,CAACX,WAAW,CAAC;QAC1D;MACF,KAAK,QAAQ;QACXA,WAAW,GAAG,IAAAY,iCAAwB,EAAC,IAAI,CAACZ,WAAW,CAAC;QACxD;IACJ;IAEA,OAAO;MACLA,WAAW;MACX,IAAIU,QAAQ,GAAG;QAACJ,KAAK,EAAE,IAAI,CAACI,QAAQ,CAAC;MAAC,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;EACH;EAEAA,QAAQA,CAAA,EAAG;IACT,IAAIG,KAAK,GAAG,CAAC;IAEb,IAAI,CAACb,WAAW,CAACc,OAAO,CAACX,UAAU,IAAI;MACrCU,KAAK,IAAIV,UAAU,CAACG,KAAK;IAC3B,CAAC,CAAC;IAEF,MAAMS,QAAQ,GAAG,IAAAC,oBAAW,EAAC,IAAI,CAAChB,WAAW,CAAC;IAC9C,OAAOiB,IAAI,CAACC,KAAK,CAAEL,KAAK,GAAG,GAAG,GAAIE,QAAQ,CAAC;EAC7C;AACF;AAACI,OAAA,CAAAC,OAAA,GAAA/B,aAAA","ignoreList":[]}
|
|
@@ -19,10 +19,10 @@ class ContentAssessor extends _assessor.default {
|
|
|
19
19
|
/**
|
|
20
20
|
* Creates a new ContentAssessor instance.
|
|
21
21
|
* @param {Researcher} researcher The researcher to use.
|
|
22
|
-
* @param {Object} [
|
|
22
|
+
* @param {Object} [config] The assessor config.
|
|
23
23
|
*/
|
|
24
|
-
constructor(researcher,
|
|
25
|
-
super(researcher,
|
|
24
|
+
constructor(researcher, config) {
|
|
25
|
+
super(researcher, config);
|
|
26
26
|
this.type = 'contentAssessor';
|
|
27
27
|
this._assessments = [new _ParagraphTooLongAssessment.default(), new _SentenceLengthInTextAssessment.default(), new _TransitionWordsAssessment.default(), new _SentenceBeginningsAssessment.default()];
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentAssessor.js","names":["_lodash","require","_assessor","_interopRequireDefault","_ParagraphTooLongAssessment","_SentenceLengthInTextAssessment","_SentenceBeginningsAssessment","_TransitionWordsAssessment","_scoreToRating","e","__esModule","default","ContentAssessor","Assessor","constructor","researcher","
|
|
1
|
+
{"version":3,"file":"contentAssessor.js","names":["_lodash","require","_assessor","_interopRequireDefault","_ParagraphTooLongAssessment","_SentenceLengthInTextAssessment","_SentenceBeginningsAssessment","_TransitionWordsAssessment","_scoreToRating","e","__esModule","default","ContentAssessor","Assessor","constructor","researcher","config","type","_assessments","ParagraphTooLong","SentenceLengthInText","TransitionWords","SentenceBeginnings","calculatePenaltyPointsFullSupport","rating","calculatePenaltyPointsPartialSupport","_allAssessmentsSupported","numberOfAssessments","length","applicableAssessments","getApplicableAssessments","calculatePenaltyPoints","results","getValidResults","penaltyPoints","map","result","scoreToRating","getScore","bind","sum","_ratePenaltyPoints","totalPenaltyPoints","calculateOverallScore","exports"],"sources":["../../../src/scoring/assessors/contentAssessor.js"],"sourcesContent":["import {map, sum} from 'lodash';\nimport Assessor from './assessor.js';\nimport ParagraphTooLong from '../assessments/readability/ParagraphTooLongAssessment.js';\nimport SentenceLengthInText from '../assessments/readability/SentenceLengthInTextAssessment.js';\nimport SentenceBeginnings from '../assessments/readability/SentenceBeginningsAssessment.js';\nimport TransitionWords from '../assessments/readability/TransitionWordsAssessment.js';\nimport scoreToRating from '../interpreters/scoreToRating.js';\n\n/**\n * The ContentAssessor class is used for the readability analysis.\n */\nexport default class ContentAssessor extends Assessor {\n /**\n * Creates a new ContentAssessor instance.\n * @param {Researcher}\tresearcher\tThe researcher to use.\n * @param {Object}\t\t[config]\tThe assessor config.\n */\n constructor(researcher, config) {\n super(researcher, config);\n this.type = 'contentAssessor';\n\n this._assessments = [\n new ParagraphTooLong(),\n new SentenceLengthInText(),\n new TransitionWords(),\n new SentenceBeginnings()\n ];\n }\n\n /**\n * Calculates the weighted rating for languages that have all assessments based on a given rating.\n *\n * @param {string} rating The rating to be weighted.\n * @returns {number} The weighted rating.\n */\n calculatePenaltyPointsFullSupport(rating) {\n switch (rating) {\n case 'bad':\n return 3;\n case 'ok':\n return 2;\n default:\n case 'good':\n return 0;\n }\n }\n\n /**\n * Calculates the weighted rating for languages that don't have all assessments based on a given rating.\n *\n * @param {string} rating The rating to be weighted.\n * @returns {number} The weighted rating.\n */\n calculatePenaltyPointsPartialSupport(rating) {\n switch (rating) {\n case 'bad':\n return 4;\n case 'ok':\n return 2;\n default:\n case 'good':\n return 0;\n }\n }\n\n /**\n * Determines whether a language is fully supported. If a language supports 7 content assessments,\n * it is fully supported\n *\n * @returns {boolean} True if fully supported.\n */\n _allAssessmentsSupported() {\n const numberOfAssessments = this._assessments.length;\n const applicableAssessments = this.getApplicableAssessments();\n return applicableAssessments.length === numberOfAssessments;\n }\n\n /**\n * Calculates the penalty points based on the assessment results.\n *\n * @returns {number} The total penalty points for the results.\n */\n calculatePenaltyPoints() {\n const results = this.getValidResults();\n\n const penaltyPoints = map(\n results,\n function(result) {\n const rating = scoreToRating(result.getScore());\n\n if (this._allAssessmentsSupported()) {\n return this.calculatePenaltyPointsFullSupport(rating);\n }\n\n return this.calculatePenaltyPointsPartialSupport(rating);\n }.bind(this)\n );\n\n return sum(penaltyPoints);\n }\n\n /**\n * Rates the penalty points\n *\n * @param {number} totalPenaltyPoints The amount of penalty points.\n * @returns {number} The score based on the amount of penalty points.\n *\n * @private\n */\n _ratePenaltyPoints(totalPenaltyPoints) {\n if (this.getValidResults().length === 1) {\n // If we have only 1 result, we only have a \"no content\" result\n return 30;\n }\n\n if (this._allAssessmentsSupported()) {\n // Determine the total score based on the total penalty points.\n if (totalPenaltyPoints > 6) {\n // A red indicator.\n return 30;\n }\n\n if (totalPenaltyPoints > 4) {\n // An orange indicator.\n return 60;\n }\n } else {\n if (totalPenaltyPoints > 4) {\n // A red indicator.\n return 30;\n }\n\n if (totalPenaltyPoints > 2) {\n // An orange indicator.\n return 60;\n }\n }\n // A green indicator.\n return 90;\n }\n\n /**\n * Calculates the overall score based on the assessment results.\n *\n * @returns {number} The overall score.\n */\n calculateOverallScore() {\n const results = this.getValidResults();\n\n // If you have no content, you have a red indicator.\n if (results.length === 0) {\n return 30;\n }\n\n const totalPenaltyPoints = this.calculatePenaltyPoints();\n\n return this._ratePenaltyPoints(totalPenaltyPoints);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,+BAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,6BAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,0BAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,cAAA,GAAAL,sBAAA,CAAAF,OAAA;AAA6D,SAAAE,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7D;AACA;AACA;AACe,MAAMG,eAAe,SAASC,iBAAQ,CAAC;EACpD;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACC,UAAU,EAAEC,MAAM,EAAE;IAC9B,KAAK,CAACD,UAAU,EAAEC,MAAM,CAAC;IACzB,IAAI,CAACC,IAAI,GAAG,iBAAiB;IAE7B,IAAI,CAACC,YAAY,GAAG,CAClB,IAAIC,mCAAgB,CAAC,CAAC,EACtB,IAAIC,uCAAoB,CAAC,CAAC,EAC1B,IAAIC,kCAAe,CAAC,CAAC,EACrB,IAAIC,qCAAkB,CAAC,CAAC,CACzB;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEC,iCAAiCA,CAACC,MAAM,EAAE;IACxC,QAAQA,MAAM;MACZ,KAAK,KAAK;QACR,OAAO,CAAC;MACV,KAAK,IAAI;QACP,OAAO,CAAC;MACV;MACA,KAAK,MAAM;QACT,OAAO,CAAC;IACZ;EACF;;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AE;QAC1B;QACA,OAAO,EAAE;MACX;MAEA,IAAIA,kBAAkB,GAAG,CAAC,EAAE;QAC1B;QACA,OAAO,EAAE;MACX;IACF,CAAC,MAAM;MACL,IAAIA,kBAAkB,GAAG,CAAC,EAAE;QAC1B;QACA,OAAO,EAAE;MACX;MAEA,IAAIA,kBAAkB,GAAG,CAAC,EAAE;QAC1B;QACA,OAAO,EAAE;MACX;IACF;IACA;IACA,OAAO,EAAE;EACX;;EAEA;AACF;AACA;AACA;AACA;EACEC,qBAAqBA,CAAA,EAAG;IACtB,MAAMX,OAAO,GAAG,IAAI,CAACC,eAAe,CAAC,CAAC;;IAEtC;IACA,IAAID,OAAO,CAACJ,MAAM,KAAK,CAAC,EAAE;MACxB,OAAO,EAAE;IACX;IAEA,MAAMc,kBAAkB,GAAG,IAAI,CAACX,sBAAsB,CAAC,CAAC;IAExD,OAAO,IAAI,CAACU,kBAAkB,CAACC,kBAAkB,CAAC;EACpD;AACF;AAACE,OAAA,CAAAjC,OAAA,GAAAC,eAAA","ignoreList":[]}
|
|
@@ -32,10 +32,10 @@ class SEOAssessor extends _assessor.default {
|
|
|
32
32
|
/**
|
|
33
33
|
* Creates a new SEOAssessor instance.
|
|
34
34
|
* @param {Researcher} researcher The researcher to use.
|
|
35
|
-
* @param {Object} [
|
|
35
|
+
* @param {Object} [config] The assessor config.
|
|
36
36
|
*/
|
|
37
|
-
constructor(researcher,
|
|
38
|
-
super(researcher,
|
|
37
|
+
constructor(researcher, config) {
|
|
38
|
+
super(researcher, config);
|
|
39
39
|
this.type = 'SEOAssessor';
|
|
40
40
|
this._assessments = [new _MetaTitleKeywordAssessment.default(), new _TextImagesAssessment.default(), new _NumberInMetaTitleAssessment.default(), new _IntroductionKeywordAssessment.default(), new _KeyphraseLengthAssessment.default(), new _MetaDescriptionKeywordAssessment.default(), new _MetaDescriptionLengthAssessment.default(), new _SubHeadingsKeywordAssessment.default(), new _OutboundLinksAssessment.default(), new _KeywordDensityAssessment.default(), new _ImageCountAssessment.default(), new _UrlLengthAssessment.default(), new _TextLengthAssessment.default(), new _SingleTitleAssessment.default(), new _KeyphraseAssessment.default(), new _InternalLinksAssessment.default(), new _PageTitleWidthAssessment.default(), new _UrlKeywordAssessment.default(), new _SingleH1Assessment.default()];
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seoAssessor.js","names":["_assessor","_interopRequireDefault","require","_IntroductionKeywordAssessment","_KeyphraseLengthAssessment","_MetaDescriptionKeywordAssessment","_MetaDescriptionLengthAssessment","_SubHeadingsKeywordAssessment","_OutboundLinksAssessment","_KeywordDensityAssessment","_InternalLinksAssessment","_UrlKeywordAssessment","_ImageCountAssessment","_TextLengthAssessment","_PageTitleWidthAssessment","_SingleH1Assessment","_KeyphraseAssessment","_SingleTitleAssessment","_UrlLengthAssessment","_NumberInMetaTitleAssessment","_TextImagesAssessment","_MetaTitleKeywordAssessment","e","__esModule","default","SEOAssessor","Assessor","constructor","researcher","
|
|
1
|
+
{"version":3,"file":"seoAssessor.js","names":["_assessor","_interopRequireDefault","require","_IntroductionKeywordAssessment","_KeyphraseLengthAssessment","_MetaDescriptionKeywordAssessment","_MetaDescriptionLengthAssessment","_SubHeadingsKeywordAssessment","_OutboundLinksAssessment","_KeywordDensityAssessment","_InternalLinksAssessment","_UrlKeywordAssessment","_ImageCountAssessment","_TextLengthAssessment","_PageTitleWidthAssessment","_SingleH1Assessment","_KeyphraseAssessment","_SingleTitleAssessment","_UrlLengthAssessment","_NumberInMetaTitleAssessment","_TextImagesAssessment","_MetaTitleKeywordAssessment","e","__esModule","default","SEOAssessor","Assessor","constructor","researcher","config","type","_assessments","MetaTitleKeywordAssessment","TextImagesAssessment","NumberInMetaTitleAssessment","IntroductionKeywordAssessment","KeyphraseLengthAssessment","MetaDescriptionKeywordAssessment","MetaDescriptionLength","SubheadingsKeyword","OutboundLinks","KeyphraseDensityAssessment","ImageCount","UrlLengthAssessment","TextLength","SingleTitleAssessment","KeyphraseAssessment","InternalLinksAssessment","TitleWidth","SlugKeywordAssessment","SingleH1Assessment","exports"],"sources":["../../../src/scoring/assessors/seoAssessor.js"],"sourcesContent":["import Assessor from './assessor';\nimport IntroductionKeywordAssessment from '../assessments/seo/IntroductionKeywordAssessment';\nimport KeyphraseLengthAssessment from '../assessments/seo/KeyphraseLengthAssessment';\nimport MetaDescriptionKeywordAssessment from '../assessments/seo/MetaDescriptionKeywordAssessment';\nimport MetaDescriptionLength from '../assessments/seo/MetaDescriptionLengthAssessment';\nimport SubheadingsKeyword from '../assessments/seo/SubHeadingsKeywordAssessment';\nimport OutboundLinks from '../assessments/seo/OutboundLinksAssessment';\nimport KeyphraseDensityAssessment from '../assessments/seo/KeywordDensityAssessment';\nimport InternalLinksAssessment from '../assessments/seo/InternalLinksAssessment';\nimport SlugKeywordAssessment from '../assessments/seo/UrlKeywordAssessment';\nimport ImageCount from '../assessments/seo/ImageCountAssessment';\nimport TextLength from '../assessments/seo/TextLengthAssessment';\nimport TitleWidth from '../assessments/seo/PageTitleWidthAssessment';\nimport SingleH1Assessment from '../assessments/seo/SingleH1Assessment';\nimport KeyphraseAssessment from '../assessments/seo/KeyphraseAssessment';\nimport SingleTitleAssessment from '../assessments/seo/SingleTitleAssessment';\nimport UrlLengthAssessment from '../assessments/seo/UrlLengthAssessment';\nimport NumberInMetaTitleAssessment from '../assessments/seo/NumberInMetaTitleAssessment';\nimport TextImagesAssessment from '../assessments/seo/TextImagesAssessment';\nimport MetaTitleKeywordAssessment from '../assessments/seo/MetaTitleKeywordAssessment';\n\n/**\n * The SEOAssessor class is used for the general SEO analysis.\n */\nexport default class SEOAssessor extends Assessor {\n /**\n * Creates a new SEOAssessor instance.\n * @param {Researcher}\tresearcher\tThe researcher to use.\n * @param {Object}\t\t[config]\tThe assessor config.\n */\n constructor(researcher, config) {\n super(researcher, config);\n this.type = 'SEOAssessor';\n\n this._assessments = [\n new MetaTitleKeywordAssessment(),\n new TextImagesAssessment(),\n new NumberInMetaTitleAssessment(),\n new IntroductionKeywordAssessment(),\n new KeyphraseLengthAssessment(),\n new MetaDescriptionKeywordAssessment(),\n new MetaDescriptionLength(),\n new SubheadingsKeyword(),\n new OutboundLinks(),\n new KeyphraseDensityAssessment(),\n new ImageCount(),\n new UrlLengthAssessment(),\n new TextLength(),\n new SingleTitleAssessment(),\n new KeyphraseAssessment(),\n new InternalLinksAssessment(),\n new TitleWidth(),\n new SlugKeywordAssessment(),\n new SingleH1Assessment()\n ];\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,8BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,0BAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,iCAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,gCAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,6BAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,wBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,yBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,wBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,qBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,qBAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,qBAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,yBAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,mBAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,oBAAA,GAAAf,sBAAA,CAAAC,OAAA;AACA,IAAAe,sBAAA,GAAAhB,sBAAA,CAAAC,OAAA;AACA,IAAAgB,oBAAA,GAAAjB,sBAAA,CAAAC,OAAA;AACA,IAAAiB,4BAAA,GAAAlB,sBAAA,CAAAC,OAAA;AACA,IAAAkB,qBAAA,GAAAnB,sBAAA,CAAAC,OAAA;AACA,IAA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