update sitemap
This commit is contained in:
parent
c9f31c4664
commit
31ec0e85da
@ -79,7 +79,7 @@ let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL;
|
|||||||
|
|
||||||
|
|
||||||
<div class="z-1 absolute top-5">
|
<div class="z-1 absolute top-5">
|
||||||
<img class="w-36 ml-2" src={cloudFrontUrl+'/assets/donation_logo.png'} alt="logo">
|
<img class="w-32 sm:w-36 ml-3 sm:ml-2" src={cloudFrontUrl+'/assets/donation_logo.png'} alt="logo">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- End Column -->
|
<!-- End Column -->
|
||||||
|
|||||||
@ -1,153 +1,154 @@
|
|||||||
import { userRegion } from '$lib/store';
|
import { userRegion } from "$lib/store";
|
||||||
|
|
||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
const usRegion = ["cle1", "iad1", "pdx1", "sfo1"];
|
||||||
let apiURL;
|
let apiURL;
|
||||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||||
|
|
||||||
userRegion.subscribe(value => {
|
userRegion.subscribe((value) => {
|
||||||
if (usRegion.includes(value)) {
|
if (usRegion.includes(value)) {
|
||||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||||
} else {
|
} else {
|
||||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
runtime: 'nodejs20.x',
|
runtime: "nodejs20.x",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const pages = [
|
const pages = [
|
||||||
{title: "/"},
|
{ title: "/" },
|
||||||
{title: "/cramer-tracker"},
|
{ title: "/cramer-tracker" },
|
||||||
{title: "/reddit-tracker"},
|
{ title: "/reddit-tracker" },
|
||||||
{title: "/most-shorted-stocks"},
|
{ title: "/corporate-lobbying-tracker" },
|
||||||
{title: "/stocks"},
|
{ title: "/most-shorted-stocks" },
|
||||||
{title: "/etf"},
|
{ title: "/stocks" },
|
||||||
{title: "/crypto"},
|
{ title: "/etf" },
|
||||||
{title: "/etf/etf-providers"},
|
{ title: "/crypto" },
|
||||||
{title: "/etf/new-launches"},
|
{ title: "/etf/etf-providers" },
|
||||||
{title: "/trending"},
|
{ title: "/etf/new-launches" },
|
||||||
{title: "/price-alert"},
|
{ title: "/trending" },
|
||||||
{title: "/heatmaps"},
|
{ title: "/price-alert" },
|
||||||
{title: "/portfolio"},
|
{ title: "/heatmaps" },
|
||||||
{title: "/newsletter"},
|
{ title: "/donation" },
|
||||||
{title: "/options-flow"},
|
//{title: "/portfolio"},
|
||||||
{title: "/options-zero-dte"},
|
{ title: "/newsletter" },
|
||||||
{title: "/ipos"},
|
{ title: "/options-flow" },
|
||||||
{title: "/list"},
|
{ title: "/options-zero-dte" },
|
||||||
{title: "/list/mega-cap-stocks"},
|
{ title: "/ipos" },
|
||||||
{title: "/list/large-cap-stocks"},
|
{ title: "/list" },
|
||||||
{title: "/list/mid-cap-stocks"},
|
{ title: "/list/dividend-kings" },
|
||||||
{title: "/list/small-cap-stocks"},
|
{ title: "/list/dividend-aristocrats" },
|
||||||
{title: "/list/micro-cap-stocks"},
|
{ title: "/list/magnificent-seven" },
|
||||||
{title: "/list/nano-cap-stocks"},
|
{ title: "/list/mega-cap-stocks" },
|
||||||
{title: "/list/nasdaq-stocks"},
|
{ title: "/list/large-cap-stocks" },
|
||||||
{title: "/list/nyse-stocks"},
|
{ title: "/list/mid-cap-stocks" },
|
||||||
{title: "/list/xetra-stocks"},
|
{ title: "/list/small-cap-stocks" },
|
||||||
{title: "/list/nasdaq-100-stocks"},
|
{ title: "/list/micro-cap-stocks" },
|
||||||
{title: "/list/dow-jones-stocks"},
|
{ title: "/list/nano-cap-stocks" },
|
||||||
{title: "/list/sp-500-stocks"},
|
{ title: "/list/nasdaq-stocks" },
|
||||||
{title: "/list/canadian-stocks-us"},
|
{ title: "/list/nyse-stocks" },
|
||||||
{title: "/list/chinese-stocks-us"},
|
{ title: "/list/xetra-stocks" },
|
||||||
{title: "/list/indian-stocks-us"},
|
{ title: "/list/nasdaq-100-stocks" },
|
||||||
{title: "/list/japanese-stocks-us"},
|
{ title: "/list/dow-jones-stocks" },
|
||||||
{title: "/list/german-stocks-us"},
|
{ title: "/list/sp-500-stocks" },
|
||||||
{title: "/list/israeli-stocks-us"},
|
{ title: "/list/canadian-stocks-us" },
|
||||||
{title: "/list/uk-stocks-us"},
|
{ title: "/list/chinese-stocks-us" },
|
||||||
{title: "/list/financial-sector"},
|
{ title: "/list/indian-stocks-us" },
|
||||||
{title: "/list/healthcare-sector"},
|
{ title: "/list/japanese-stocks-us" },
|
||||||
{title: "/list/technology-sector"},
|
{ title: "/list/german-stocks-us" },
|
||||||
{title: "/list/industrials-sector"},
|
{ title: "/list/israeli-stocks-us" },
|
||||||
{title: "/list/energy-sector"},
|
{ title: "/list/uk-stocks-us" },
|
||||||
{title: "/list/utilities-sector"},
|
{ title: "/list/financial-sector" },
|
||||||
{title: "/list/consumer-cyclical-sector"},
|
{ title: "/list/healthcare-sector" },
|
||||||
{title: "/list/real-estate-sector"},
|
{ title: "/list/technology-sector" },
|
||||||
{title: "/list/basic-materials-sector"},
|
{ title: "/list/industrials-sector" },
|
||||||
{title: "/list/communication-services-sector"},
|
{ title: "/list/energy-sector" },
|
||||||
{title: "/list/consumer-defensive-sector"},
|
{ title: "/list/utilities-sector" },
|
||||||
{title: "/list/delisted-stocks"},
|
{ title: "/list/consumer-cyclical-sector" },
|
||||||
{title: "/list/bitcoin-etfs"},
|
{ title: "/list/real-estate-sector" },
|
||||||
{title: "/stock-screener"},
|
{ title: "/list/basic-materials-sector" },
|
||||||
{title: "/market-news"},
|
{ title: "/list/communication-services-sector" },
|
||||||
{title: "/market-news/crypto"},
|
{ title: "/list/consumer-defensive-sector" },
|
||||||
{title: "/market-news/general"},
|
{ title: "/list/delisted-stocks" },
|
||||||
{title: "/earnings-calendar"},
|
{ title: "/list/bitcoin-etfs" },
|
||||||
{title: "/economic-calendar"},
|
{ title: "/stock-screener" },
|
||||||
{title: "/dividends-calendar"},
|
{ title: "/market-news" },
|
||||||
{title: "/stock-splits-calendar"},
|
{ title: "/market-news/crypto" },
|
||||||
{title: "/market-mover"},
|
{ title: "/market-news/general" },
|
||||||
{title: "/community"},
|
{ title: "/earnings-calendar" },
|
||||||
{title: "/community/create-post"},
|
{ title: "/economic-calendar" },
|
||||||
{title: "/hedge-funds"},
|
{ title: "/dividends-calendar" },
|
||||||
{title: "/login"},
|
{ title: "/stock-splits-calendar" },
|
||||||
{title: "/register"},
|
{ title: "/market-mover" },
|
||||||
{title: "/watchlist"},
|
{ title: "/community" },
|
||||||
{title: "/leaderboard"},
|
{ title: "/community/create-post" },
|
||||||
{title: "/tournament-rules"},
|
{ title: "/hedge-funds" },
|
||||||
{title: "/pricing"},
|
{ title: "/login" },
|
||||||
{title: "/terms-of-use"},
|
{ title: "/register" },
|
||||||
{title: "/privacy-policy"},
|
{ title: "/watchlist" },
|
||||||
{title: "/imprint"},
|
//{ title: "/leaderboard" },
|
||||||
{title: "/about"},
|
//{ title: "/tournament-rules" },
|
||||||
{title: "/contact"},
|
{ title: "/pricing" },
|
||||||
{title: "/blog"},
|
{ title: "/terms-of-use" },
|
||||||
{title: "/politicians"},
|
{ title: "/privacy-policy" },
|
||||||
{title: "/politicians/flow-data"},
|
{ title: "/imprint" },
|
||||||
{title: "/analysts"},
|
{ title: "/about" },
|
||||||
{title: "/analysts/top-stocks"},
|
{ title: "/contact" },
|
||||||
|
{ title: "/blog" },
|
||||||
|
{ title: "/politicians" },
|
||||||
|
{ title: "/politicians/flow-data" },
|
||||||
|
{ title: "/analysts" },
|
||||||
|
{ title: "/analysts/top-stocks" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const site = "https://stocknear.com"
|
const site = "https://stocknear.com";
|
||||||
const website = "https://stocknear.com"
|
const website = "https://stocknear.com";
|
||||||
|
|
||||||
|
|
||||||
/** @type {import('./$types').RequestHandler} */
|
/** @type {import('./$types').RequestHandler} */
|
||||||
export async function GET({locals}) {
|
export async function GET({ locals }) {
|
||||||
|
//get all posts;
|
||||||
|
|
||||||
|
const outputPost = await locals.pb.collection("posts").getFullList();
|
||||||
|
|
||||||
//get all posts;
|
const outputBlogPost = await locals.pb.collection("articles").getFullList();
|
||||||
|
|
||||||
const outputPost = await locals.pb.collection('posts').getFullList() ;
|
const posts = outputPost?.map((item) => ({
|
||||||
|
id: item.id,
|
||||||
|
}));
|
||||||
|
|
||||||
const outputBlogPost = await locals.pb.collection('articles').getFullList() ;
|
const articles = outputBlogPost?.map((item) => ({
|
||||||
|
id: item.id,
|
||||||
|
}));
|
||||||
|
|
||||||
const posts = outputPost?.map(item => ({
|
const rawData = await fetch(apiURL + "/searchbar-data", {
|
||||||
id: item.id,
|
method: "GET",
|
||||||
}));
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-API-KEY": apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const outputStocks = await rawData.json();
|
||||||
|
const stocks = outputStocks?.map((item) => ({
|
||||||
|
id: item?.symbol,
|
||||||
|
type: item?.type,
|
||||||
|
}));
|
||||||
|
|
||||||
const articles = outputBlogPost?.map(item => ({
|
const body = sitemap(posts, articles, stocks, pages);
|
||||||
id: item.id,
|
const response = new Response(body);
|
||||||
}));
|
response.headers.set("Cache-Control", "max-age=0, s-maxage=3600");
|
||||||
|
response.headers.set("Content-Type", "application/xml");
|
||||||
|
return response;
|
||||||
const rawData = await fetch(apiURL+'/searchbar-data', {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json","X-API-KEY": apiKey
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const outputStocks = await rawData.json();
|
|
||||||
const stocks = outputStocks?.map(item => ({
|
|
||||||
id: item?.symbol,
|
|
||||||
type: item?.type
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const body = sitemap(posts, articles, stocks, pages);
|
|
||||||
const response = new Response(body);
|
|
||||||
response.headers.set('Cache-Control', 'max-age=0, s-maxage=3600');
|
|
||||||
response.headers.set('Content-Type', 'application/xml');
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modified sitemap function
|
// Modified sitemap function
|
||||||
const sitemap = (posts, articles, stocks, pages) => `<?xml version="1.0" encoding="UTF-8" ?>
|
const sitemap = (
|
||||||
|
posts,
|
||||||
|
articles,
|
||||||
|
stocks,
|
||||||
|
pages
|
||||||
|
) => `<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<urlset
|
<urlset
|
||||||
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
|
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
|
||||||
xmlns:news="https://www.google.com/schemas/sitemap-news/0.9"
|
xmlns:news="https://www.google.com/schemas/sitemap-news/0.9"
|
||||||
@ -156,28 +157,47 @@ const sitemap = (posts, articles, stocks, pages) => `<?xml version="1.0" encodin
|
|||||||
xmlns:image="https://www.google.com/schemas/sitemap-image/1.1"
|
xmlns:image="https://www.google.com/schemas/sitemap-image/1.1"
|
||||||
xmlns:video="https://www.google.com/schemas/sitemap-video/1.1"
|
xmlns:video="https://www.google.com/schemas/sitemap-video/1.1"
|
||||||
>
|
>
|
||||||
${pages.map((page) => `
|
${pages
|
||||||
|
.map(
|
||||||
|
(page) => `
|
||||||
<url>
|
<url>
|
||||||
<loc>${website}${page.title}</loc>
|
<loc>${website}${page.title}</loc>
|
||||||
</url>
|
</url>
|
||||||
`).join('')}
|
`
|
||||||
${stocks.map((ticker) => {
|
)
|
||||||
// Determine the path based on the type of the ticker
|
.join("")}
|
||||||
const path = ticker.type === 'Stock' ? '/stocks/' : ticker.type === 'ETF' ? '/etf/' : '/stocks/';
|
${stocks
|
||||||
return `
|
.map((ticker) => {
|
||||||
|
// Determine the path based on the type of the ticker
|
||||||
|
const path =
|
||||||
|
ticker.type === "Stock"
|
||||||
|
? "/stocks/"
|
||||||
|
: ticker.type === "ETF"
|
||||||
|
? "/etf/"
|
||||||
|
: "/stocks/";
|
||||||
|
return `
|
||||||
<url>
|
<url>
|
||||||
<loc>${website}${path}${ticker.id}</loc>
|
<loc>${website}${path}${ticker.id}</loc>
|
||||||
</url>
|
</url>
|
||||||
`;
|
`;
|
||||||
}).join('')}
|
})
|
||||||
${articles.map((article) => `
|
.join("")}
|
||||||
|
${articles
|
||||||
|
.map(
|
||||||
|
(article) => `
|
||||||
<url>
|
<url>
|
||||||
<loc>${website}/blog/article/${article.id}</loc>
|
<loc>${website}/blog/article/${article.id}</loc>
|
||||||
</url>
|
</url>
|
||||||
`).join('')}
|
`
|
||||||
${posts.map((post) => `
|
)
|
||||||
|
.join("")}
|
||||||
|
${posts
|
||||||
|
.map(
|
||||||
|
(post) => `
|
||||||
<url>
|
<url>
|
||||||
<loc>${website}/community/post/${post.id}</loc>
|
<loc>${website}/community/post/${post.id}</loc>
|
||||||
</url>
|
</url>
|
||||||
`).join('')}
|
`
|
||||||
</urlset>`;
|
)
|
||||||
|
.join("")}
|
||||||
|
</urlset>`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user