谷歌Blogger 归档页面示例及代码

在谷歌博客“此生未命名 - Untitled Life”发现blogger建立网站地图的方法,存留使用:


日志页地址:https://loikein.blogspot.com/2018/11/blogger.html

代码下载页:https://github.com/loikein/Blogger-archive-page-CN/blob/master/blogger-archive-CN.html

模板示例页:https://www.chzi.eu.org/p/sitemap_28.html

代码粘贴如下:

<script type="text/javascript">
function LoadTheArchive(TotalFeed)
{
var PostTitles = new Array();
var PostURLs = new Array();
var PostYears = new Array();
var PostMonths = new Array();
var PostDays = new Array();

if("entry" in TotalFeed.feed)
{
var PostEntries=TotalFeed.feed.entry.length;

document.write("共计发布了 " + PostEntries + " 篇博文<br /><br />");

for(var PostNum=0; PostNum<PostEntries ; PostNum++)
{
var ThisPost = TotalFeed.feed.entry[PostNum];
PostTitles.push(ThisPost.title.$t);
PostYears.push(ThisPost.published.$t.substring(0,4));
PostMonths.push(ThisPost.published.$t.substring(5,7));
PostDays.push(ThisPost.published.$t.substring(8,10));
var ThisPostURL;

for(var LinkNum=0; LinkNum < ThisPost.link.length; LinkNum++)
{
if(ThisPost.link[LinkNum].rel == "alternate")
{
ThisPostURL = ThisPost.link[LinkNum].href;
break
}
}

PostURLs.push(ThisPostURL);
}
}

DisplaytheTOC(PostTitles, PostURLs, PostYears, PostMonths, PostDays);
}

function DisplaytheTOC(PostTitles, PostURLs, PostYears, PostMonths, PostDays)
{
var MonthNames=["一","二","三","四","五","六","七","八","九","十","十一","十二"];
var NumberOfEntries=PostTitles.length;

var currentMonth = "";
var currentYear = "";

for(var EntryNum = 0; EntryNum < NumberOfEntries; EntryNum++)
{
NameOfMonth = MonthNames[parseInt(PostMonths[EntryNum],10)-1];

if (currentMonth != NameOfMonth || currentYear != PostYears[EntryNum]) {
currentMonth = NameOfMonth;
currentYear = PostYears[EntryNum];

document.write("<div class='dateStyle'><br />" + currentYear + "&nbsp;年&nbsp;" + currentMonth + "月</div>");
}

document.write("<a href =" +PostURLs[EntryNum] + "><div class=dayStyle>" + parseInt(PostDays[EntryNum],10) + "&nbsp;日&ensp;</div>" + PostTitles[EntryNum] + "</a><br />");
}
}
</script>

<script src="/feeds/posts/default?start-index=1&amp;max-results=500&amp;alt=json-in-script&amp;callback=LoadTheArchive"></script>
<script src="/feeds/posts/default?start-index=501&amp;max-results=500&amp;alt=json-in-script&amp;callback=LoadTheArchive"></script>
<script src="/feeds/posts/default?start-index=1001&amp;max-results=500&amp;alt=json-in-script&amp;callback=LoadTheArchive"></script>

<!-- css -->
<style type="text/css">
.dayStyle {
color: #757575;
display: inline-block;
width: 4em;
text-align: right;
}
</style>

后一页 前一页