-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #255 from Bashamega/fix
GH fix
- Loading branch information
Showing
27 changed files
with
547 additions
and
542 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} | ||
"extends": "next/core-web-vitals" | ||
} |
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
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 |
---|---|---|
|
@@ -7,5 +7,3 @@ | |
tasks: | ||
- init: npm install && npm run build | ||
command: npm run start | ||
|
||
|
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
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,4 +1,4 @@ | ||
module.exports = { | ||
tabWidth: 2, | ||
useTabs: false | ||
useTabs: false, | ||
}; |
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,48 +1,52 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const xml2js = require('xml2js'); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const xml2js = require("xml2js"); | ||
|
||
// Define paths relative to the script folder | ||
const toolsFilePath = path.join(__dirname, '../src/db/tools.json'); | ||
const sitemapFilePath = path.join(__dirname, '../src/app/sitemap.xml'); | ||
const toolsFilePath = path.join(__dirname, "../src/db/tools.json"); | ||
const sitemapFilePath = path.join(__dirname, "../src/app/sitemap.xml"); | ||
|
||
// Read and parse JSON file | ||
const toolsData = JSON.parse(fs.readFileSync(toolsFilePath, 'utf-8')); | ||
const toolsData = JSON.parse(fs.readFileSync(toolsFilePath, "utf-8")); | ||
|
||
// Extract tool links from the JSON data | ||
const toolsLinks = toolsData.map(tool => `https://wdt.adambashaahmednaji.com${tool.link}`); | ||
const toolsLinks = toolsData.map( | ||
(tool) => `https://wdt.adambashaahmednaji.com${tool.link}`, | ||
); | ||
|
||
// Read and parse the sitemap XML file | ||
const sitemapXml = fs.readFileSync(sitemapFilePath, 'utf-8'); | ||
const sitemapXml = fs.readFileSync(sitemapFilePath, "utf-8"); | ||
const parser = new xml2js.Parser(); | ||
|
||
parser.parseString(sitemapXml, (err, result) => { | ||
if (err) throw err; | ||
|
||
// Extract existing links from the sitemap | ||
const existingLinks = result.urlset.url.map(url => url.loc[0]); | ||
|
||
// Find tools that are not in the sitemap | ||
const newTools = toolsLinks.filter(toolLink => !existingLinks.includes(toolLink)); | ||
|
||
// If there are new tools, add them to the sitemap | ||
if (newTools.length > 0) { | ||
newTools.forEach(newTool => { | ||
result.urlset.url.push({ | ||
loc: [newTool], | ||
lastmod: [new Date().toISOString()], | ||
priority: ["0.80"] | ||
}); | ||
}); | ||
|
||
// Convert the updated sitemap back to XML | ||
const builder = new xml2js.Builder(); | ||
const updatedSitemapXml = builder.buildObject(result); | ||
|
||
// Write the updated sitemap back to the file | ||
fs.writeFileSync(sitemapFilePath, updatedSitemapXml); | ||
console.log(`Added ${newTools.length} new tools to the sitemap.`); | ||
} else { | ||
console.log('All tools are already present in the sitemap.'); | ||
} | ||
if (err) throw err; | ||
|
||
// Extract existing links from the sitemap | ||
const existingLinks = result.urlset.url.map((url) => url.loc[0]); | ||
|
||
// Find tools that are not in the sitemap | ||
const newTools = toolsLinks.filter( | ||
(toolLink) => !existingLinks.includes(toolLink), | ||
); | ||
|
||
// If there are new tools, add them to the sitemap | ||
if (newTools.length > 0) { | ||
newTools.forEach((newTool) => { | ||
result.urlset.url.push({ | ||
loc: [newTool], | ||
lastmod: [new Date().toISOString()], | ||
priority: ["0.80"], | ||
}); | ||
}); | ||
|
||
// Convert the updated sitemap back to XML | ||
const builder = new xml2js.Builder(); | ||
const updatedSitemapXml = builder.buildObject(result); | ||
|
||
// Write the updated sitemap back to the file | ||
fs.writeFileSync(sitemapFilePath, updatedSitemapXml); | ||
console.log(`Added ${newTools.length} new tools to the sitemap.`); | ||
} else { | ||
console.log("All tools are already present in the sitemap."); | ||
} | ||
}); |
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
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ const YAML = require("json-to-pretty-yaml"); | |
export default function HTML_JSX() { | ||
const [isDarkMode, setIsDarkMode] = useState(false); | ||
const [value, setValue] = useState( | ||
`{"name": "Alice", "age": 25, "email": "[email protected]", "isStudent": false, "courses": ["Math", "Science", "History"]}` | ||
`{"name": "Alice", "age": 25, "email": "[email protected]", "isStudent": false, "courses": ["Math", "Science", "History"]}`, | ||
); | ||
const handleChange = (val) => { | ||
setValue(val); | ||
|
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
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
Oops, something went wrong.