diff --git a/src/app/page.js b/src/app/page.js index 21626ed..54d5670 100644 --- a/src/app/page.js +++ b/src/app/page.js @@ -23,7 +23,7 @@ export default function ArticlesPage() { setIsLoading(true); try { const response = await fetch( - `https://dev.to/api/articles/latest/?per_page=22&page=${page}` + `https://dev.to/api/articles/?per_page=22&page=${page}` ); const data = await response.json(); setArticles((prevArticles) => [...prevArticles, ...data]); diff --git a/src/app/sitemapsh/[id]/route.js b/src/app/sitemapsh/[id]/route.js index ae5b88a..73dff9a 100644 --- a/src/app/sitemapsh/[id]/route.js +++ b/src/app/sitemapsh/[id]/route.js @@ -15,7 +15,7 @@ console.log(randomNumber); let getArticlesFromDevTo = async (params) => { console.log("params", params); const response = await fetch( - `https://dev.to/api/articles/latest/?per_page=100000&page=${ + `https://dev.to/api/articles/?per_page=100000&page=${ params || generateRandomNumber(1, 1000).toString() }` ); diff --git a/src/app/sitemapsh/route.js b/src/app/sitemapsh/route.js index a2691f0..cd4b02f 100644 --- a/src/app/sitemapsh/route.js +++ b/src/app/sitemapsh/route.js @@ -1,36 +1,23 @@ import { NextResponse } from "next/server"; -// Mock function to fetch articles (replace this with your actual implementation) -let getArticlesFromDevTo = async () => { - const response = await fetch( - `https://dev.to/api/articles/?per_page=100000&page=1` - ); - const data = await response.json(); - return data; -}; export async function GET(req) { - if (req.method === "GET") { + if (true) { try { // Fetch articles from Dev.to or your database - const articles = await getArticlesFromDevTo(); // Start building the XML let xml = ''; - xml += - ''; + xml += ''; + + for (let i = 0; i < 1000; i++) { + xml += ""; + xml += `https://sh20raj.com/sitemapsh/${Math.floor(Math.random()*10000)}`; // Modify URL structure as needed + xml += ""; - // Add each article URL to the sitemap - articles.forEach((article) => { - xml += ""; - xml += `https://sh20raj.com${article.path}`; // Modify URL structure as needed - xml += `${new Date(article.published_at).toISOString()}`; // Use published date as last modified - xml += "weekly"; // You can adjust the change frequency - xml += "0.8"; // Priority can be adjusted based on the importance of the page - xml += ""; - }); + } - xml += ""; + xml += ""; // Set the response headers and status return new NextResponse(xml, {