[fix] fix sitemap error
This commit is contained in:
parent
54b9389e63
commit
c6c7284e18
3 changed files with 14 additions and 12 deletions
|
|
@ -1,11 +0,0 @@
|
||||||
import { createReadStream } from 'fs';
|
|
||||||
import { ServerResponse } from 'http';
|
|
||||||
|
|
||||||
const sitemapHandler = async (_, res = ServerResponse) => {
|
|
||||||
const sitemap = createReadStream('./public/sitemap.xml.gz');
|
|
||||||
res.setHeader('content-type', 'application/xml');
|
|
||||||
res.setHeader('content-encoding', 'gzip');
|
|
||||||
sitemap.pipe(res);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default sitemapHandler;
|
|
||||||
|
|
@ -12,7 +12,7 @@ async function generateSitemap() {
|
||||||
sitemap.write({ url: "/", changefreq: "daily", priority: 1.0 });
|
sitemap.write({ url: "/", changefreq: "daily", priority: 1.0 });
|
||||||
sitemap.write({ url: "/about", changefreq: "daily", priority: 0.9 });
|
sitemap.write({ url: "/about", changefreq: "daily", priority: 0.9 });
|
||||||
sitemap.write({ url: "/projects", changefreq: "daily", priority: 0.9 });
|
sitemap.write({ url: "/projects", changefreq: "daily", priority: 0.9 });
|
||||||
sitemap.write({ url: "/projects/archive", changefreq: "daily", priority: 0.9 });
|
sitemap.write({ url: "/projects/archive", changefreq: "daily", priority: 0.7 });
|
||||||
|
|
||||||
sitemap.end();
|
sitemap.end();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,17 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
|
||||||
});
|
});
|
||||||
module.exports = withBundleAnalyzer({
|
module.exports = withBundleAnalyzer({
|
||||||
// your Next.js configuration
|
// your Next.js configuration
|
||||||
|
async headers() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: "/sitemap.xml.gz",
|
||||||
|
headers: [
|
||||||
|
{
|
||||||
|
key: "Content-Type",
|
||||||
|
value: "application/gzip",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue