{"action":"created","issue":{"url":"https://api.github.com/repos/toddmotto/linkjuice/issues/8","repository_url":"https://api.github.com/repos/toddmotto/linkjuice","labels_url":"https://api.github.com/repos/toddmotto/linkjuice/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/toddmotto/linkjuice/issues/8/comments","events_url":"https://api.github.com/repos/toddmotto/linkjuice/issues/8/events","html_url":"https://github.com/toddmotto/linkjuice/issues/8","id":182929991,"number":8,"title":"Table of contents","user":{"login":"klaascuvelier","id":354147,"avatar_url":"https://avatars.githubusercontent.com/u/354147?v=3","gravatar_id":"","url":"https://api.github.com/users/klaascuvelier","html_url":"https://github.com/klaascuvelier","followers_url":"https://api.github.com/users/klaascuvelier/followers","following_url":"https://api.github.com/users/klaascuvelier/following{/other_user}","gists_url":"https://api.github.com/users/klaascuvelier/gists{/gist_id}","starred_url":"https://api.github.com/users/klaascuvelier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klaascuvelier/subscriptions","organizations_url":"https://api.github.com/users/klaascuvelier/orgs","repos_url":"https://api.github.com/users/klaascuvelier/repos","events_url":"https://api.github.com/users/klaascuvelier/events{/privacy}","received_events_url":"https://api.github.com/users/klaascuvelier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-13T23:33:12Z","updated_at":"2016-10-17T19:37:06Z","closed_at":null,"body":"Hi @toddmotto, this a great plugin.\r\n\r\nI was wondering if you ever got the request to get a list of generated links.\r\nI use this plugin myself and wanted to have some sort of \"table of contents\" dynamically generated based upon the links that were generated by your plugin.\r\n\r\nI achieved it this way now:\r\n```js\r\nvar linkNodes = [].slice.call(document.getElementsByClassName(linkjuiceClass));\r\nvar menu = document.getElementById('table-of-contents');\r\n\r\nmenu.innerHTML = linkNodes\r\n    .map(function (node) {\r\n        return '<li><a href=\"' + node.href + '\">' + node.innerHTML + '</a></li>';\r\n    })\r\n    .join('');\r\n```\r\n\r\nThis works, but is obviously not the most desirable way of doing it.\r\nI could also populate an array using the `contentFn` function, but that's very impure.\r\n\r\nAn alternative would be to give the list of links generated (`id` + `title`) as function return or have something link `linkjuice.links` (Array/NodeList) which can be iterated on.\r\n\r\nI can help you implement this if you'd want that, but if I am the only person who ever had this request, you can just ignore this :)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/toddmotto/linkjuice/issues/comments/254310347","html_url":"https://github.com/toddmotto/linkjuice/issues/8#issuecomment-254310347","issue_url":"https://api.github.com/repos/toddmotto/linkjuice/issues/8","id":254310347,"user":{"login":"toddmotto","id":1655968,"avatar_url":"https://avatars.githubusercontent.com/u/1655968?v=3","gravatar_id":"","url":"https://api.github.com/users/toddmotto","html_url":"https://github.com/toddmotto","followers_url":"https://api.github.com/users/toddmotto/followers","following_url":"https://api.github.com/users/toddmotto/following{/other_user}","gists_url":"https://api.github.com/users/toddmotto/gists{/gist_id}","starred_url":"https://api.github.com/users/toddmotto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toddmotto/subscriptions","organizations_url":"https://api.github.com/users/toddmotto/orgs","repos_url":"https://api.github.com/users/toddmotto/repos","events_url":"https://api.github.com/users/toddmotto/events{/privacy}","received_events_url":"https://api.github.com/users/toddmotto/received_events","type":"User","site_admin":false},"created_at":"2016-10-17T19:37:06Z","updated_at":"2016-10-17T19:37:06Z","body":"Well, people might want to use it without generating a TOC. So the idea is they'd do (at the top of their document):\r\n\r\n```html\r\n<!-- blog title etc -->\r\n<div class=\"toc\"></div>\r\n<!-- blog content -->\r\n```\r\n\r\nAnd then the `init`:\r\n\r\n```js\r\nlinkjuice.init({\r\n  tableOfContents: '.toc'\r\n});\r\n```\r\n\r\nThis would automagically compile + inject the list for them at runtime :) that was my idea anyway. And if they don't even have a TOC, they just won't use the option."}}
{"actor":{"display_login":"toddmotto"}}