axyseo 2.0.0-alpha.0.0.54 → 2.0.0-alpha.0.0.56

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.
@@ -15,16 +15,17 @@ import { filterShortcodesFromHTML } from "../helpers";
15
15
  *
16
16
  * @param {Paper} paper The Paper object.
17
17
  *
18
+ * @param value
18
19
  * @returns {WordCountResult} The number of words found in the text, plus "word" as the unit used in calculating the text length.
19
20
  */
20
- export default function (paper) {
21
- let text = paper.getText();
21
+ export default function (paper, value = null) {
22
+ let text = typeof value === 'string' ? value : paper.getText();
22
23
  text = removeHtmlBlocks(text);
23
- text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);
24
+ text = filterShortcodesFromHTML(text, paper?._attributes && paper._attributes.shortcodes);
24
25
  return {
25
26
  text: text,
26
27
  count: wordCount(text),
27
- unit: "word"
28
+ unit: 'word'
28
29
  };
29
30
  }
30
31
  //# sourceMappingURL=wordCountInText.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wordCountInText.js","names":["wordCount","removeHtmlBlocks","filterShortcodesFromHTML","paper","text","getText","_attributes","shortcodes","count","unit"],"sources":["../../../src/languageProcessing/researches/wordCountInText.js"],"sourcesContent":["import wordCount from \"../helpers/word/countWords.js\";\nimport removeHtmlBlocks from \"../helpers/html/htmlParser\";\nimport { filterShortcodesFromHTML } from \"../helpers\";\n\n/**\n * A result of the word count calculation.\n *\n * @typedef WordCountResult\n * @param {number} count The number of words found in the text.\n * @param {\"word\"} unit The unit used in the text length calculations, always \"word\".\n */\n\n/**\n * Count the words in the text.\n *\n * @param {Paper} paper The Paper object.\n *\n * @returns {WordCountResult} The number of words found in the text, plus \"word\" as the unit used in calculating the text length.\n */\nexport default function( paper ) {\n\tlet text = paper.getText();\n\ttext = removeHtmlBlocks( text );\n\ttext = filterShortcodesFromHTML( text, paper._attributes && paper._attributes.shortcodes );\n\treturn {\n\t\ttext: text,\n\t\tcount: wordCount( text ),\n\t\tunit: \"word\",\n\t};\n}\n"],"mappings":"AAAA,OAAOA,SAAS;AAChB,OAAOC,gBAAgB;AACvB,SAASC,wBAAwB;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,UAAUC,KAAK,EAAG;EAChC,IAAIC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAAC,CAAC;EAC1BD,IAAI,GAAGH,gBAAgB,CAAEG,IAAK,CAAC;EAC/BA,IAAI,GAAGF,wBAAwB,CAAEE,IAAI,EAAED,KAAK,CAACG,WAAW,IAAIH,KAAK,CAACG,WAAW,CAACC,UAAW,CAAC;EAC1F,OAAO;IACNH,IAAI,EAAEA,IAAI;IACVI,KAAK,EAAER,SAAS,CAAEI,IAAK,CAAC;IACxBK,IAAI,EAAE;EACP,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"file":"wordCountInText.js","names":["wordCount","removeHtmlBlocks","filterShortcodesFromHTML","paper","value","text","getText","_attributes","shortcodes","count","unit"],"sources":["../../../src/languageProcessing/researches/wordCountInText.js"],"sourcesContent":["import wordCount from '../helpers/word/countWords.js';\nimport removeHtmlBlocks from '../helpers/html/htmlParser';\nimport {filterShortcodesFromHTML} from '../helpers';\n\n/**\n * A result of the word count calculation.\n *\n * @typedef WordCountResult\n * @param {number} count The number of words found in the text.\n * @param {\"word\"} unit The unit used in the text length calculations, always \"word\".\n */\n\n/**\n * Count the words in the text.\n *\n * @param {Paper} paper The Paper object.\n *\n * @param value\n * @returns {WordCountResult} The number of words found in the text, plus \"word\" as the unit used in calculating the text length.\n */\nexport default function(paper, value = null) {\n let text = typeof value === 'string' ? value : paper.getText();\n text = removeHtmlBlocks(text);\n text = filterShortcodesFromHTML(text, paper?._attributes && paper._attributes.shortcodes);\n return {\n text: text,\n count: wordCount(text),\n unit: 'word'\n };\n}\n"],"mappings":"AAAA,OAAOA,SAAS;AAChB,OAAOC,gBAAgB;AACvB,SAAQC,wBAAwB;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,UAASC,KAAK,EAAEC,KAAK,GAAG,IAAI,EAAE;EAC3C,IAAIC,IAAI,GAAG,OAAOD,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAGD,KAAK,CAACG,OAAO,CAAC,CAAC;EAC9DD,IAAI,GAAGJ,gBAAgB,CAACI,IAAI,CAAC;EAC7BA,IAAI,GAAGH,wBAAwB,CAACG,IAAI,EAAEF,KAAK,EAAEI,WAAW,IAAIJ,KAAK,CAACI,WAAW,CAACC,UAAU,CAAC;EACzF,OAAO;IACLH,IAAI,EAAEA,IAAI;IACVI,KAAK,EAAET,SAAS,CAACK,IAAI,CAAC;IACtBK,IAAI,EAAE;EACR,CAAC;AACH","ignoreList":[]}
@@ -1,7 +1,8 @@
1
1
  import { merge } from 'lodash';
2
2
  import Assessment from "../assessment";
3
3
  import AssessmentResult from "../../../values/AssessmentResult";
4
- import { countWordInHtml } from "../../../helpers";
4
+ import wordCountInText from "../../../languageProcessing/researches/wordCountInText";
5
+ import countCharacters from "../../../languageProcessing/languages/ja/helpers/countCharacters";
5
6
 
6
7
  /**
7
8
  * Represents an assessment that checks the length of the text and gives feedback accordingly.
@@ -63,10 +64,8 @@ export default class TextLengthAssessment extends Assessment {
63
64
  * @returns {{score: number, body: React.JSX.Element, status: string}}
64
65
  */
65
66
  calculateResult(paper, i18n) {
66
- const {
67
- wordCount,
68
- charCount
69
- } = countWordInHtml(paper.getText(), true);
67
+ const wordCount = wordCountInText(paper).count;
68
+ const charCount = countCharacters(paper.getText());
70
69
  let status = 'bad';
71
70
  if (charCount < 2500 && wordCount >= 600) {
72
71
  status = 'improve';
@@ -1 +1 @@
1
- {"version":3,"file":"TextLengthAssessment.js","names":["merge","Assessment","AssessmentResult","countWordInHtml","TextLengthAssessment","constructor","config","defaultConfig","id","ctaType","docUrl","priority","fixPosition","title","content","good","improve","bad","identifier","_config","getResult","paper","researcher","i18n","calculatedResult","calculateResult","assessmentResult","setScore","score","setStatus","status","wordCount","charCount","getText","getScore"],"sources":["../../../../src/scoring/assessments/seo/TextLengthAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\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\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 };\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,SAAQC,eAAe;;AAEvB;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,SAASH,UAAU,CAAC;EAC3D;AACF;AACA;AACA;AACA;AACA;AACA;EACEI,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,GAAGnB,KAAK,CAACO,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEc,SAASA,CAAC;IAACC,KAAK;IAAEC,UAAU;IAAEC;EAAI,CAAC,EAAE;IACnC,MAAMC,gBAAgB,GAAG,IAAI,CAACC,eAAe,CAACJ,KAAK,EAAEE,IAAI,CAAC;IAE1D,MAAMG,gBAAgB,GAAG,IAAIxB,gBAAgB,CAAC;MAACI,MAAM,EAAE,IAAI,CAACa;IAAO,CAAC,CAAC;IACrEO,gBAAgB,CAACC,QAAQ,CAACH,gBAAgB,CAACI,KAAK,CAAC;IACjDF,gBAAgB,CAACG,SAAS,CAACL,gBAAgB,CAACM,MAAM,CAAC;IAEnD,OAAOJ,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACED,eAAeA,CAACJ,KAAK,EAAEE,IAAI,EAAE;IAC3B,MAAM;MAACQ,SAAS;MAAEC;IAAS,CAAC,GAAG7B,eAAe,CAACkB,KAAK,CAACY,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC;IACrE,IAAIH,MAAM,GAAG,KAAK;IAClB,IAAIE,SAAS,GAAG,IAAI,IAAID,SAAS,IAAI,GAAG,EAAE;MACxCD,MAAM,GAAG,SAAS;IACpB;IACA,IAAIC,SAAS,GAAG,GAAG,IAAIC,SAAS,GAAG,IAAI,EAAE;MACvCF,MAAM,GAAG,KAAK;IAChB;IACA,IAAIE,SAAS,IAAI,IAAI,IAAID,SAAS,IAAI,GAAG,EAAE;MACzCD,MAAM,GAAG,MAAM;IACjB;IAEA,MAAMF,KAAK,GAAG,IAAI,CAACM,QAAQ,CAAC,IAAI,CAACf,OAAO,CAACR,QAAQ,EAAEmB,MAAM,CAAC;IAE1D,OAAO;MACLF,KAAK;MACLE;IACF,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"TextLengthAssessment.js","names":["merge","Assessment","AssessmentResult","wordCountInText","countCharacters","TextLengthAssessment","constructor","config","defaultConfig","id","ctaType","docUrl","priority","fixPosition","title","content","good","improve","bad","identifier","_config","getResult","paper","researcher","i18n","calculatedResult","calculateResult","assessmentResult","setScore","score","setStatus","status","wordCount","count","charCount","getText","getScore"],"sources":["../../../../src/scoring/assessments/seo/TextLengthAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport Assessment from '../assessment';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport wordCountInText from '@axyseo/languageProcessing/researches/wordCountInText';\nimport countCharacters from '@axyseo/languageProcessing/languages/ja/helpers/countCharacters';\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\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 = wordCountInText(paper).count;\n const charCount = countCharacters(paper.getText());\n\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 };\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,OAAOC,eAAe;AACtB,OAAOC,eAAe;;AAEtB;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,SAASJ,UAAU,CAAC;EAC3D;AACF;AACA;AACA;AACA;AACA;AACA;EACEK,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,C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AIE,SAAS,GAAG,IAAI,EAAE;MACvCH,MAAM,GAAG,KAAK;IAChB;IACA,IAAIG,SAAS,IAAI,IAAI,IAAIF,SAAS,IAAI,GAAG,EAAE;MACzCD,MAAM,GAAG,MAAM;IACjB;IAEA,MAAMF,KAAK,GAAG,IAAI,CAACO,QAAQ,CAAC,IAAI,CAAChB,OAAO,CAACR,QAAQ,EAAEmB,MAAM,CAAC;IAE1D,OAAO;MACLF,KAAK;MACLE;IACF,CAAC;EACH;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axyseo",
3
- "version": "2.0.0-alpha.0.0.54",
3
+ "version": "2.0.0-alpha.0.0.56",
4
4
  "main": "build/index.js",
5
5
  "scripts": {
6
6
  "prepublishOnly": "npm run build && npm version prerelease --preid=alpha",