New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

seord

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seord - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

3

dist/html-analyzer.d.ts
import { type CheerioAPI } from "cheerio";
import type { Link, LinksGroup } from "./interfaces";
import type { Heading, Link, LinksGroup } from "./interfaces";
/**

@@ -13,2 +13,3 @@ * Class to analyze HTML content

getAllLinks(): Link[];
getAllHeadingTags(): Heading[];
isRelativeLink(href: string): boolean;

@@ -15,0 +16,0 @@ startAsAbsoluteLink(href: string): boolean;

@@ -28,2 +28,13 @@ "use strict";

}
getAllHeadingTags() {
let allHeadingTags = [];
this.htmlDom("h1,h2,h3,h4,h5,h6").each((index, element) => {
let headingElement = this.htmlDom(element);
allHeadingTags.push({
text: headingElement.text(),
tag: headingElement.prop('tagName')
});
});
return allHeadingTags;
}
isRelativeLink(href) {

@@ -30,0 +41,0 @@ return href.startsWith('./') || href.startsWith('../') || href.startsWith('/') || href.startsWith('#');

@@ -24,2 +24,6 @@ interface Link {

}
interface Heading {
text: string;
tag: string;
}
interface SeoData {

@@ -46,2 +50,2 @@ seoScore: number;

}
export { Link, LinksGroup, KeywordDensity, ContentJson, SeoData };
export { Link, LinksGroup, KeywordDensity, ContentJson, SeoData, Heading };
import type { HtmlAnalyzer } from "./html-analyzer";
import type { ContentJson, KeywordDensity } from "./interfaces";
import type { ContentJson, Heading, KeywordDensity } from "./interfaces";
export declare class SeoAnalyzer {

@@ -19,2 +19,4 @@ MINIMUM_KEYWORD_DENSITY: number;

keywordDensity: number;
strictMode: boolean;
headings: Heading[];
messages: {

@@ -25,3 +27,3 @@ warnings: string[];

};
constructor(content: ContentJson, htmlAnalyzer: HtmlAnalyzer);
constructor(content: ContentJson, htmlAnalyzer: HtmlAnalyzer, strictMode?: boolean);
getSubKeywordsDensity(): KeywordDensity[];

@@ -42,2 +44,6 @@ totalUniqueInternalLinksCount(): number;

private assignMessagesForMetaDescription;
filterHeading(headingTag: string): Heading[];
private assignMessagesForHeadings;
assignMessagesForKeywordInHeadings(): void;
assignMessagesForSubKeywordsInHeadings(): void;
/**

@@ -44,0 +50,0 @@ * Returns the messages object.

@@ -5,3 +5,3 @@ "use strict";

class SeoAnalyzer {
constructor(content, htmlAnalyzer) {
constructor(content, htmlAnalyzer, strictMode = false) {
this.MINIMUM_KEYWORD_DENSITY = 1;

@@ -19,2 +19,3 @@ this.MAXIMUM_KEYWORD_DENSITY = 3;

this.MINIMUM_SUB_KEYWORD_IN_META_DESCRIPTION_DENSITY = 2;
this.headings = [];
this.messages = {

@@ -27,3 +28,11 @@ warnings: [],

this.htmlAnalyzer = htmlAnalyzer;
this.strictMode = strictMode;
this.keywordDensity = this.calculateDensity(this.content.keyword);
this.headings = this.htmlAnalyzer.getAllHeadingTags();
if (!strictMode) {
this.headings.push({
tag: 'H1',
'text': this.content.title
});
}
this.assignMessages();

@@ -262,2 +271,64 @@ }

}
filterHeading(headingTag) {
return this.headings.filter((heading) => heading.tag.toLowerCase() === headingTag.toLowerCase());
}
assignMessagesForHeadings() {
if (this.headings.length === 0) {
this.messages.warnings.push('Missing headings, please add at least one heading tag.');
}
else {
this.messages.goodPoints.push(`You have ${this.headings.length} this.headings.`);
// warning for missing h1 tag
let headingsOne = this.filterHeading('h1');
if (headingsOne.length === 0) {
this.messages.warnings.push('Missing h1 tag, please add at least one h1 tag.');
}
else if (headingsOne.length > 1) {
this.messages.warnings.push('More than one h1 tag found, please remove all but one h1 tag.');
}
else {
this.messages.goodPoints.push('Nice. You have h1 tag, which is essential.');
}
let headingsTwo = this.filterHeading('h2');
if (headingsTwo.length === 0) {
this.messages.warnings.push('Missing h2 tag, please add at least one h2 tag. It is recommended to have at least one h2 tag.');
}
else {
this.messages.goodPoints.push('Nice. You have h2 tag, which is essential.');
}
let headingsThree = this.filterHeading('h3');
if (headingsThree.length === 0) {
this.messages.minorWarnings.push('Missing h3 tag, please add at least one h3 tag. Having h3 tag is not mandatory, but it is recommended to have at least one h3 tag.');
}
else {
this.messages.goodPoints.push('You have h3 tag, which is good.');
}
}
}
// keyword in Headings
assignMessagesForKeywordInHeadings() {
this.headings.forEach((heading) => {
let keywordInHeading = this.countOccurrencesInString(this.content.keyword, heading.text);
if (keywordInHeading > 0) {
this.messages.goodPoints.push(`Keyword "${this.content.keyword}" found in ${heading.tag} tag "${heading.text}".`);
}
else {
this.messages.minorWarnings.push(`Keyword "${this.content.keyword}" not found in ${heading.tag} tag "${heading.text}".`);
}
});
}
// sub keywords in Headings
assignMessagesForSubKeywordsInHeadings() {
this.headings.forEach((heading) => {
this.content.subKeywords.forEach((subKeyword) => {
let subKeywordInHeading = this.countOccurrencesInString(subKeyword, heading.text);
if (subKeywordInHeading > 0) {
this.messages.goodPoints.push(`Sub keyword "${subKeyword}" found in ${heading.tag} tag "${heading.text}", which is good.`);
}
else {
this.messages.minorWarnings.push(`Sub keyword "${subKeyword}" not found in ${heading.tag} tag "${heading.text}".`);
}
});
});
}
/**

@@ -280,2 +351,5 @@ * Returns the messages object.

this.assignMessagesForMetaDescription();
this.assignMessagesForKeywordInHeadings();
this.assignMessagesForSubKeywordsInHeadings();
this.assignMessagesForHeadings();
return this.messages;

@@ -282,0 +356,0 @@ }

@@ -9,3 +9,3 @@ import { SeoAnalyzer } from './seo-analyzer';

seoAnalyzer: SeoAnalyzer;
constructor(contentJson: ContentJson, siteDomainName?: string | null);
constructor(contentJson: ContentJson, siteDomainName?: string | null, strictMode?: boolean);
private makeContentLowerCase;

@@ -12,0 +12,0 @@ analyzeSeo(): {

@@ -7,3 +7,3 @@ "use strict";

class SeoCheck {
constructor(contentJson, siteDomainName = null) {
constructor(contentJson, siteDomainName = null, strictMode = false) {
this.content = contentJson;

@@ -13,3 +13,3 @@ this.makeContentLowerCase();

this.htmlAnalyzer = new html_analyzer_1.HtmlAnalyzer(this.content.htmlText, this.siteDomainName);
this.seoAnalyzer = new seo_analyzer_1.SeoAnalyzer(this.content, this.htmlAnalyzer);
this.seoAnalyzer = new seo_analyzer_1.SeoAnalyzer(this.content, this.htmlAnalyzer, strictMode);
}

@@ -16,0 +16,0 @@ makeContentLowerCase() {

{
"name": "seord",
"version": "0.0.3",
"version": "0.0.4",
"description": "Advanced SEO Analyzer",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -32,2 +32,3 @@ # SEO Analyzer - SEOrd

- Checks for meta description length, placement, keyword density, and keyword frequency
- Headings Analysis `(H1, H2, H3, H4, H5, H6)` on the basis of keyword and sub keywords, their density, and usage

@@ -76,2 +77,3 @@ ## Usage

console.log(`\nMinor Warnings: ${result.messages.minorWarnings.length}`);

@@ -98,8 +100,8 @@ result.messages.minorWarnings.forEach((error) => {

The result of the above example will be:
```text
```yaml
Warnings: 7
- The density of sub keyword "car insurance" is too high in the content, i.e. 2.34%.
- The density of sub keyword "rates" is too high in the content, i.e. 4.28%.
- The density of sub keyword "premiums" is too high in the content, i.e. 1.38%.
- The density of sub keyword "us" is too high in the content, i.e. 1.38%.
- The density of sub keyword "car insurance" is too high in the content, i.e. 2.37%.
- The density of sub keyword "rates" is too high in the content, i.e. 4.18%.
- The density of sub keyword "premiums" is too high in the content, i.e. 1.39%.
- The density of sub keyword "us" is too high in the content, i.e. 1.39%.
- Not enough internal links. You only have 1 unique internal links, try increasing it.

@@ -109,7 +111,7 @@ - Not enough outbound links. You only have 0, try increasing it.

Good Points: 14
Good Points: 25
- Good, your content has a keyword "progressive".
- Keyword density is 1.52%.
- Keyword density is 1.39%.
- Good, your content has sub keywords "car insurance, rates, premiums, save money, us".
- The density of sub keyword "save money" is 0.55% in the content, which is good.
- The density of sub keyword "save money" is 0.56% in the content, which is good.
- Title tag is 49 characters long.

@@ -125,12 +127,82 @@ - Keyword density in title is 12.50%, which is good.

- The density of sub keyword "us" in meta description is 3.45%.
- Keyword "progressive" found in H1 tag "does progressive raise your rates after 6 months?".
- Sub keyword "car insurance" found in H3 tag "2. How can I
lower my Progressive car insurance rates?", which is good.
- Sub keyword "rates" found in H3 tag "2. How can I
lower my Progressive car insurance rates?", which is good.
- Sub keyword "car insurance" found in H3 tag "3. Can I switch car insurance providers if my rates increase?", which is good.
- Sub keyword "rates" found in H3 tag "3. Can I switch car insurance providers if my rates increase?", which is good.
- Sub keyword "us" found in H2 tag "Conclusion", which is good.
- Sub keyword "rates" found in H1 tag "does progressive raise your rates after 6 months?", which is good.
- You have 9 this.headings.
- Nice. You have h1 tag, which is essential.
- Nice. You have h2 tag, which is essential.
- You have h3 tag, which is good.
Minor Warnings: 1
Minor Warnings: 48
- Meta description does not start with keyword. It starts with "find out if progress", try starting with keyword. Not starting with keyword is not a big issue, but it is recommended to start with keyword.
- Keyword "progressive" not found in H2 tag "How Are Car Insurance Rates Determined?".
- Keyword "progressive" not found in H2 tag "Does Progressive Raise Your Rates?".
- Keyword "progressive" not found in H3 tag "How to Save Money on Car Insurance in
the US".
- Keyword "progressive" not found in H2 tag "Frequently Asked Questions".
- Keyword "progressive" not found in H3 tag "1. Does Progressive offer accident forgiveness?".
- Keyword "progressive" not found in H3 tag "2. How can I
lower my Progressive car insurance rates?".
- Keyword "progressive" not found in H3 tag "3. Can I switch car insurance providers if my rates increase?".
- Keyword "progressive" not found in H2 tag "Conclusion".
- Sub keyword "car insurance" not found in H2 tag "How Are Car Insurance Rates Determined?".
- Sub keyword "rates" not found in H2 tag "How Are Car Insurance Rates Determined?".
- Sub keyword "premiums" not found in H2 tag "How Are Car Insurance Rates Determined?".
- Sub keyword "save money" not found in H2 tag "How Are Car Insurance Rates Determined?".
- Sub keyword "us" not found in H2 tag "How Are Car Insurance Rates Determined?".
- Sub keyword "car insurance" not found in H2 tag "Does Progressive Raise Your Rates?".
- Sub keyword "rates" not found in H2 tag "Does Progressive Raise Your Rates?".
- Sub keyword "premiums" not found in H2 tag "Does Progressive Raise Your Rates?".
- Sub keyword "save money" not found in H2 tag "Does Progressive Raise Your Rates?".
- Sub keyword "us" not found in H2 tag "Does Progressive Raise Your Rates?".
- Sub keyword "car insurance" not found in H3 tag "How to Save Money on Car Insurance in
the US".
- Sub keyword "rates" not found in H3 tag "How to Save Money on Car Insurance in
the US".
- Sub keyword "premiums" not found in H3 tag "How to Save Money on Car Insurance in
the US".
- Sub keyword "save money" not found in H3 tag "How to Save Money on Car Insurance in
the US".
- Sub keyword "us" not found in H3 tag "How to Save Money on Car Insurance in
the US".
- Sub keyword "car insurance" not found in H2 tag "Frequently Asked Questions".
- Sub keyword "rates" not found in H2 tag "Frequently Asked Questions".
- Sub keyword "premiums" not found in H2 tag "Frequently Asked Questions".
- Sub keyword "save money" not found in H2 tag "Frequently Asked Questions".
- Sub keyword "us" not found in H2 tag "Frequently Asked Questions".
- Sub keyword "car insurance" not found in H3 tag "1. Does Progressive offer accident forgiveness?".
- Sub keyword "rates" not found in H3 tag "1. Does Progressive offer accident forgiveness?".
- Sub keyword "premiums" not found in H3 tag "1. Does Progressive offer accident forgiveness?".
- Sub keyword "save money" not found in H3 tag "1. Does Progressive offer accident forgiveness?".
- Sub keyword "us" not found in H3 tag "1. Does Progressive offer accident forgiveness?".
- Sub keyword "premiums" not found in H3 tag "2. How can I
lower my Progressive car insurance rates?".
- Sub keyword "save money" not found in H3 tag "2. How can I
lower my Progressive car insurance rates?".
- Sub keyword "us" not found in H3 tag "2. How can I
lower my Progressive car insurance rates?".
- Sub keyword "premiums" not found in H3 tag "3. Can I switch car insurance providers if my rates increase?".
- Sub keyword "save money" not found in H3 tag "3. Can I switch car insurance providers if my rates increase?".
- Sub keyword "us" not found in H3 tag "3. Can I switch car insurance providers if my rates increase?".
- Sub keyword "car insurance" not found in H2 tag "Conclusion".
- Sub keyword "rates" not found in H2 tag "Conclusion".
- Sub keyword "premiums" not found in H2 tag "Conclusion".
- Sub keyword "save money" not found in H2 tag "Conclusion".
- Sub keyword "car insurance" not found in H1 tag "does progressive raise your rates after 6 months?".
- Sub keyword "premiums" not found in H1 tag "does progressive raise your rates after 6 months?".
- Sub keyword "save money" not found in H1 tag "does progressive raise your rates after 6 months?".
- Sub keyword "us" not found in H1 tag "does progressive raise your rates after 6 months?".
SEO Score: 66.66666666666666
SEO Score: 78.125
Keyword SEO Score: 100
Keyword Density: 1.5172413793103448
Sub Keyword Density: (car insurance 2.344827586206897),(rates 4.275862068965517),(premiums 1.3793103448275863),(save money 0.5517241379310345),(us 1.3793103448275863)
Keyword Frequency: 11
Word Count: 725
Keyword Density: 1.392757660167131
Sub Keyword Density: (car insurance 2.3676880222841223),(rates 4.178272980501393),(premiums 1.392757660167131),(save money 0.5571030640668524),(us 1.392757660167131)
Keyword Frequency: 10
Word Count: 718
Total Links: 1

@@ -137,0 +209,0 @@ ```

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc