提交 3ca1a674 编写于 作者: D DCloud_LXH

feat: create sitemap

上级 7850a59f
......@@ -46,7 +46,7 @@ function parseBar(tab, file, options) {
}
}
link = path.join('/', link.replace(/\.md\b/, '.html')
link = path.join('/', link.replace(/\.md\b/, '')
.replace(/\bREADME\b/, '')
.replace(/\/index/, '/')
.replace(/\?id=/, '#'))
......
const fs = require('fs')
const path = require('path')
const domain = 'https://zh.uniapp.dcloud.io'
const domain = 'https://doc.dcloud.net.cn'
const xmlBefore = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
`
......@@ -9,6 +9,7 @@ const xmlAfter = `\n</urlset>`
module.exports = (links, callback = () => { }) => {
const xmlItems = links.map(url => {
if (!url.endsWith('/') && !url.endsWith('html')) url += '.html'
return ` <url>
<loc>${domain + url}</loc>
</url>`
......
{
"name": "unidocs-uni-app-x-zh-zh",
"name": "unidocs-uni-app-x-zh",
"version": "1.0.0",
"description": "",
"main": "index.js",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册