Merged in feat/SW-550-sitemap (pull request #981)
feat(SW-550): added sync functionality and sitemap generation * feat(SW-550): added sync functionality and sitemap generation * feat(SW-550): Added support for splitting and saving multiple sitemaps when there are 50000+ urls * feat(SW-550): Updates after PR * feat(SW-550): Added locale to sitemap data * feat(SW-550): Added support for locale based sitemapData * feat(SW-550): Saving alternates of sitemap entries * feat(SW-550): Refactoring to use sitemap utils file * feat(SW-550): Using Netlify.env to get environment variables * feat(SW-550): clarify use of functions Approved-by: Michael Zetterberg
This commit is contained in:
17
netlify/functions/sitemap/index.mts
Normal file
17
netlify/functions/sitemap/index.mts
Normal file
@@ -0,0 +1,17 @@
|
||||
/* eslint-disable import/no-anonymous-default-export */
|
||||
import type { Context } from "@netlify/functions"
|
||||
|
||||
export default async (request: Request, context: Context) => {
|
||||
const { next_run } = await request.json()
|
||||
const SITEMAP_SYNC_SECRET = Netlify.env.get("SITEMAP_SYNC_SECRET")
|
||||
const PUBLIC_URL = Netlify.env.get("PUBLIC_URL")
|
||||
console.info(
|
||||
`Started sitemap sync at: ${new Date().toISOString()}! Next invocation at: ${next_run}`
|
||||
)
|
||||
const headers = new Headers()
|
||||
headers.set("x-sitemap-sync-secret", SITEMAP_SYNC_SECRET!)
|
||||
|
||||
fetch(`${PUBLIC_URL}/api/sitemap`, {
|
||||
headers,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user