Skip to content

Commit

Permalink
all set
Browse files Browse the repository at this point in the history
  • Loading branch information
SH20RAJ authored Mar 25, 2024
1 parent 029112d commit cc513f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 145 deletions.
149 changes: 5 additions & 144 deletions src/app/sitemapsh/[id]/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ console.log(randomNumber);
let getArticlesFromDevTo = async (params) => {
console.log("params", params);
const response = await fetch(
`https://dev.to/api/articles/?per_page=1000&page=${
params || generateRandomNumber(1, 1000).toString()
`https://dev.to/api/articles/latest/?per_page=1000&page=${
0
}`
);
const data = await response.json();
Expand All @@ -28,27 +28,6 @@ export async function GET(req) {
try {
// Fetch articles from Dev.to or your database
let articles = await getArticlesFromDevTo(0);
let articles2 = await getArticlesFromDevTo(328);
let articles3 = await getArticlesFromDevTo(39);
let articles4 = await getArticlesFromDevTo(342);
// let articles5 = await getArticlesFromDevTo(35);
// let articles6 = await getArticlesFromDevTo(122);
// let articles7 = await getArticlesFromDevTo(11);
// let articles8 = await getArticlesFromDevTo(312);
// let articles9 = await getArticlesFromDevTo(31);
// let articles10 = await getArticlesFromDevTo(21);
// let articles11 = await getArticlesFromDevTo();
// let articles12 = await getArticlesFromDevTo(2);
// let articles13 = await getArticlesFromDevTo();
// let articles14 = await getArticlesFromDevTo(2);
// let articles15 = await getArticlesFromDevTo();
// let articles16 = await getArticlesFromDevTo(2);
// let articles17 = await getArticlesFromDevTo();
// let articles18 = await getArticlesFromDevTo(2);
// let articles19 = await getArticlesFromDevTo();
// let articles20 = await getArticlesFromDevTo(2);
// let articles21 = await getArticlesFromDevTo();
// let articles22 = await getArticlesFromDevTo(2);

// Start building the XML
let xml = '<?xml version="1.0" encoding="UTF-8"?>';
Expand All @@ -61,129 +40,11 @@ export async function GET(req) {
xml += `<lastmod>${new Date(
article.published_at
).toISOString()}</lastmod>`; // Use published date as last modified
xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
xml += "<changefreq>daily</changefreq>"; // You can adjust the change frequency
xml += "<priority>1</priority>"; // Priority can be adjusted based on the importance of the page
xml += "</url>";
});
articles2.forEach((article) => {
xml += "<url>";
xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
xml += `<lastmod>${new Date(
article.published_at
).toISOString()}</lastmod>`; // Use published date as last modified
xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
xml += "</url>";
});
articles3.forEach((article) => {
xml += "<url>";
xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
xml += `<lastmod>${new Date(
article.published_at
).toISOString()}</lastmod>`; // Use published date as last modified
xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
xml += "</url>";
});
articles4.forEach((article) => {
xml += "<url>";
xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
xml += `<lastmod>${new Date(
article.published_at
).toISOString()}</lastmod>`; // Use published date as last modified
xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
xml += "</url>";
});
// articles5.forEach((article) => {
// xml += "<url>";
// xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
// xml += `<lastmod>${new Date(
// article.published_at
// ).toISOString()}</lastmod>`; // Use published date as last modified
// xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
// xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
// xml += "</url>";
// });
// articles6.forEach((article) => {
// xml += "<url>";
// xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
// xml += `<lastmod>${new Date(
// article.published_at
// ).toISOString()}</lastmod>`; // Use published date as last modified
// xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
// xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
// xml += "</url>";
// });
// articles7.forEach((article) => {
// xml += "<url>";
// xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
// xml += `<lastmod>${new Date(
// article.published_at
// ).toISOString()}</lastmod>`; // Use published date as last modified
// xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
// xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
// xml += "</url>";
// });
// articles8.forEach((article) => {
// xml += "<url>";
// xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
// xml += `<lastmod>${new Date(
// article.published_at
// ).toISOString()}</lastmod>`; // Use published date as last modified
// xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
// xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
// xml += "</url>";
// });
// (await getArticlesFromDevTo(24)).forEach((article) => {
// xml += "<url>";
// xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
// xml += `<lastmod>${new Date(
// article.published_at
// ).toISOString()}</lastmod>`; // Use published date as last modified
// xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
// xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
// xml += "</url>";
// });

// (await getArticlesFromDevTo(32)).forEach((article) => {
// xml += "<url>";
// xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
// xml += `<lastmod>${new Date(
// article.published_at
// ).toISOString()}</lastmod>`; // Use published date as last modified
// xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
// xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
// xml += "</url>";
// });

// (await getArticlesFromDevTo(23)).forEach((article) => {
// xml += "<url>";
// xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
// xml += `<lastmod>${new Date(
// article.published_at
// ).toISOString()}</lastmod>`; // Use published date as last modified
// xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
// xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
// xml += "</url>";
// });

// (await getArticlesFromDevTo(324)).forEach((article) => {
// xml += "<url>";
// xml += `<loc>https://sh20raj.com${article.path}</loc>`; // Modify URL structure as needed
// xml += `<lastmod>${new Date(
// article.published_at
// ).toISOString()}</lastmod>`; // Use published date as last modified
// xml += "<changefreq>weekly</changefreq>"; // You can adjust the change frequency
// xml += "<priority>0.8</priority>"; // Priority can be adjusted based on the importance of the page
// xml += "</url>";
// });







xml += "</urlset>";

// Set the response headers and status
Expand Down
2 changes: 1 addition & 1 deletion src/app/sitemapsh/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function GET(req) {

for (let i = 0; i < 1000; i++) {
xml += "<sitemap>";
xml += `<loc>https://sh20raj.com/sitemapsh/${Math.floor(Math.random()*10000)}</loc>`; // Modify URL structure as needed
xml += `<loc>https://sh20raj.com/sitemapsh/${Math.floor(Math.random()*1000)}</loc>`; // Modify URL structure as needed
xml += "</sitemap>";

}
Expand Down

0 comments on commit cc513f6

Please sign in to comment.