NUXT 2-动态创建一个带有NUXT AXIOS数据的站点地图

发布于 2025-02-12 14:33:52 字数 912 浏览 1 评论 0原文

有这样的终点。当我发送请求时,响应如下
我正在使用Axios。 当您在标题中给FR时,fr站点地形会来

  http://mysite/api/sitemap   

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
    <url>
        <loc>https://mysite/tr</loc>
        <priority>1.0</priority>
    </url>

    <url>
        <loc>https://mysite/tr/faq/my-faq-1</loc>
        <priority>0.6</priority>
    </url>
   
    <url>
        <loc>https://mysite/tr/blog/my-blog-1</loc>
        <priority>0.6</priority>
    </url>
</urlset>

如何将传入数据作为站点文件写入?

There is such an endpoint. When I send a request, the response is as follows
I am using axios. (When you give FR in the header, FR sitemaps come. When I give EN, EN sitemaps come.)

  http://mysite/api/sitemap   

This is the response I got

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
    <url>
        <loc>https://mysite/tr</loc>
        <priority>1.0</priority>
    </url>

    <url>
        <loc>https://mysite/tr/faq/my-faq-1</loc>
        <priority>0.6</priority>
    </url>
   
    <url>
        <loc>https://mysite/tr/blog/my-blog-1</loc>
        <priority>0.6</priority>
    </url>
</urlset>

sitemap.xml ---- sitemap-en.xml ---- sitemap-fr.xml

How can I write the incoming data as a sitemap file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽袖吟 2025-02-19 14:33:52

您必须使用“@nuxtjs/stitemap”软件包。 ( https://sitemap.nuxtjs.org

You must use "@nuxtjs/sitemap" package. (https://sitemap.nuxtjs.org)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文