axyseo 2.1.20 → 2.1.21

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.
@@ -30,11 +30,10 @@ class TextLengthAssessment extends _assessment.default {
30
30
  docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#text-length',
31
31
  priority: 'high',
32
32
  fixPosition: 'description',
33
- title: 'Text length',
33
+ title: 'Content length ',
34
34
  content: {
35
- good: 'Text length is optimized.',
36
- improve: 'Content length is acceptable, but could be expanded to 2,500 characters for more value.',
37
- bad: 'Insufficient content. Aim for at least 600 words to provide value and rank well in search results.'
35
+ good: 'Content length on target',
36
+ bad: 'Write 300 to 500 words. Cover features, specs, sizing, use, and care. '
38
37
  }
39
38
  };
40
39
  this.identifier = _analysis.TEXT_LENGTH_ID;
@@ -69,27 +68,48 @@ class TextLengthAssessment extends _assessment.default {
69
68
  */
70
69
  calculateResult(paper) {
71
70
  const pageType = paper.getPageType();
72
- const wordCount = (0, _wordCountInText.default)(paper).count;
73
- const charCount = (0, _countCharacters.default)(paper.getText());
74
- let status = 'bad';
75
- if (pageType === "product" && charCount <= 500 && wordCount >= 300) {
76
- status = 'good';
77
- }
78
- if (pageType === "collection" && charCount <= 300 && wordCount >= 150) {
79
- status = 'good';
80
- }
81
- if (pageType === "article" && charCount <= 1000 && wordCount >= 600) {
82
- status = 'good';
83
- }
84
- if (pageType === "page" && charCount <= 1000 && wordCount >= 600) {
85
- status = 'good';
71
+ const {
72
+ count: wordCount
73
+ } = (0, _wordCountInText.default)(paper);
74
+ const rules = {
75
+ product: {
76
+ min: 300,
77
+ max: 500,
78
+ badMessage: 'Write 300 to 500 words. Cover features, specs, sizing, use, and care.'
79
+ },
80
+ collection: {
81
+ min: 150,
82
+ max: 300,
83
+ badMessage: 'Write 150 to 300 words. Present the range and give quick buying guidance.'
84
+ },
85
+ article: {
86
+ min: 600,
87
+ max: 1000,
88
+ badMessage: 'Write 600 to 1000 words. Explain the topic with clear sections and examples.'
89
+ },
90
+ page: {
91
+ min: 600,
92
+ max: 1000,
93
+ badMessage: 'Write 600 to 1000 words. Provide clear, well-structured info for the page’s purpose.'
94
+ }
95
+ };
96
+ let status = 'good';
97
+ const rule = rules[pageType];
98
+ if (rule && (wordCount < rule.min || wordCount > rule.max)) {
99
+ status = 'bad';
100
+ this._config = (0, _lodash.merge)(this._config, {
101
+ content: {
102
+ good: 'Content length on target',
103
+ bad: rule.badMessage
104
+ }
105
+ });
86
106
  }
87
- const score = this.getScore(_analysis.MAIN_CONTENT_POINTS, status);
88
107
  return {
89
- score,
108
+ score: this.getScore(_analysis.MAIN_CONTENT_POINTS, status),
90
109
  status
91
110
  };
92
111
  }
112
+
93
113
  /**
94
114
  * Checks whether the paper has a keyword and a slug.
95
115
  *
@@ -1 +1 @@
1
- {"version":3,"file":"TextLengthAssessment.js","names":["_lodash","require","_assessment","_interopRequireDefault","_AssessmentResult","_wordCountInText","_countCharacters","_analysis","e","__esModule","default","TextLengthAssessment","Assessment","constructor","config","defaultConfig","id","TEXT_LENGTH_ID","ctaType","docUrl","priority","fixPosition","title","content","good","improve","bad","identifier","_config","merge","getResult","paper","researcher","calculatedResult","calculateResult","assessmentResult","AssessmentResult","setScore","score","setStatus","status","pageType","getPageType","wordCount","wordCountInText","count","charCount","countCharacters","getText","getScore","MAIN_CONTENT_POINTS","isApplicable","_default","exports"],"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';\nimport {MAIN_CONTENT_POINTS, TEXT_LENGTH_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents an assessment that checks the length of the text and gives feedback accordingly.\n */\n 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: TEXT_LENGTH_ID,\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 = TEXT_LENGTH_ID;\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 * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.\n */\n getResult({paper, researcher}) {\n const calculatedResult = this.calculateResult(paper);\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 * @returns {{score: number, status: string}}\n */\n calculateResult(paper) {\n const pageType = paper.getPageType();\n const wordCount = wordCountInText(paper).count;\n const charCount = countCharacters(paper.getText());\n\n let status = 'bad';\n if (pageType === \"product\" && charCount <= 500 && wordCount >= 300) {\n status = 'good';\n }\n if (pageType === \"collection\" && charCount <= 300 && wordCount >= 150) {\n status = 'good';\n }\n if (pageType === \"article\" && charCount <= 1000 && wordCount >= 600) {\n status = 'good';\n }\n if (pageType === \"page\" && charCount <= 1000 && wordCount >= 600) {\n status = 'good';\n }\n\n const score = this.getScore(MAIN_CONTENT_POINTS, status);\n\n return {\n score,\n status\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 true;\n }\n}\n\nexport default TextLengthAssessment;\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,gBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,gBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAA2E,SAAAE,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE3E;AACA;AACA;AACC,MAAMG,oBAAoB,SAASC,mBAAU,CAAC;EAC7C;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAEC,wBAAc;MAClBC,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,GAAGV,wBAAc;IAChC,IAAI,CAACW,OAAO,GAAG,IAAAC,aAAK,EAACd,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEgB,SAASA,CAAC;IAACC,KAAK;IAAEC;EAAU,CAAC,EAAE;IAC7B,MAAMC,gBAAgB,GAAG,IAAI,CAACC,eAAe,CAACH,KAAK,CAAC;IACpD,MAAMI,gBAAgB,GAAG,IAAIC,yBAAgB,CAAC;MAACtB,MAAM,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AAA,CAAA3C,OAAA,GAEcC,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"TextLengthAssessment.js","names":["_lodash","require","_assessment","_interopRequireDefault","_AssessmentResult","_wordCountInText","_countCharacters","_analysis","e","__esModule","default","TextLengthAssessment","Assessment","constructor","config","defaultConfig","id","TEXT_LENGTH_ID","ctaType","docUrl","priority","fixPosition","title","content","good","bad","identifier","_config","merge","getResult","paper","researcher","calculatedResult","calculateResult","assessmentResult","AssessmentResult","setScore","score","setStatus","status","pageType","getPageType","count","wordCount","wordCountInText","rules","product","min","max","badMessage","collection","article","page","rule","getScore","MAIN_CONTENT_POINTS","isApplicable","_default","exports"],"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';\nimport {MAIN_CONTENT_POINTS, TEXT_LENGTH_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents an assessment that checks the length of the text and gives feedback accordingly.\n */\n 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: TEXT_LENGTH_ID,\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: 'Content length ',\n content: {\n good: 'Content length on target',\n bad:\n 'Write 300 to 500 words. Cover features, specs, sizing, use, and care. '\n }\n };\n\n this.identifier = TEXT_LENGTH_ID;\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 * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.\n */\n getResult({paper, researcher}) {\n const calculatedResult = this.calculateResult(paper);\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 * @returns {{score: number, status: string}}\n */\n calculateResult(paper) {\n const pageType = paper.getPageType();\n const { count: wordCount } = wordCountInText(paper);\n\n const rules = {\n product: {\n min: 300,\n max: 500,\n badMessage:\n 'Write 300 to 500 words. Cover features, specs, sizing, use, and care.'\n },\n collection: {\n min: 150,\n max: 300,\n badMessage:\n 'Write 150 to 300 words. Present the range and give quick buying guidance.'\n },\n article: {\n min: 600,\n max: 1000,\n badMessage:\n 'Write 600 to 1000 words. Explain the topic with clear sections and examples.'\n },\n page: {\n min: 600,\n max: 1000,\n badMessage:\n 'Write 600 to 1000 words. Provide clear, well-structured info for the page’s purpose.'\n }\n };\n\n let status = 'good';\n const rule = rules[pageType];\n\n if (rule && (wordCount < rule.min || wordCount > rule.max)) {\n status = 'bad';\n this._config = merge(this._config, {\n content: {\n good: 'Content length on target',\n bad: rule.badMessage\n }\n });\n }\n\n return {\n score: this.getScore(MAIN_CONTENT_POINTS, status),\n status\n };\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 true;\n }\n}\n\nexport default TextLengthAssessment;\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,gBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,gBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,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] Whether the current page is the front page of the site. Defaults to false.
67
67
  */
68
68
  constructor(text, attributes) {
69
- console.log('attributes', attributes);
70
69
  this._text = (0, _helpers.cleanHTML)(text || '');
71
70
  this._tree = null;
72
71
  attributes = attributes || {};
@@ -1 +1 @@
1
- {"version":3,"file":"Paper.js","names":["_lodash","require","_helpers","_checkRelatedKeywords","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","pageType","Paper","constructor","text","attributes","console","log","_text","cleanHTML","_tree","defaults","hasOwnProperty","url","onlyLetters","replace","isEmpty","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","getRelatedKeywords","data","getData","related_keywords","map","hasH1Count","isNull","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","hasFAQsSchema","hasFAQs","getFAQs","length","hasArticleSchema","hasData","isObject","hasRelatedKeywords","relatedKeywords","Array","isArray","getIgnoredAssessments","ignoredAssessments","getPageType","getSkippedAssessments","skippedAssessments","getShopSettings","hasUrl","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","faqs","hasCustomData","getCustomData","hasTextTitle","isNil","getTextTitle","serialize","_parseClass","equals","paper","isEqual","parse","serialized","exports","default"],"sources":["../../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull, isObject} from 'lodash';\nimport {cleanHTML} from '@axyseo/helpers';\nimport {transformRelatedKeyword} from '@axyseo/languageProcessing/researches/checkRelatedKeywords';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false,\n pageType: '',\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object[]} [attributes.skippedAssessments] The array of texts, show which assessments should be skipped (those assessments will have good result).\n * @param {Object} [attributes.data] Given data.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n console.log('attributes', attributes);\n this._text = cleanHTML(text || '');\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getRelatedKeywords() {\n const data = this.getData();\n return (data?.related_keywords || []).map(keyword => keyword.text);\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes.description !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasFAQsSchema() {\n return this._attributes?.hasFAQsSchema || false;\n }\n\n /**\n *\n * @returns {boolean}\n */\n hasFAQs() {\n return 'faqs' in this.getData() && this.getFAQs().length > 0;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasArticleSchema() {\n return this._attributes?.hasArticleSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasData() {\n const data = this._attributes?.data;\n return isObject(data) && !isEmpty(data);\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasRelatedKeywords() {\n const relatedKeywords = this._attributes?.data?.related_keywords || [];\n return Array.isArray(relatedKeywords) && relatedKeywords.length > 0;\n }\n\n /**\n *\n * @returns {Object|{}}\n */\n getData() {\n return this._attributes?.data || {};\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getPageType() {\n return this._attributes?.pageType || '';\n }\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getSkippedAssessments() {\n return this._attributes?.skippedAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getFAQs() {\n return this.getData()?.faqs || {};\n }\n\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,iBAAiB,GAAG;EACxBC,OAAO,EAAE,EAAE;EACXC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE,EAAE;EACTC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,OAAO;EACfC,SAAS,EAAE,EAAE;EACbC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,CAAC,CAAC;EACdC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,KAAK;EACvBC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,KAAK;EAClBC,QAAQ,EAAE;AACZ,CAAC;;AAED;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UAAU,EAAE;IACvB;IACA,IAAIA,UAAU,YAAYvF,KAAK,EAAE;MAC/B,OAAOuF,UAAU;IACnB;;IAEA;IACA;IACA,MAAM;MAACrF,IAAI;MAAEgF,WAAW;MAAE,GAAG/E;IAAU,CAAC,GAAGoF,UAAU;IAErD,OAAO,IAAIvF,KAAK,CAACE,IAAI,EAAEC,UAAU,CAAC;EACpC;AACF;AAACqF,OAAA,CAAAC,OAAA,GAAAzF,KAAA","ignoreList":[]}
1
+ {"version":3,"file":"Paper.js","names":["_lodash","require","_helpers","_checkRelatedKeywords","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","pageType","Paper","constructor","text","attributes","_text","cleanHTML","_tree","defaults","hasOwnProperty","url","onlyLetters","replace","isEmpty","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","getRelatedKeywords","data","getData","related_keywords","map","hasH1Count","isNull","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","hasFAQsSchema","hasFAQs","getFAQs","length","hasArticleSchema","hasData","isObject","hasRelatedKeywords","relatedKeywords","Array","isArray","getIgnoredAssessments","ignoredAssessments","getPageType","getSkippedAssessments","skippedAssessments","getShopSettings","hasUrl","console","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","faqs","hasCustomData","getCustomData","hasTextTitle","isNil","getTextTitle","serialize","_parseClass","equals","paper","isEqual","parse","serialized","exports","default"],"sources":["../../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull, isObject} from 'lodash';\nimport {cleanHTML} from '@axyseo/helpers';\nimport {transformRelatedKeyword} from '@axyseo/languageProcessing/researches/checkRelatedKeywords';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false,\n pageType: '',\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object[]} [attributes.skippedAssessments] The array of texts, show which assessments should be skipped (those assessments will have good result).\n * @param {Object} [attributes.data] Given data.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n this._text = cleanHTML(text || '');\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getRelatedKeywords() {\n const data = this.getData();\n return (data?.related_keywords || []).map(keyword => keyword.text);\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes.description !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasFAQsSchema() {\n return this._attributes?.hasFAQsSchema || false;\n }\n\n /**\n *\n * @returns {boolean}\n */\n hasFAQs() {\n return 'faqs' in this.getData() && this.getFAQs().length > 0;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasArticleSchema() {\n return this._attributes?.hasArticleSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasData() {\n const data = this._attributes?.data;\n return isObject(data) && !isEmpty(data);\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasRelatedKeywords() {\n const relatedKeywords = this._attributes?.data?.related_keywords || [];\n return Array.isArray(relatedKeywords) && relatedKeywords.length > 0;\n }\n\n /**\n *\n * @returns {Object|{}}\n */\n getData() {\n return this._attributes?.data || {};\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getPageType() {\n return this._attributes?.pageType || '';\n }\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getSkippedAssessments() {\n return this._attributes?.skippedAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getFAQs() {\n return this.getData()?.faqs || {};\n }\n\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,iBAAiB,GAAG;EACxBC,OAAO,EAAE,EAAE;EACXC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE,EAAE;EACTC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,OAAO;EACfC,SAAS,EAAE,EAAE;EACbC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,CAAC,CAAC;EACdC,SAAS,EAAE,EAA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ACA;AACA;AACA;AACA;AACA;EACE,OAAOwE,KAAKA,CAACC,UAAU,EAAE;IACvB;IACA,IAAIA,UAAU,YAAYtF,KAAK,EAAE;MAC/B,OAAOsF,UAAU;IACnB;;IAEA;IACA;IACA,MAAM;MAACpF,IAAI;MAAE+E,WAAW;MAAE,GAAG9E;IAAU,CAAC,GAAGmF,UAAU;IAErD,OAAO,IAAItF,KAAK,CAACE,IAAI,EAAEC,UAAU,CAAC;EACpC;AACF;AAACoF,OAAA,CAAAC,OAAA,GAAAxF,KAAA","ignoreList":[]}
@@ -24,11 +24,10 @@ class TextLengthAssessment extends Assessment {
24
24
  docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#text-length',
25
25
  priority: 'high',
26
26
  fixPosition: 'description',
27
- title: 'Text length',
27
+ title: 'Content length ',
28
28
  content: {
29
- good: 'Text length is optimized.',
30
- improve: 'Content length is acceptable, but could be expanded to 2,500 characters for more value.',
31
- bad: 'Insufficient content. Aim for at least 600 words to provide value and rank well in search results.'
29
+ good: 'Content length on target',
30
+ bad: 'Write 300 to 500 words. Cover features, specs, sizing, use, and care. '
32
31
  }
33
32
  };
34
33
  this.identifier = TEXT_LENGTH_ID;
@@ -63,27 +62,48 @@ class TextLengthAssessment extends Assessment {
63
62
  */
64
63
  calculateResult(paper) {
65
64
  const pageType = paper.getPageType();
66
- const wordCount = wordCountInText(paper).count;
67
- const charCount = countCharacters(paper.getText());
68
- let status = 'bad';
69
- if (pageType === "product" && charCount <= 500 && wordCount >= 300) {
70
- status = 'good';
71
- }
72
- if (pageType === "collection" && charCount <= 300 && wordCount >= 150) {
73
- status = 'good';
74
- }
75
- if (pageType === "article" && charCount <= 1000 && wordCount >= 600) {
76
- status = 'good';
77
- }
78
- if (pageType === "page" && charCount <= 1000 && wordCount >= 600) {
79
- status = 'good';
65
+ const {
66
+ count: wordCount
67
+ } = wordCountInText(paper);
68
+ const rules = {
69
+ product: {
70
+ min: 300,
71
+ max: 500,
72
+ badMessage: 'Write 300 to 500 words. Cover features, specs, sizing, use, and care.'
73
+ },
74
+ collection: {
75
+ min: 150,
76
+ max: 300,
77
+ badMessage: 'Write 150 to 300 words. Present the range and give quick buying guidance.'
78
+ },
79
+ article: {
80
+ min: 600,
81
+ max: 1000,
82
+ badMessage: 'Write 600 to 1000 words. Explain the topic with clear sections and examples.'
83
+ },
84
+ page: {
85
+ min: 600,
86
+ max: 1000,
87
+ badMessage: 'Write 600 to 1000 words. Provide clear, well-structured info for the page’s purpose.'
88
+ }
89
+ };
90
+ let status = 'good';
91
+ const rule = rules[pageType];
92
+ if (rule && (wordCount < rule.min || wordCount > rule.max)) {
93
+ status = 'bad';
94
+ this._config = merge(this._config, {
95
+ content: {
96
+ good: 'Content length on target',
97
+ bad: rule.badMessage
98
+ }
99
+ });
80
100
  }
81
- const score = this.getScore(MAIN_CONTENT_POINTS, status);
82
101
  return {
83
- score,
102
+ score: this.getScore(MAIN_CONTENT_POINTS, status),
84
103
  status
85
104
  };
86
105
  }
106
+
87
107
  /**
88
108
  * Checks whether the paper has a keyword and a slug.
89
109
  *
@@ -1 +1 @@
1
- {"version":3,"file":"TextLengthAssessment.js","names":["merge","Assessment","AssessmentResult","wordCountInText","countCharacters","MAIN_CONTENT_POINTS","TEXT_LENGTH_ID","TextLengthAssessment","constructor","config","defaultConfig","id","ctaType","docUrl","priority","fixPosition","title","content","good","improve","bad","identifier","_config","getResult","paper","researcher","calculatedResult","calculateResult","assessmentResult","setScore","score","setStatus","status","pageType","getPageType","wordCount","count","charCount","getText","getScore","isApplicable"],"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';\nimport {MAIN_CONTENT_POINTS, TEXT_LENGTH_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents an assessment that checks the length of the text and gives feedback accordingly.\n */\n 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: TEXT_LENGTH_ID,\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 = TEXT_LENGTH_ID;\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 * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.\n */\n getResult({paper, researcher}) {\n const calculatedResult = this.calculateResult(paper);\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 * @returns {{score: number, status: string}}\n */\n calculateResult(paper) {\n const pageType = paper.getPageType();\n const wordCount = wordCountInText(paper).count;\n const charCount = countCharacters(paper.getText());\n\n let status = 'bad';\n if (pageType === \"product\" && charCount <= 500 && wordCount >= 300) {\n status = 'good';\n }\n if (pageType === \"collection\" && charCount <= 300 && wordCount >= 150) {\n status = 'good';\n }\n if (pageType === \"article\" && charCount <= 1000 && wordCount >= 600) {\n status = 'good';\n }\n if (pageType === \"page\" && charCount <= 1000 && wordCount >= 600) {\n status = 'good';\n }\n\n const score = this.getScore(MAIN_CONTENT_POINTS, status);\n\n return {\n score,\n status\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 true;\n }\n}\n\nexport default TextLengthAssessment;\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,OAAOC,eAAe;AACtB,OAAOC,eAAe;AACtB,SAAQC,mBAAmB,EAAEC,cAAc;;AAE3C;AACA;AACA;AACC,MAAMC,oBAAoB,SAASN,UAAU,CAAC;EAC7C;AACF;AACA;AACA;AACA;AACA;AACA;EACEO,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAEL,cAAc;MAClBM,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,GAAGf,cAAc;IAChC,IAAI,CAACgB,OAAO,GAAGtB,KAAK,CAACU,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEc,SAASA,CAAC;IAACC,KAAK;IAAEC;EAAU,CAAC,EAAE;IAC7B,MAAMC,gBAAgB,GAAG,IAAI,CAACC,eAAe,CAACH,KAAK,CAAC;IACpD,MAAMI,gBAAgB,GAAG,IAAI1B,gBAAgB,CAAC;MAACO,MAAM,EAAE,IAAI,CAACa;IAAO,CAAC,CAAC;IACrEM,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;EACED,eAAeA,CAACH,KAAK,EAAE;IACrB,MAAMS,QAAQ,GAAGT,KAAK,CAACU,WAAW,CAAC,CAAC;IACpC,MAAMC,SAAS,GAAGhC,eAAe,CAACqB,KAAK,CAAC,CAACY,KAAK;IAC9C,MAAMC,SAAS,GAAGjC,eAAe,CAACoB,KAAK,CAACc,OAAO,CAAC,CAAC,CAAC;IAElD,IAAIN,MAAM,GAAG,KAAK;IAClB,IAAIC,QAAQ,KAAK,SAAS,IAAII,SAAS,IAAI,GAAG,IAAIF,SAAS,IAAI,GAAG,EAAE;MAClEH,MAAM,GAAG,MAAM;IACjB;IACA,IAAIC,QAAQ,KAAK,YAAY,IAAII,SAAS,IAAI,GAAG,IAAIF,SAAS,IAAI,GAAG,EAAE;MACrEH,MAAM,GAAG,MAAM;IACjB;IACA,IAAIC,QAAQ,KAAK,SAAS,IAAII,SAAS,IAAI,IAAI,IAAIF,SAAS,IAAI,GAAG,EAAE;MACnEH,MAAM,GAAG,MAAM;IACjB;IACA,IAAIC,QAAQ,KAAK,MAAM,IAAII,SAAS,IAAI,IAAI,IAAIF,SAAS,IAAI,GAAG,EAAE;MAChEH,MAAM,GAAG,MAAM;IACjB;IAEA,MAAMF,KAAK,GAAG,IAAI,CAACS,QAAQ,CAAClC,mBAAmB,EAAE2B,MAAM,CAAC;IAExD,OAAO;MACLF,KAAK;MACLE;IACF,CAAC;EACH;EACA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEQ,YAAYA,CAAChB,KAAK,EAAEC,UAAU,EAAE;IAC9B,OAAO,IAAI;EACb;AACF;AAEA,eAAelB,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"TextLengthAssessment.js","names":["merge","Assessment","AssessmentResult","wordCountInText","countCharacters","MAIN_CONTENT_POINTS","TEXT_LENGTH_ID","TextLengthAssessment","constructor","config","defaultConfig","id","ctaType","docUrl","priority","fixPosition","title","content","good","bad","identifier","_config","getResult","paper","researcher","calculatedResult","calculateResult","assessmentResult","setScore","score","setStatus","status","pageType","getPageType","count","wordCount","rules","product","min","max","badMessage","collection","article","page","rule","getScore","isApplicable"],"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';\nimport {MAIN_CONTENT_POINTS, TEXT_LENGTH_ID} from '@axyseo/const/analysis';\n\n/**\n * Represents an assessment that checks the length of the text and gives feedback accordingly.\n */\n 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: TEXT_LENGTH_ID,\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: 'Content length ',\n content: {\n good: 'Content length on target',\n bad:\n 'Write 300 to 500 words. Cover features, specs, sizing, use, and care. '\n }\n };\n\n this.identifier = TEXT_LENGTH_ID;\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 * @returns {AssessmentResult} The result of the assessment, containing both a score and a descriptive text.\n */\n getResult({paper, researcher}) {\n const calculatedResult = this.calculateResult(paper);\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 * @returns {{score: number, status: string}}\n */\n calculateResult(paper) {\n const pageType = paper.getPageType();\n const { count: wordCount } = wordCountInText(paper);\n\n const rules = {\n product: {\n min: 300,\n max: 500,\n badMessage:\n 'Write 300 to 500 words. Cover features, specs, sizing, use, and care.'\n },\n collection: {\n min: 150,\n max: 300,\n badMessage:\n 'Write 150 to 300 words. Present the range and give quick buying guidance.'\n },\n article: {\n min: 600,\n max: 1000,\n badMessage:\n 'Write 600 to 1000 words. Explain the topic with clear sections and examples.'\n },\n page: {\n min: 600,\n max: 1000,\n badMessage:\n 'Write 600 to 1000 words. Provide clear, well-structured info for the page’s purpose.'\n }\n };\n\n let status = 'good';\n const rule = rules[pageType];\n\n if (rule && (wordCount < rule.min || wordCount > rule.max)) {\n status = 'bad';\n this._config = merge(this._config, {\n content: {\n good: 'Content length on target',\n bad: rule.badMessage\n }\n });\n }\n\n return {\n score: this.getScore(MAIN_CONTENT_POINTS, status),\n status\n };\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 true;\n }\n}\n\nexport default TextLengthAssessment;\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,OAAOC,eAAe;AACtB,OAAOC,eAAe;AACtB,SAAQC,mBAAmB,EAAEC,cAAc;;AAE3C;AACA;AACA;AACC,MAAMC,oBAAoB,SAASN,UAAU,CAAC;EAC7C;AACF;AACA;AACA;AACA;AACA;AACA;EACEO,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAEL,cAAc;MAClBM,OAAO,EAAE,KAAK;MACdC,MAAM,EACJ,yFAAyF;MAC3FC,QAAQ,EAAE,MAAM;MAChBC,WAAW,EAAE,aAAa;MAC1BC,KAAK,EA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,MAAM,GAAG,MAAM;IACnB,MAAMa,IAAI,GAAGR,KAAK,CAACJ,QAAQ,CAAC;IAE5B,IAAIY,IAAI,KAAKT,SAAS,GAAGS,IAAI,CAACN,GAAG,IAAIH,SAAS,GAAGS,IAAI,CAACL,GAAG,CAAC,EAAE;MAC1DR,MAAM,GAAG,KAAK;MACd,IAAI,CAACV,OAAO,GAAGrB,KAAK,CAAC,IAAI,CAACqB,OAAO,EAAE;QACjCJ,OAAO,EAAE;UACPC,IAAI,EAAE,0BAA0B;UAChCC,GAAG,EAAEyB,IAAI,CAACJ;QACZ;MACF,CAAC,CAAC;IACJ;IAEA,OAAO;MACLX,KAAK,EAAE,IAAI,CAACgB,QAAQ,CAACxC,mBAAmB,EAAE0B,MAAM,CAAC;MACjDA;IACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEe,YAAYA,CAACvB,KAAK,EAAEC,UAAU,EAAE;IAC9B,OAAO,IAAI;EACb;AACF;AAEA,eAAejB,oBAAoB","ignoreList":[]}
@@ -61,7 +61,6 @@ export default class Paper {
61
61
  * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.
62
62
  */
63
63
  constructor(text, attributes) {
64
- console.log('attributes', attributes);
65
64
  this._text = cleanHTML(text || '');
66
65
  this._tree = null;
67
66
  attributes = attributes || {};
@@ -1 +1 @@
1
- {"version":3,"file":"Paper.js","names":["defaults","isEmpty","isEqual","isNil","isNull","isObject","cleanHTML","transformRelatedKeyword","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","pageType","Paper","constructor","text","attributes","console","log","_text","_tree","hasOwnProperty","url","onlyLetters","replace","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","getRelatedKeywords","data","getData","related_keywords","map","hasH1Count","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","hasFAQsSchema","hasFAQs","getFAQs","length","hasArticleSchema","hasData","hasRelatedKeywords","relatedKeywords","Array","isArray","getIgnoredAssessments","ignoredAssessments","getPageType","getSkippedAssessments","skippedAssessments","getShopSettings","hasUrl","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","faqs","hasCustomData","getCustomData","hasTextTitle","getTextTitle","serialize","_parseClass","equals","paper","parse","serialized"],"sources":["../../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull, isObject} from 'lodash';\nimport {cleanHTML} from '@axyseo/helpers';\nimport {transformRelatedKeyword} from '@axyseo/languageProcessing/researches/checkRelatedKeywords';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false,\n pageType: '',\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object[]} [attributes.skippedAssessments] The array of texts, show which assessments should be skipped (those assessments will have good result).\n * @param {Object} [attributes.data] Given data.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n console.log('attributes', attributes);\n this._text = cleanHTML(text || '');\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getRelatedKeywords() {\n const data = this.getData();\n return (data?.related_keywords || []).map(keyword => keyword.text);\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes.description !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasFAQsSchema() {\n return this._attributes?.hasFAQsSchema || false;\n }\n\n /**\n *\n * @returns {boolean}\n */\n hasFAQs() {\n return 'faqs' in this.getData() && this.getFAQs().length > 0;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasArticleSchema() {\n return this._attributes?.hasArticleSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasData() {\n const data = this._attributes?.data;\n return isObject(data) && !isEmpty(data);\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasRelatedKeywords() {\n const relatedKeywords = this._attributes?.data?.related_keywords || [];\n return Array.isArray(relatedKeywords) && relatedKeywords.length > 0;\n }\n\n /**\n *\n * @returns {Object|{}}\n */\n getData() {\n return this._attributes?.data || {};\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getPageType() {\n return this._attributes?.pageType || '';\n }\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getSkippedAssessments() {\n return this._attributes?.skippedAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getFAQs() {\n return this.getData()?.faqs || {};\n }\n\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAO,QAAQ;AAC1E,SAAQC,SAAS;AACjB,SAAQC,uBAAuB;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG;EACxBC,OAAO,EAAE,EAAE;EACXC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE,EAAE;EACTC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,OAAO;EACfC,SAAS,EAAE,EAAE;EACbC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,CAAC,CAAC;EACdC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,KAAK;EACvBC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,KAAK;EAClBC,QAAQ,EAAE;AACZ,CAAC;;AAED;AACA;AACA;AACA,eAAe,MAAMC,KAAK,CAAC;EACzB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,IAAI,EAAEC,UAAU,EAAE;IAC5BC,OAAO,CAACC,GAAG,CAAC,YAAY,EAAEF,UAAU,CAAC;IACrC,IAAI,CAACG,KAAK,GAAG3B,SAAS,CAACuB,IAAI,IAAI,EAAE,CAAC;IAElC,IAAI,CAACK,KAAK,GAAG,IAAI;IAEjBJ,UAAU,GAAGA,UAAU,IAAI,CAAC,CAAC;IAC7B9B,QAAQ,CAAC8B,UAAU,EAAEtB,iBAAiB,CAAC;IAEvC,IAAIsB,UAAU,CAACZ,MAAM,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C7D,WAAW,CAACjB,SAAS,KAAK,EAAE,IAAI,CAACnB,KAAK,CAAC,IAAI,CAACoC,WAAW,CAACjB,SAAS,CAAC;EAChF;;EAEA;AACF;AACA;AACA;EACE+E,YAAYA,CAAA,EAAG;IACb,OAAO,IAAI,CAAC9D,WAAW,CAACjB,SAAS;EACnC;;EAEA;AACF;AACA;AACA;AACA;EACEgF,SAASA,CAAA,EAAG;IACV,OAAO;MACLC,WAAW,EAAE,OAAO;MACpB1E,IAAI,EAAE,IAAI,CAACI,KAAK;MAChB,GAAG,IAAI,CAACM;IACV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEiE,MAAMA,CAACC,KAAK,EAAE;IACZ,OAAO,IAAI,CAACxE,KAAK,KAAKwE,KAAK,CAAClD,OAAO,CAAC,CAAC,IAAIrD,OAAO,CAAC,IAAI,CAACqC,WAAW,EAAEkE,KAAK,CAAClE,WAAW,CAAC;EACvF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,OAAOmE,KAAKA,CAACC,UAAU,EAAE;IACvB;IACA,IAAIA,UAAU,YAAYhF,KAAK,EAAE;MAC/B,OAAOgF,UAAU;IACnB;;IAEA;IACA;IACA,MAAM;MAAC9E,IAAI;MAAE0E,WAAW;MAAE,GAAGzE;IAAU,CAAC,GAAG6E,UAAU;IAErD,OAAO,IAAIhF,KAAK,CAACE,IAAI,EAAEC,UAAU,CAAC;EACpC;AACF","ignoreList":[]}
1
+ {"version":3,"file":"Paper.js","names":["defaults","isEmpty","isEqual","isNil","isNull","isObject","cleanHTML","transformRelatedKeyword","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","pageType","Paper","constructor","text","attributes","_text","_tree","hasOwnProperty","url","onlyLetters","replace","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","getRelatedKeywords","data","getData","related_keywords","map","hasH1Count","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","hasFAQsSchema","hasFAQs","getFAQs","length","hasArticleSchema","hasData","hasRelatedKeywords","relatedKeywords","Array","isArray","getIgnoredAssessments","ignoredAssessments","getPageType","getSkippedAssessments","skippedAssessments","getShopSettings","hasUrl","console","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","faqs","hasCustomData","getCustomData","hasTextTitle","getTextTitle","serialize","_parseClass","equals","paper","parse","serialized"],"sources":["../../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull, isObject} from 'lodash';\nimport {cleanHTML} from '@axyseo/helpers';\nimport {transformRelatedKeyword} from '@axyseo/languageProcessing/researches/checkRelatedKeywords';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false,\n pageType: '',\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object[]} [attributes.skippedAssessments] The array of texts, show which assessments should be skipped (those assessments will have good result).\n * @param {Object} [attributes.data] Given data.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n this._text = cleanHTML(text || '');\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getRelatedKeywords() {\n const data = this.getData();\n return (data?.related_keywords || []).map(keyword => keyword.text);\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes.description !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasFAQsSchema() {\n return this._attributes?.hasFAQsSchema || false;\n }\n\n /**\n *\n * @returns {boolean}\n */\n hasFAQs() {\n return 'faqs' in this.getData() && this.getFAQs().length > 0;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasArticleSchema() {\n return this._attributes?.hasArticleSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasData() {\n const data = this._attributes?.data;\n return isObject(data) && !isEmpty(data);\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasRelatedKeywords() {\n const relatedKeywords = this._attributes?.data?.related_keywords || [];\n return Array.isArray(relatedKeywords) && relatedKeywords.length > 0;\n }\n\n /**\n *\n * @returns {Object|{}}\n */\n getData() {\n return this._attributes?.data || {};\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getPageType() {\n return this._attributes?.pageType || '';\n }\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getSkippedAssessments() {\n return this._attributes?.skippedAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n *\n * @returns {*|*[]}\n */\n getFAQs() {\n return this.getData()?.faqs || {};\n }\n\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAO,QAAQ;AAC1E,SAAQC,SAAS;AACjB,SAAQC,uBAAuB;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG;EACxBC,OAAO,EAAE,EAAE;EACXC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE,EAAE;EACTC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,OAAO;EACfC,SAAS,EAAE,EAAE;EACbC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,CAAC,CAAC;EACdC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,KAAK;EACvBC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,KAAK;EAClBC,QAAQ,EAAE;AACZ,CAAC;;AAED;AACA;AACA;AACA,eAAe,MAAMC,KAAK,CAAC;EACzB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,IAAI,EAAEC,UAAU,EAAE;IAC5B,IAAI,CAACC,KAAK,GAAGzB,SAAS,CAACuB,IAAI,IAAI,EAAE,CAAC;IAElC,IAAI,CAACG,KAAK,GAAG,IAAI;IAEjBF,UAAU,GAAGA,UAAU,IAAI,CAAC,CAAC;IAC7B9B,QAAQ,CAAC8B,UAAU,EAAEtB,iBAAiB,CAAC;IAEvC,IAAIsB,UAAU,CAACZ,MAAM,KAAK,EAAE,EAAE;MAC5B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AAE,IAAI,CAACnB,KAAK,CAAC,IAAI,CAACkC,WAAW,CAACf,SAAS,CAAC;EAChF;;EAEA;AACF;AACA;AACA;EACE8E,YAAYA,CAAA,EAAG;IACb,OAAO,IAAI,CAAC/D,WAAW,CAACf,SAAS;EACnC;;EAEA;AACF;AACA;AACA;AACA;EACE+E,SAASA,CAAA,EAAG;IACV,OAAO;MACLC,WAAW,EAAE,OAAO;MACpBzE,IAAI,EAAE,IAAI,CAACE,KAAK;MAChB,GAAG,IAAI,CAACM;IACV,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEkE,MAAMA,CAACC,KAAK,EAAE;IACZ,OAAO,IAAI,CAACzE,KAAK,KAAKyE,KAAK,CAACnD,OAAO,CAAC,CAAC,IAAInD,OAAO,CAAC,IAAI,CAACmC,WAAW,EAAEmE,KAAK,CAACnE,WAAW,CAAC;EACvF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,OAAOoE,KAAKA,CAACC,UAAU,EAAE;IACvB;IACA,IAAIA,UAAU,YAAY/E,KAAK,EAAE;MAC/B,OAAO+E,UAAU;IACnB;;IAEA;IACA;IACA,MAAM;MAAC7E,IAAI;MAAEyE,WAAW;MAAE,GAAGxE;IAAU,CAAC,GAAG4E,UAAU;IAErD,OAAO,IAAI/E,KAAK,CAACE,IAAI,EAAEC,UAAU,CAAC;EACpC;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axyseo",
3
- "version": "2.1.20",
3
+ "version": "2.1.21",
4
4
  "main": "build/cjs/index.js",
5
5
  "module": "build/esm/index.js",
6
6
  "exports": {