-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71849e1
commit a02181d
Showing
17 changed files
with
203 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from "../functions/index.js"; | ||
export * from "./analyzers/index.js"; | ||
export * from "./functions/index.js"; | ||
export * from "./checkContent/index.js"; | ||
export * from "./prepareHTML.js"; | ||
export * from "./sections/index.js"; |
File renamed without changes.
2 changes: 0 additions & 2 deletions
2
packages/landing-friend-core/src/utils/searchDuplicated/functions/index.ts
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
...anding-friend-core/src/utils/searchDuplicated/generateHtmlContent/generateContentToRow.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { DuplicatedContentWithName, DuplicatedSearchName } from "@/index.js"; | ||
|
||
const nameChanger = (name: DuplicatedSearchName) => { | ||
return name === DuplicatedSearchName.SameMetaDesc | ||
? "Found duplicated meta description" | ||
: name === DuplicatedSearchName.SamePage | ||
? "Found duplicated pages" | ||
: "Found duplicated page title"; | ||
}; | ||
|
||
interface GenerateContent { | ||
contentWithOption: DuplicatedContentWithName; | ||
name: DuplicatedSearchName; | ||
} | ||
|
||
export const generateContentToRow = ({ contentWithOption, name }: GenerateContent) => { | ||
const value = contentWithOption[name]; | ||
if (!value) return; | ||
return { | ||
numberOfErrors: value.numberOfDuplicates, | ||
content: ` | ||
<tr> | ||
<td>${nameChanger(name)}: <strong>${value.numberOfDuplicates}</strong></td> | ||
<td>${value.duplicatesOnSite.map(d => `<div style="padding: 2px 0;">${d}</div>`).join("")}</td> | ||
</tr> | ||
`, | ||
}; | ||
}; |
58 changes: 58 additions & 0 deletions
58
packages/landing-friend-core/src/utils/searchDuplicated/generateHtmlContent/generateRow.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { DuplicatedSearchName, FileWithDuplicateContent, generateContentToRow } from "@/index.js"; | ||
|
||
interface Row { | ||
fileWithContent: FileWithDuplicateContent; | ||
tableIndex: number; | ||
} | ||
|
||
export const generateRow = ({ fileWithContent, tableIndex }: Row): string => { | ||
let rows = ""; | ||
if (!fileWithContent) return ""; | ||
|
||
const row = Object.entries(fileWithContent).map(([fileName, contentWithOption]) => { | ||
let allErrors = 0; | ||
let contentToRow = ""; | ||
for (const name of Object.values(DuplicatedSearchName)) { | ||
const data = generateContentToRow({ contentWithOption, name }); | ||
if (data) { | ||
allErrors += data.numberOfErrors; | ||
contentToRow += data.content; | ||
} | ||
} | ||
|
||
return ` | ||
<table> | ||
<thead> | ||
<tr> | ||
<th colspan="2"> | ||
${fileName} | Number of errors: (${allErrors}) | ||
<span class="toggle-button" id="toggle-button-${tableIndex}">▼</span> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody id="toggle-body-${tableIndex}" class="hidden"> | ||
${contentToRow} | ||
</tbody> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", () => { | ||
const toggleButton = document.getElementById("toggle-button-${tableIndex}"); | ||
const toggleBody = document.getElementById("toggle-body-${tableIndex}"); | ||
toggleButton && | ||
toggleBody && | ||
toggleButton.addEventListener("click", () => { | ||
if (toggleBody.classList.contains("hidden")) { | ||
toggleBody.classList.remove("hidden"); | ||
toggleButton.textContent = "▲"; | ||
} else { | ||
toggleBody.classList.add("hidden"); | ||
toggleButton.textContent = "▼"; | ||
} | ||
}); | ||
}) | ||
</script> | ||
</table> | ||
`; | ||
}); | ||
rows = rows + row.join(""); | ||
return rows; | ||
}; |
12 changes: 12 additions & 0 deletions
12
packages/landing-friend-core/src/utils/searchDuplicated/generateHtmlContent/generateRows.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { FileWithDuplicateContent, generateRow } from "@/index.js"; | ||
|
||
export const generateRows = (dataArray: FileWithDuplicateContent[]) => { | ||
let rows = ""; | ||
dataArray | ||
.map((fileWithContent, tableIndex) => { | ||
rows = rows + generateRow({ fileWithContent, tableIndex }); | ||
}) | ||
.join(""); | ||
|
||
return rows; | ||
}; |
3 changes: 3 additions & 0 deletions
3
packages/landing-friend-core/src/utils/searchDuplicated/generateHtmlContent/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./generateContentToRow.js"; | ||
export * from "./generateRow.js"; | ||
export * from "./generateRows.js"; |
File renamed without changes.
5 changes: 4 additions & 1 deletion
5
packages/landing-friend-core/src/utils/searchDuplicated/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export * from "./functions/index.js"; | ||
export * from "./findAndStoreDuplicates.js"; | ||
export * from "./generateHtmlContent/index.js"; | ||
export * from "./getContent.js"; | ||
export * from "./prepareDuplicatedHtml.js"; |
80 changes: 80 additions & 0 deletions
80
packages/landing-friend-core/src/utils/searchDuplicated/prepareDuplicatedHtml.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { FileWithDuplicateContent, generateRows } from "@/index.js"; | ||
|
||
interface Props { | ||
dataArray: FileWithDuplicateContent[]; | ||
domain: string; | ||
} | ||
|
||
export const prepareDuplicatedHtml = ({ dataArray, domain }: Props): string => { | ||
const rows = generateRows(dataArray); | ||
|
||
return ` | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>SEO analyze</title> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 20px; | ||
background-color: #f9f9f9; | ||
} | ||
h1 { | ||
margin-bottom: 20px; | ||
} | ||
h4 { | ||
word-break: break-word; | ||
margin-bottom: 12px; | ||
} | ||
table { | ||
border-collapse: collapse; | ||
width: 100%; | ||
margin: 30px 0px 60px; | ||
} | ||
th, | ||
td { | ||
border: 1px solid black; | ||
padding: 8px; | ||
text-align: left; | ||
justify-content: space-between; | ||
} | ||
th { | ||
background-color: #f2f2f2; | ||
} | ||
tr:nth-child(even) { | ||
background-color: #f2f2f2; | ||
} | ||
.center { | ||
text-align: center; | ||
} | ||
.toggle-button { | ||
cursor: pointer; | ||
} | ||
.hidden { | ||
display: none; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Duplicated pages for ${domain}</h1> | ||
<table> | ||
${rows} | ||
</table> | ||
</body> | ||
</html> | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters