Skip to content

Commit

Permalink
feat: make toc works
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 13, 2020
1 parent 550e889 commit d4a12ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--<div class="toc" #toc></div>-->
<div class="toc" #toc></div>
<markdown
class="markdown"
[src]="src"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ export class MarkdownRenderComponent implements OnInit, OnChanges {

private renderHeading(options: any) {
return (text: string, level: number, raw: string, slugger: Slugger) => {
this.tocify.add(text, level, '', slugger.slug(raw));
const anchor = slugger.slug(raw);
this.tocify.add(text, level, '', anchor);
if (options.headerIds) {
return '<h' + level + ' id="' + options.headerPrefix + slugger.slug(raw) + '">' + text + '</h' + level + '>\n';
return '<h' + level + ' id="' + options.headerPrefix + anchor + '">' + text + '</h' + level + '>\n';
}
return '<h' + level + '>' + text + '</h' + level + '>\n';
};
Expand Down

0 comments on commit d4a12ef

Please sign in to comment.