-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsitemap.cfm
33 lines (33 loc) · 849 Bytes
/
sitemap.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!---
site:
url: https://example.com
layout: none
permalink: /sitemap.xml
excludeFromCollections: true
--->
<cfscript>
function getPages(collections){
var ret = collections.all.filter((item) => {
return item.excludeFromCollections == false && (item.type == "page" || item.type == "post");
});
ret.sort( ( e1, e2 ) => {
return compare( e1.permalink, e2.permalink );
} );
return ret;
}
lastMod = dateFormat(now(), "yyyy-mm-dd");
savecontent variable="xml" {
writeOutput('<?xml version="1.0" encoding="UTF-8"?>#chr(10)#');
writeoutput('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">#chr(10)#');
for(var p in getPages(collections)){
writeoutput('
<url>
<loc>#prc.site.url##p.permalink#</loc>
<lastmod>#lastMod#</lastmod>
</url>
');
}
writeoutput('</urlset>#chr(10)#');
}
</cfscript>
<cfoutput>#xml#</cfoutput>