Skip to content

Commit

Permalink
sitemap problem solved
Browse files Browse the repository at this point in the history
  • Loading branch information
SH20RAJ authored Mar 18, 2024
1 parent 6360894 commit f1a6c8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/app/sitemap/3rd/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ function generateRandomNumber(min, max) {
// then add min to ensure the number falls within the desired range.
return Math.floor(Math.random() * (max - min + 1)) + min;
}

console.log(generateRandomNumber(1,1000))
// Mock function to fetch articles (replace this with your actual implementation)
let getArticlesFromDevTo = async () => {
const response = await fetch(
`https://dev.to/api/articles/latest/?per_page=2000&page=${generateRandomNumber(1,1000)}`
`https://dev.to/api/articles/latest/?per_page=2000&page=${generateRandomNumber(1,1000).toString() || 54}`
);
const data = await response.json();
return data;
Expand Down
13 changes: 4 additions & 9 deletions src/app/sitemap/[id]/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ function generateRandomNumber(min, max) {
// then add min to ensure the number falls within the desired range.
return Math.floor(Math.random() * (max - min + 1)) + min;
}

// Usage example to generate a random number between 1 and 10000
const randomNumber = generateRandomNumber(1, 1000);
console.log(randomNumber);

console.log(generateRandomNumber(1,1000))
// Mock function to fetch articles (replace this with your actual implementation)
let getArticlesFromDevTo = async (params) => {
console.log(params);
let getArticlesFromDevTo = async () => {
const response = await fetch(
`https://dev.to/api/articles/latest/?per_page=1000&page=${randomNumber}`
`https://dev.to/api/articles/latest/?per_page=2000&page=${generateRandomNumber(1,1000).toString() || 54}`
);
const data = await response.json();
return data;
Expand All @@ -34,7 +29,7 @@ export async function GET(req) {
// Add each article URL to the sitemap
articles.forEach((article) => {
xml += '<url>';
xml += `<loc>https://dev-art.vercel.app${article.path}</loc>`; // Modify URL structure as needed
xml += `<loc>https://www.forn.fun${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
Expand Down

0 comments on commit f1a6c8e

Please sign in to comment.