Comparing version 0.0.1 to 0.0.2
@@ -18,3 +18,3 @@ import { type CheerioAPI } from "cheerio"; | ||
getInternalLinks(): LinksGroup; | ||
getWordCount(): number; | ||
getWordCount(stringContent?: string | null): number; | ||
} |
@@ -81,4 +81,10 @@ "use strict"; | ||
} | ||
getWordCount() { | ||
return this.htmlDom.text().split(' ').length; | ||
getWordCount(stringContent = null) { | ||
if (!stringContent) { | ||
stringContent = this.htmlDom.text().toLowerCase(); | ||
} | ||
else { | ||
stringContent = stringContent.toLowerCase(); | ||
} | ||
return stringContent.split(' ').length; | ||
} | ||
@@ -85,0 +91,0 @@ } |
@@ -13,5 +13,6 @@ interface Link { | ||
density: number; | ||
position?: number; | ||
} | ||
interface ContentJson { | ||
question: string; | ||
title: string; | ||
keyword: string; | ||
@@ -36,7 +37,7 @@ subKeywords: string[]; | ||
outboundLinks: LinksGroup; | ||
questionSEO: { | ||
subKeywordsWithQuestion: KeywordDensity[]; | ||
keywordWithQuestion: KeywordDensity; | ||
titleSEO: { | ||
subKeywordsWithTitle: KeywordDensity[]; | ||
keywordWithTitle: KeywordDensity; | ||
}; | ||
} | ||
export { Link, LinksGroup, KeywordDensity, ContentJson, SeoData }; |
@@ -20,7 +20,8 @@ import type { HtmlAnalyzer } from "./html-analyzer"; | ||
}; | ||
getKeywordInQuestion(keyword?: string | null): KeywordDensity; | ||
getSubKeywordsInQuestion(): KeywordDensity[]; | ||
countOccurrencesInString(keyword: string, string: string): number; | ||
getKeywordInTitle(keyword?: string | null): KeywordDensity; | ||
getSubKeywordsInTitle(): KeywordDensity[]; | ||
countOccurrencesInString(keyword: string, stringContent: string): number; | ||
getSeoScore(): number; | ||
getKeywordSeoScore(): number; | ||
getTitleWordCount(): number; | ||
} |
@@ -81,3 +81,3 @@ "use strict"; | ||
}); | ||
if (this.getKeywordInQuestion()) { | ||
if (this.getKeywordInTitle()) { | ||
goodPoints.push(`You have your main keyword in question.`); | ||
@@ -88,4 +88,4 @@ } | ||
} | ||
if (this.getSubKeywordsInQuestion().length > 0) { | ||
goodPoints.push(`You have ${this.getSubKeywordsInQuestion().length} sub keywords in question.`); | ||
if (this.getSubKeywordsInTitle().length > 0) { | ||
goodPoints.push(`You have ${this.getSubKeywordsInTitle().length} sub keywords in question.`); | ||
} | ||
@@ -128,21 +128,23 @@ else { | ||
} | ||
getKeywordInQuestion(keyword = null) { | ||
getKeywordInTitle(keyword = null) { | ||
var _a; | ||
if (keyword === null) { | ||
keyword = this.content.keyword; | ||
} | ||
const density = this.calculateDensity(keyword, this.content.question); | ||
const density = this.calculateDensity(keyword, this.content.title); | ||
return { | ||
keyword, | ||
density | ||
density, | ||
position: (_a = this.content.title) === null || _a === void 0 ? void 0 : _a.indexOf(keyword) | ||
}; | ||
} | ||
getSubKeywordsInQuestion() { | ||
getSubKeywordsInTitle() { | ||
let subKeywordsInQuestion = []; | ||
this.content.subKeywords.forEach((sub_keyword) => { | ||
subKeywordsInQuestion.push(this.getKeywordInQuestion(sub_keyword)); | ||
subKeywordsInQuestion.push(this.getKeywordInTitle(sub_keyword)); | ||
}); | ||
return subKeywordsInQuestion; | ||
} | ||
countOccurrencesInString(keyword, string) { | ||
return string.split(keyword).length - 1; | ||
countOccurrencesInString(keyword, stringContent) { | ||
return stringContent.split(keyword).length - 1; | ||
} | ||
@@ -158,4 +160,4 @@ getSeoScore() { | ||
const keywordDensity = this.getKeywordDensity(); | ||
const keywordInQuestion = this.getKeywordInQuestion(); | ||
const subKeywordsInQuestion = this.getSubKeywordsInQuestion(); | ||
const keywordInQuestion = this.getKeywordInTitle(); | ||
const subKeywordsInQuestion = this.getSubKeywordsInTitle(); | ||
const subKeywordsDensity = this.getSubKeywordsDensity(); | ||
@@ -171,4 +173,7 @@ const keywordInQuestionScore = keywordInQuestion.density * 10; | ||
} | ||
getTitleWordCount() { | ||
return this.htmlAnalyzer.getWordCount(this.content.title); | ||
} | ||
} | ||
exports.SeoAnalyzer = SeoAnalyzer; | ||
//# sourceMappingURL=seo-analyzer.js.map |
@@ -22,7 +22,7 @@ import { SeoAnalyzer } from './seo-analyzer'; | ||
outboundLinks: import("./interfaces").LinksGroup; | ||
questionSEO: { | ||
subKeywordsWithQuestion: import("./interfaces").KeywordDensity[]; | ||
keywordWithQuestion: import("./interfaces").KeywordDensity; | ||
titleSEO: { | ||
subKeywordsWithTitle: import("./interfaces").KeywordDensity[]; | ||
keywordWithTitle: import("./interfaces").KeywordDensity; | ||
}; | ||
}; | ||
} |
@@ -23,5 +23,5 @@ "use strict"; | ||
outboundLinks: this.htmlAnalyzer.getOutboundLinks(), | ||
questionSEO: { | ||
subKeywordsWithQuestion: this.seoAnalyzer.getSubKeywordsInQuestion(), | ||
keywordWithQuestion: this.seoAnalyzer.getKeywordInQuestion(), | ||
titleSEO: { | ||
subKeywordsWithTitle: this.seoAnalyzer.getSubKeywordsInTitle(), | ||
keywordWithTitle: this.seoAnalyzer.getKeywordInTitle(), | ||
} | ||
@@ -28,0 +28,0 @@ }; |
{ | ||
"name": "seord", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Advanced SEO Analyzer", | ||
@@ -19,2 +19,8 @@ "main": "dist/index.js", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Bishwas-py/seord/issues" | ||
}, | ||
"homepage": "https://github.com/Bishwas-py/seord#readme", | ||
"devDependencies": { | ||
@@ -21,0 +27,0 @@ "@types/node": "^20.4.5", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
33198
426
0
1