@abreen/tada 1.15.8 → 1.15.10
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.
- package/build/bundle.ts +55 -26
- package/build/colors.ts +2 -2
- package/build/config-files.ts +11 -21
- package/build/config-loader.ts +1 -1
- package/build/external-links-plugin.ts +1 -0
- package/build/generate-favicon.ts +0 -2
- package/build/generate-web-app-manifest.ts +0 -2
- package/build/pdf-text.ts +2 -2
- package/build/reachability.ts +1 -1
- package/build/site-variables.ts +1 -3
- package/build/template-globals.ts +7 -0
- package/build/templates.ts +1 -1
- package/build/util.ts +1 -22
- package/build/utils/literate-java.ts +1 -1
- package/build/utils/markdown-partials.ts +1 -1
- package/build/utils/shiki-highlighter.ts +1 -4
- package/build/utils/trace-layout.ts +2 -2
- package/build/validate-config-links.ts +51 -1
- package/build/watch/config-paths.ts +1 -1
- package/build/watch/planner.ts +1 -1
- package/build/watch/snapshot.ts +4 -16
- package/package.json +5 -5
- package/schema/authors.schema.json +1 -1
- package/src/navigate/eligible.ts +8 -1
- package/src/navigate/runtime.ts +57 -5
- package/src/page-update/index.ts +6 -2
- package/src/search/index.ts +105 -71
- package/src/search/pdf-utils.ts +1 -1
- package/src/slides/index.ts +1 -1
- package/src/timezone/index.ts +8 -44
- package/src/timezone/time-format.ts +43 -0
- package/src/toc/index.ts +7 -79
- package/src/toc/model.ts +78 -0
- package/src/top/index.ts +3 -2
- package/templates/_author.html +2 -2
- package/templates/_footer.html +1 -1
- package/templates/_heading.html +1 -1
- package/templates/_nav.html +2 -2
package/src/toc/model.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
type HeadingLevel = '1' | '2' | '3' | '4' | '5' | '6';
|
|
2
|
+
type AlertType = 'warning' | 'note';
|
|
3
|
+
|
|
4
|
+
export type Alert = { type: AlertType; title: string };
|
|
5
|
+
export type Heading = { level: HeadingLevel; innerHtml: string; id: string };
|
|
6
|
+
export type Dinkus = { type: 'dinkus' };
|
|
7
|
+
|
|
8
|
+
export function getHighlightIndexes(items: (Heading | Alert | Dinkus)[]) {
|
|
9
|
+
const indexes: (number | null)[] = [];
|
|
10
|
+
let currentHeadingIndex: number | null = null;
|
|
11
|
+
let tocIndex = 0;
|
|
12
|
+
|
|
13
|
+
items.forEach(item => {
|
|
14
|
+
if (!('level' in item) && item.type === 'dinkus') {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if ('level' in item) {
|
|
19
|
+
currentHeadingIndex = tocIndex;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
indexes.push(currentHeadingIndex ?? tocIndex);
|
|
23
|
+
tocIndex++;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return indexes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function headingToTableItem(el: HTMLHeadingElement): Heading {
|
|
30
|
+
const level = el.tagName[1] as HeadingLevel;
|
|
31
|
+
|
|
32
|
+
const subtitle = el.querySelector('.heading-subtitle');
|
|
33
|
+
const subtitleText = subtitle?.textContent || '';
|
|
34
|
+
let mainText = el.textContent || '';
|
|
35
|
+
|
|
36
|
+
if (mainText.length > 0 && subtitleText.length > 0) {
|
|
37
|
+
mainText = mainText.replace(subtitleText, '').trim();
|
|
38
|
+
return {
|
|
39
|
+
level,
|
|
40
|
+
id: el.id,
|
|
41
|
+
innerHtml: `${mainText}: <span class="heading-subtitle">${subtitleText}</span>`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return { level, id: el.id, innerHtml: el.innerHTML };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function alertToTableItem(el: HTMLElement): Alert | null {
|
|
48
|
+
const classes = el.className
|
|
49
|
+
.split(' ')
|
|
50
|
+
.map(cl => cl.trim())
|
|
51
|
+
.filter(cl => cl != 'alert');
|
|
52
|
+
|
|
53
|
+
const firstClass = classes[0];
|
|
54
|
+
if (firstClass === 'warning' || firstClass === 'note') {
|
|
55
|
+
let title = el.querySelector('.title')?.innerHTML;
|
|
56
|
+
if (!title) {
|
|
57
|
+
if (firstClass === 'warning') {
|
|
58
|
+
title = 'Warning';
|
|
59
|
+
} else {
|
|
60
|
+
title = 'Note';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { type: firstClass, title };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function switchCurrent(
|
|
71
|
+
oldCurrent: HTMLElement | null,
|
|
72
|
+
newCurrent: HTMLElement,
|
|
73
|
+
) {
|
|
74
|
+
if (oldCurrent) {
|
|
75
|
+
oldCurrent.classList.remove('current');
|
|
76
|
+
}
|
|
77
|
+
newCurrent.classList.add('current');
|
|
78
|
+
}
|
package/src/top/index.ts
CHANGED
|
@@ -30,11 +30,12 @@ export default (window: Window) => {
|
|
|
30
30
|
link.onclick = e => {
|
|
31
31
|
e.preventDefault();
|
|
32
32
|
const cleanUrl = window.location.pathname + window.location.search;
|
|
33
|
+
const historyState = window.history.state;
|
|
33
34
|
if (window.location.hash) {
|
|
34
35
|
globals.setLocationHash(window, '');
|
|
35
|
-
window.history.replaceState(
|
|
36
|
+
window.history.replaceState(historyState, '', cleanUrl);
|
|
36
37
|
} else {
|
|
37
|
-
window.history.replaceState(
|
|
38
|
+
window.history.replaceState(historyState, '', cleanUrl);
|
|
38
39
|
}
|
|
39
40
|
window.scrollTo({ top: 0 });
|
|
40
41
|
const toc = window.document.querySelector('nav.toc') as HTMLElement | null;
|
package/templates/_author.html
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<aside class="author">
|
|
2
2
|
Written by
|
|
3
3
|
<% if (page.author.url) { %>
|
|
4
|
-
<a href="
|
|
4
|
+
<a href="<%- encodeAuthoredUrl(page.author.url) %>">
|
|
5
5
|
<% } %>
|
|
6
6
|
<span class="text"><%= page.author.name %></span>
|
|
7
7
|
<% if (page.author.avatar) { %>
|
|
8
8
|
<img
|
|
9
9
|
width="32"
|
|
10
10
|
height="32"
|
|
11
|
-
src="
|
|
11
|
+
src="<%- encodeAuthoredUrl(page.author.avatar) %>"
|
|
12
12
|
alt="Picture of <%= page.author.name %>"
|
|
13
13
|
class="avatar"
|
|
14
14
|
/>
|
package/templates/_footer.html
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% if (site.features.footer) { %>
|
|
2
2
|
<footer data-pagefind-ignore>
|
|
3
|
-
<p>Built using <a href="https://github.com/abreen/Tada" target="_blank">Tada</a> <%= tadaVersion %></p>
|
|
3
|
+
<p>Built using <a href="https://github.com/abreen/Tada" target="_blank" rel="noopener noreferrer">Tada</a> <%= tadaVersion %></p>
|
|
4
4
|
</footer>
|
|
5
5
|
<% } %>
|
package/templates/_heading.html
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div class="title-and-info" data-pagefind-body>
|
|
2
2
|
<% if (page.parent) { %>
|
|
3
|
-
<a class="breadcrumb" href="
|
|
3
|
+
<a class="breadcrumb" href="<%- encodeAuthoredUrl(page.parent) %>" data-pagefind-ignore><%= page.parentLabel %></a>
|
|
4
4
|
<% } %>
|
|
5
5
|
<h1 data-pagefind-weight="10" data-pagefind-meta="title_html[data-title-html]" data-title-html="<%- page.titleHtml %>"><%= page.titleHtml %></h1>
|
|
6
6
|
|
package/templates/_nav.html
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<li>
|
|
8
8
|
<a
|
|
9
9
|
class="<%= cx({disabled: link.disabled, external: link.external}) %>"
|
|
10
|
-
<% if (!link.disabled) { %>href="
|
|
11
|
-
<% if (link.external) { %>target="_blank"<% } %>
|
|
10
|
+
<% if (!link.disabled) { %>href="<%- encodeAuthoredUrl(link.internal || link.external) %>"<% } %>
|
|
11
|
+
<% if (link.external) { %>target="_blank" rel="noopener noreferrer"<% } %>
|
|
12
12
|
>
|
|
13
13
|
<%= link.text %></a>
|
|
14
14
|
</li>
|