table of content
I took another shot at the the toc script. I didn't notice first but blogger provides named anchors for the post which is more suited for a table of content.
It turned out to be rather straightforward:
I used an ol instead of an ul.
some icing on the cake
Having some (pseudo)categories in blogger is fine but the categories still show up in the labels list in the posts.
I removed the category label from the labels list and appended it to the 'posted by... ' line.
Now it really look like there are categories!
It turned out to be rather straightforward:
- select the post via the class 'post'
- for each post find the name attribute of the first anchor
- find the innerhtml of the h3 anchor
- compose a list element and append to an ul
<script type="text/javascript">
$(document).ready(function() {
$('.post').each(function(){
var txt = $(this).find('a:first').attr('name');
var tt = $(this).find('h3 a').text();
var pgltxt = '<li><a href="#' + txt + '">' + tt + '</a></li>';
$('#contentlist ul').append(pgltxt);
});
});
</script>
I used an ol instead of an ul.
some icing on the cake
Having some (pseudo)categories in blogger is fine but the categories still show up in the labels list in the posts.
I removed the category label from the labels list and appended it to the 'posted by... ' line.
//transfer categorie from label list
var lbl = $(this).find('.post-labels a:contains(*)').remove();
var cl = lbl.html();
var ncl = '';
if(cl){ncl = cl.replace(/\*/,' in category ');}
$(this).find('.fn').append(ncl);
//remove leading comma in label list
var lblst = $(this).find('.post-labels').html();
var nlblst = lblst.replace(/Labels\:\n,/,'Labels:');
$(this).find('.post-labels').html(nlblst);
Now it really look like there are categories!
categories in blogger
Comments
Post a Comment