forked from godofredoninja/simply
/
custom-post-toc.hbs
168 lines (134 loc) · 6.79 KB
/
custom-post-toc.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
{{!-- Layout --}}
{{!< default}} {{#post}} {{!-- Class for <body> --}}
{{#contentFor "special_body_class"}}is-article{{/contentFor}}
<article class="post py-vmin8 relative">
<header class="post-header godo-canvas">
{{!-- [Title, Excerpt, Author, DateTime, Share]- partials/article/article-header.hbs --}}
{{> "article/article-header"}}
</header>
{{!-- Article Body - partials/article/article-body.hbs --}}
<section id="post-body" class="post-body godo-canvas mx-auto relative {{#match @custom.post_font "=" "
font-serif"}}font-serif{{else}}font-sans{{/match}}">
{{!-- Post Image - partials/article/article-featured-image.hbs --}}
{{#if feature_image}}{{> "article/article-featured-image" image=feature_image}}{{/if}}
{{content}}
{{!-- Table of Content - on the left --}}
<div class="godo-content-side top-0 bottom-0 absolute pr-8 row-start-1 hidden font-sans lg:block">
<div class="sticky top-20 overflow-auto scroll-transparent lg:max-h-(screen-16)">
<div class="uppercase font-medium text-sm mb-3">{{t "On this page"}}</div>
{{!-- <div class="js-tocbot text-base space-y-4 leading-tight"></div> --}}
<div class="toc list-none"></div>
</div>
</div>
{{!-- Share and Tags buttons - on the right --}}
<div class="content-right-side top-0 bottom-0 absolute pl-8 row-start-1 hidden font-sans lg:block">
<div class="sticky top-20 overflow-auto scroll-transparent lg:max-h-(screen-16)">
<div class="uppercase font-medium text-sm mb-3">
<div class="uppercase font-medium text-sm mb-3">Tags</div>
<div class="space-y-4">
{{> "components/tags"}}
</div>
</div>
<div class="flex flex-col items-start">
<div class="uppercase font-medium text-sm mb-3">{{t "Share"}}</div>
{{!-- maybe replace with multiple social share icons --}}
{{> "components/social-share-vertical" Tracking_name="Footer"}}
</div>
</div>
</div>
</section>
<footer class="post-footer godo-canvas pt-10">
{{!-- Tags - ./partials/components/tags,hbs --}}
{{> "components/tags"}}
{{!-- Social Share - ./partials/components/social-share --}}
{{> "components/social-share" Tracking_name="Footer"}}
{{!-- Newsletter - ./partials/components/newsletter.hbs --}}
{{> "components/newsletter"}}
{{!-- Previous and next article --}}
<div class="prev-next pb-8">
<hr class="my-10">
{{#prev_post}}
{{> "story/story-previous-next" storyTitle=(t "Previous article") class="mb-8"}}
{{/prev_post}}
{{#next_post}}
{{> "story/story-previous-next" storyTitle=(t "Next article") class=""}}
{{/next_post}}
</div>
</footer>
</article>
{{/post}}
{{!-- Donate button --}}
{{!-- 6 Related Articles - partials/article/article-related.hbs --}}
{{> "article/article-related"}}
{{!-- Post Commets - partials/article/article-comments.hbd --}}
{{#post}}{{> "article/article-comments"}}{{/post}}
{{#contentFor "scripts"}}
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.18.2/tocbot.min.js"></script>
<script defer src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
<script>
function renderTOC() {
tocbot.init({
// Where to render the table of contents.
tocSelector: '.toc',
// Where to grab the headings to build the table of contents.
contentSelector: '.post-body',
// Which headings to grab inside of the contentSelector element.
headingSelector: 'h1, h2, h3',
// For headings inside relative or absolute positioned containers within content.
// hasInnerContainers: true,
orderedList: false,
});
}
function addDonateFloatingButton() {
kofiWidgetOverlay.draw('engineeringwithbivek', {
'type': 'floating-chat',
'floating-chat.donateButton.text': 'Support Us',
'floating-chat.donateButton.background-color': '#d9534f',
'floating-chat.donateButton.text-color': '#fff'
});
}
var observer = new IntersectionObserver(function (entries) {
if (entries[0].isIntersecting === true) {
console.log('Item has just APPEARED!');
addDonateFloatingButton();
observer.unobserve(document.querySelector(".post-footer"));
}
}, { threshold: [0] });
observer.observe(document.querySelector(".post-footer"));
document.addEventListener('DOMContentLoaded', () => {
renderTOC();
// Get all tab buttons and content containers
var tabButtons = document.querySelectorAll("button[role='tab']");
var tabContents = document.querySelectorAll("div[role='tabpanel']");
console.log("tabButtons::", tabButtons);
console.log("tabContents::", tabContents);
// Add click event listeners to all tab buttons
tabButtons.forEach((button) => {
console.log("button::", button);
button.addEventListener("click", handleTabClick);
});
// Show the first tab content by default (if needed)
tabContents[0].classList.add("active");
tabButtons[0].classList.add("active");
);
// Function to handle tab clicks
function handleTabClick(event) {
const clickedButton = event.currentTarget;
const targetContentId = clickedButton.getAttribute("aria-controls");
console.log(targetContentId);
// Hide all content first
tabContents.forEach((content) => {
content.classList.remove("active");
});
// Show the clicked tab's content
const targetContent = document.getElementById(`content-${targetContentId}`);
targetContent.classList.add("active");
// Remove active class from all buttons
tabButtons.forEach((button) => {
button.classList.remove("active");
});
// Add active class to the clicked button
clickedButton.classList.add("active");
};
</script>
{{/contentFor}}