因此,我想将ads.js添加到我的网站,但是Next github中的示例不清楚。有人知道该怎么做吗?这是使用机器人和站点地图的下一个示例:https://github.com/zeit/next.js/tree/canary/examples/with-sitemap-and-robots-express-server
谢谢!
取决于此文件需要存放的位置,您可以执行以下选项之一。
[如果没关系,只需将其用绳子绑在/static
文件夹中,然后将其命名为go.to/stati/ads.txt
将其拖放到/static
文件夹中,并将此脚本添加到自定义服务器中,以通过/ads.txt
go.to/ads.txt
。server.get('/ads.txt', (req, res) => {
const filePath = join(__dirname, 'static/ads.txt')
app.serveStatic(req, res, filePath)
})
server.get('*', (req, res) => handle(req, res))
此解决方案在快递服务器中工作。