Major update - simpler file structure, better layouts, moar content
This commit is contained in:
83
src/support/_sitemap.ejs.broken
Normal file
83
src/support/_sitemap.ejs.broken
Normal file
@@ -0,0 +1,83 @@
|
||||
<%
|
||||
/*
|
||||
Not sure it's worth the effort for this ATM.
|
||||
*/
|
||||
|
||||
var
|
||||
generateSitemapList = function(the_head, the_tail) {
|
||||
var
|
||||
sortForIndex = function(a,b) {
|
||||
if (a === 'index.html' || a<b) {
|
||||
return -1;
|
||||
}
|
||||
if (b === 'index.html' || a>b) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
filter = /(\.html$)/,
|
||||
replace = /(\.html$)|(^index\.html$)/,
|
||||
tree = function (head, tail) {
|
||||
var
|
||||
output = '',
|
||||
tree_output = '',
|
||||
data, content;
|
||||
for (var key in head) {
|
||||
var
|
||||
val = head[key];
|
||||
if (key !== '.git') {
|
||||
if (key == '_data') {
|
||||
data = val;
|
||||
} else if (key == '_contents') {
|
||||
content = val;
|
||||
} else {
|
||||
tree_output += tree(val, tail + key + "/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (content && data) {
|
||||
content
|
||||
.sort(sortForIndex)
|
||||
.forEach (function(file) {
|
||||
var
|
||||
slug = file.replace(filter, ""),
|
||||
file_data = data && data[slug] ? data[slug] : {},
|
||||
now = new Date(),
|
||||
show_item = false,
|
||||
title, date;
|
||||
if (filter.test(file)) {
|
||||
show_item = true;
|
||||
if (file_data) {
|
||||
var
|
||||
is_draft = file_data.is_draft || false,
|
||||
is_sys_file = file_data.is_sys_file || false,
|
||||
title = (file_data.title || '').trim();
|
||||
if (is_draft || is_sys_file || title === '') {
|
||||
show_item = false;
|
||||
} else {
|
||||
date = file_data.date_last_mod ? new Date(file_data.date_last_mod) : '';
|
||||
date = date !== '' && file_data.date_pub ? new Date(file_data.date_pub) : '';
|
||||
if ((date && date.getTime() > now.getTime())) {
|
||||
show_item = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (show_item) {
|
||||
output +=
|
||||
(file === 'index.html' ? '\n<ul>' : '') +
|
||||
'\n<li><a href="' + tail + file + '">' + title + '</a></li>\n';
|
||||
}
|
||||
});
|
||||
output += '\n</ul>';
|
||||
}
|
||||
return output + tree_output;
|
||||
};
|
||||
return tree(the_head, the_tail);
|
||||
};
|
||||
%>
|
||||
<h2>Site Map</h2>
|
||||
<ul>
|
||||
<%- generateSitemapList(public, "/") %>
|
||||
</ul>
|
Reference in New Issue
Block a user