-
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
930441a
commit 85ee150
Showing
32 changed files
with
542 additions
and
272 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
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 @@ | ||
export const fileLocation = "./SEO"; |
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,20 @@ | ||
export const forbiddenCharacters = [ | ||
"!", | ||
"|", | ||
":", | ||
"ı", | ||
"&", | ||
"<", | ||
">", | ||
""", | ||
"/", | ||
"`", | ||
"‘", | ||
"’", | ||
"‹", | ||
"›", | ||
" ", | ||
"", | ||
"´", | ||
"¸", | ||
]; |
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 "./exclude.js"; | ||
export * from "./filePath.js"; | ||
export * from "./forbiddenChar.js"; | ||
export * from "./staticTags.js"; | ||
export * from "./unicode.js"; |
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,73 @@ | ||
export const staticTags = [ | ||
"a", | ||
"abbr", | ||
"acronym", | ||
"address", | ||
"audio", | ||
"b", | ||
"bdi", | ||
"bdo", | ||
"blockquote", | ||
"br", | ||
"canvas", | ||
"caption", | ||
"cite", | ||
"code", | ||
"col", | ||
"colgroup", | ||
"dd", | ||
"del", | ||
"dfn", | ||
"div", | ||
"dl", | ||
"dt", | ||
"em", | ||
"embed", | ||
"figure", | ||
"figcaption", | ||
"h1", | ||
"h2", | ||
"h3", | ||
"h4", | ||
"h5", | ||
"h6", | ||
"iframe", | ||
"ins", | ||
"kbd", | ||
"li", | ||
"mark", | ||
"noscript", | ||
"object", | ||
"ol", | ||
"p", | ||
"param", | ||
"path", | ||
"picture", | ||
"pre", | ||
"q", | ||
"rp", | ||
"rt", | ||
"ruby", | ||
"samp", | ||
"script", | ||
"small", | ||
"span", | ||
"strong", | ||
"style", | ||
"sub", | ||
"sup", | ||
"svg", | ||
"table", | ||
"tbody", | ||
"td", | ||
"tfoot", | ||
"th", | ||
"thead", | ||
"time", | ||
"track", | ||
"tr", | ||
"ul", | ||
"var", | ||
"video", | ||
"wbr", | ||
]; |
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
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,74 @@ | ||
import fs from "fs"; | ||
import open, { apps } from "open"; | ||
import path from "path"; | ||
|
||
import { | ||
ConfigFile, | ||
fileLocation, | ||
FileName, | ||
fileName, | ||
FileWithDuplicateContent, | ||
getContent, | ||
getHtmlFiles, | ||
matchedSetting, | ||
message, | ||
pathName, | ||
saveFile, | ||
} from "@/index.js"; | ||
|
||
export const searchDuplicated = async (config: ConfigFile, interval?: NodeJS.Timer) => { | ||
const { input, searchDuplicated, excludedPage } = config; | ||
|
||
if (!searchDuplicated) { | ||
return message("Define analyzer in config", "redBright"); | ||
} | ||
|
||
const contentArray: FileWithDuplicateContent[] = []; | ||
|
||
const allHtmlFiles = getHtmlFiles(input, false); | ||
|
||
for (const file of allHtmlFiles) { | ||
if ( | ||
!matchedSetting( | ||
file | ||
.replace("\\", "/") | ||
.replace(/\.html|\.php/g, "") | ||
.replace(/index/g, "") | ||
.replace(/\/$/g, ""), | ||
excludedPage | ||
) | ||
) { | ||
contentArray.push( | ||
await getContent({ | ||
file: file.replace("\\", "/"), | ||
input: input.replace(/\.\//g, ""), | ||
}) | ||
); | ||
} | ||
} | ||
|
||
clearTimeout(interval); | ||
try { | ||
saveFile(pathName(FileName.duplicated, ".json"), JSON.stringify(contentArray, null, 2)); | ||
// saveFile(pathName(FileName.duplicated, ".html"), htmlWithTablesAndCharts); | ||
message( | ||
"Your website has been analyzed, JSON and html files have been generated in ./SEO", | ||
"green" | ||
); | ||
} catch { | ||
message("Failed to create files", "red"); | ||
} finally { | ||
if ( | ||
fs.existsSync(path.join(process.cwd(), fileLocation, fileName(FileName.duplicated, ".html"))) | ||
) { | ||
try { | ||
await open(path.join(process.cwd(), fileLocation, fileName(FileName.duplicated, ".html")), { | ||
app: { name: apps.browser }, | ||
}); | ||
message("The analysis file has been opened in your browser.", "green"); | ||
} catch { | ||
message("Cannot open browser. Please open file manually", "red"); | ||
} | ||
} | ||
} | ||
}; |
Oops, something went wrong.