@onsvisual/svelte-components 0.1.68 → 0.1.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -69,6 +69,21 @@
|
|
|
69
69
|
const observer = writable();
|
|
70
70
|
setContext("observer", observer);
|
|
71
71
|
|
|
72
|
+
function formatSections(sections) {
|
|
73
|
+
const secs = [];
|
|
74
|
+
let sec = { subsections: [] };
|
|
75
|
+
for (const section of sections) {
|
|
76
|
+
if (section.dataset.subsection !== "true") {
|
|
77
|
+
if (sec.title || sec.subsections.length > 0) secs.push(sec);
|
|
78
|
+
sec = { id: section.id, title: section.dataset.title, subsections: [] };
|
|
79
|
+
} else {
|
|
80
|
+
sec.subsections.push({ id: section.id, title: section.dataset.title });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return [...secs, sec];
|
|
84
|
+
}
|
|
85
|
+
$: formattedSections = formatSections($sections);
|
|
86
|
+
|
|
72
87
|
onMount(() => {
|
|
73
88
|
if (!noContents) {
|
|
74
89
|
$observer = new IntersectionObserver(
|
|
@@ -113,20 +128,36 @@
|
|
|
113
128
|
</h2>
|
|
114
129
|
{/if}
|
|
115
130
|
<ol class="ons-list ons-u-mb-m ons-list--dashed">
|
|
116
|
-
{#
|
|
117
|
-
|
|
118
|
-
class="ons-list__item"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
{#if formattedSections}
|
|
132
|
+
{#each formattedSections as section}
|
|
133
|
+
<li class="ons-list__item">
|
|
134
|
+
{#if section.id && section.title}
|
|
135
|
+
<a
|
|
136
|
+
href="#{section.id}"
|
|
137
|
+
class="ons-list__link"
|
|
138
|
+
class:ons-toc__link-active="{section.id === active}"
|
|
139
|
+
>
|
|
140
|
+
{section.title}
|
|
141
|
+
</a>
|
|
142
|
+
{/if}
|
|
143
|
+
{#if section.subsections.length > 0}
|
|
144
|
+
<ol class="ons-list ons-u-mb-no ons-list--dashed">
|
|
145
|
+
{#each section.subsections as subsection}
|
|
146
|
+
<li class="ons-list__item">
|
|
147
|
+
<a
|
|
148
|
+
href="#{subsection.id}"
|
|
149
|
+
class="ons-list__link"
|
|
150
|
+
class:ons-toc__link-active="{subsection.id === active}"
|
|
151
|
+
>
|
|
152
|
+
{subsection.title}
|
|
153
|
+
</a>
|
|
154
|
+
</li>
|
|
155
|
+
{/each}
|
|
156
|
+
</ol>
|
|
157
|
+
{/if}
|
|
158
|
+
</li>
|
|
159
|
+
{/each}
|
|
160
|
+
{/if}
|
|
130
161
|
</ol>
|
|
131
162
|
{/if}
|
|
132
163
|
<slot name="after-nav" />
|