Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Making Table of Contents with Snowman

Hello, I am a new user to twine 2 and I'm trying to create a fixed sidebar that links to the other passages in the story using snowman. Currently I am prepending some html to a fixed ul but I am not sure how to make it link to the passages that they correspond to. Is there an easy solution to this? Thanks.

Comments

  • Basically, any link with a data-passage attribute will act like a link to that passage. Here's one way to do it:
    var links = ['Red', 'Green', 'Blue'];
    
    $(function() {
    	var $list = $('<ul></ul>').css({
    		position: 'fixed',
    		top: '1em',
    		left: '1em',
    		backgroundColor: 'white'
    	});
    	
    	links.forEach(function(name) {
    		var $li = $('<li></li>');
    		
    		$li.append($('<a></a>').text(name).attr('data-passage', name));
    		$list.append($li);
    	});
    	
    	$('body').append($list);
    });
    
Sign In or Register to comment.