@abreen/tada 1.7.2 → 1.8.1
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/README.md +1 -0
- package/bin/tada.ts +2 -2
- package/build/site-variables.ts +1 -1
- package/build/types.d.ts +1 -0
- package/build/utils/render.ts +5 -1
- package/package.json +1 -1
- package/schema/site.schema.json +8 -2
- package/src/_layout.scss +32 -0
- package/src/print/style.scss +2 -1
- package/src/search/index.ts +19 -5
- package/src/search/pdf-utils.ts +2 -0
- package/src/search/style.scss +4 -4
- package/templates/_footer.html +5 -0
- package/templates/_heading.html +1 -1
- package/templates/_theme.scss +1 -0
- package/templates/code.html +2 -1
- package/templates/default.html +1 -0
- package/templates/literate.html +1 -0
package/README.md
CHANGED
|
@@ -232,6 +232,7 @@ Example site configuration JSON file:
|
|
|
232
232
|
| `features.search` | Enable search UI and Pagefind index generation |
|
|
233
233
|
| `features.code` | Enable generated source-code HTML pages for configured code extensions |
|
|
234
234
|
| `features.favicon` | Enable automatically generated favicons |
|
|
235
|
+
| `features.footer` | Show the Tada footer at the bottom of every page |
|
|
235
236
|
| `base` | Full base URL of the deployed site, used for metadata and URL generation |
|
|
236
237
|
| `basePath` | URL prefix for deployment under a subpath (e.g., `"/cs101"`), use `"/"` at root |
|
|
237
238
|
| `internalDomains` | Domain names treated as internal by link processing (not marked external) |
|
package/bin/tada.ts
CHANGED
|
@@ -332,7 +332,7 @@ async function initCommand(args: string[]): Promise<void> {
|
|
|
332
332
|
base: 'http://localhost:8080',
|
|
333
333
|
basePath: '/',
|
|
334
334
|
internalDomains: ['localhost'],
|
|
335
|
-
features: { search: true, code: true, favicon: false },
|
|
335
|
+
features: { search: true, code: true, favicon: false, footer: true },
|
|
336
336
|
});
|
|
337
337
|
|
|
338
338
|
const prodConfig = createSiteConfig({
|
|
@@ -345,7 +345,7 @@ async function initCommand(args: string[]): Promise<void> {
|
|
|
345
345
|
base: prodBase,
|
|
346
346
|
basePath: prodBasePath,
|
|
347
347
|
internalDomains: [prodDomain],
|
|
348
|
-
features: { search: true, code: true, favicon: true },
|
|
348
|
+
features: { search: true, code: true, favicon: true, footer: true },
|
|
349
349
|
});
|
|
350
350
|
|
|
351
351
|
fs.writeFileSync(
|
package/build/site-variables.ts
CHANGED
|
@@ -10,7 +10,7 @@ const configDir = getProjectDir();
|
|
|
10
10
|
|
|
11
11
|
const DEFAULT: Partial<SiteVariables> = {
|
|
12
12
|
basePath: '/',
|
|
13
|
-
features: { search: true, code: true, favicon: true },
|
|
13
|
+
features: { search: true, code: true, favicon: true, footer: true },
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const isValid = compileJsonSchema(siteSchema);
|
package/build/types.d.ts
CHANGED
package/build/utils/render.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
toPosix,
|
|
25
25
|
toUrlPath,
|
|
26
26
|
} from './paths';
|
|
27
|
+
import pkg from '../../package.json' with { type: 'json' };
|
|
27
28
|
import { parseFrontMatterAndContent } from './front-matter';
|
|
28
29
|
import { createMarkdown } from './markdown';
|
|
29
30
|
import { generateTocHtml, generateCodeTocHtml } from '../toc-plugin';
|
|
@@ -45,6 +46,8 @@ import type {
|
|
|
45
46
|
|
|
46
47
|
const log = makeLogger(import.meta.url);
|
|
47
48
|
|
|
49
|
+
const tadaVersion: string = pkg.version;
|
|
50
|
+
|
|
48
51
|
const REQUIRED_FRONT_MATTER_FIELDS = ['title'];
|
|
49
52
|
|
|
50
53
|
function isWatchMode(assetFiles: string[]): boolean {
|
|
@@ -133,6 +136,7 @@ function createTemplateParameters({
|
|
|
133
136
|
content,
|
|
134
137
|
applyBasePath,
|
|
135
138
|
isWatchMode,
|
|
139
|
+
tadaVersion,
|
|
136
140
|
};
|
|
137
141
|
}
|
|
138
142
|
|
|
@@ -291,7 +295,7 @@ export function renderCodePageAsset({
|
|
|
291
295
|
const codeFilePath = applyBasePath(
|
|
292
296
|
normalizeOutputPath(`/${toUrlPath(path.relative(contentDir, filePath))}`),
|
|
293
297
|
);
|
|
294
|
-
const titleHtml = `<
|
|
298
|
+
const titleHtml = `<code>${name + ext}</code>`;
|
|
295
299
|
const tocItems = lang === 'java' ? extractJavaMethodToc(sourceCode) : [];
|
|
296
300
|
const tocHtml = generateCodeTocHtml(tocItems);
|
|
297
301
|
const pageVariables: Record<string, unknown> = {
|
package/package.json
CHANGED
package/schema/site.schema.json
CHANGED
|
@@ -4,11 +4,17 @@
|
|
|
4
4
|
"properties": {
|
|
5
5
|
"features": {
|
|
6
6
|
"type": "object",
|
|
7
|
-
"default": {
|
|
7
|
+
"default": {
|
|
8
|
+
"search": true,
|
|
9
|
+
"code": true,
|
|
10
|
+
"favicon": true,
|
|
11
|
+
"footer": true
|
|
12
|
+
},
|
|
8
13
|
"properties": {
|
|
9
14
|
"search": { "type": "boolean", "default": true },
|
|
10
15
|
"code": { "type": "boolean", "default": true },
|
|
11
|
-
"favicon": { "type": "boolean", "default": true }
|
|
16
|
+
"favicon": { "type": "boolean", "default": true },
|
|
17
|
+
"footer": { "type": "boolean", "default": true }
|
|
12
18
|
},
|
|
13
19
|
"additionalProperties": false
|
|
14
20
|
},
|
package/src/_layout.scss
CHANGED
|
@@ -198,3 +198,35 @@ body.literate main table {
|
|
|
198
198
|
grid-template-columns: 1fr 1fr;
|
|
199
199
|
gap: var(--gap);
|
|
200
200
|
}
|
|
201
|
+
|
|
202
|
+
footer {
|
|
203
|
+
@include user-select(none);
|
|
204
|
+
text-align: center;
|
|
205
|
+
padding: 2rem 0 1rem;
|
|
206
|
+
color: var(--fg2-color);
|
|
207
|
+
|
|
208
|
+
a {
|
|
209
|
+
color: var(--fg2-color);
|
|
210
|
+
text-decoration: none;
|
|
211
|
+
|
|
212
|
+
@media (hover: hover) {
|
|
213
|
+
&:hover {
|
|
214
|
+
color: var(--link-color-hover);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&:active {
|
|
219
|
+
color: var(--link-active-color);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
&::after {
|
|
223
|
+
content: '';
|
|
224
|
+
display: inline-block;
|
|
225
|
+
width: 1.5em;
|
|
226
|
+
height: 1.5em;
|
|
227
|
+
vertical-align: middle;
|
|
228
|
+
margin-left: 0.2em;
|
|
229
|
+
@include contained-mask(var(--icon-tada));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
package/src/print/style.scss
CHANGED
package/src/search/index.ts
CHANGED
|
@@ -11,7 +11,12 @@ interface PagefindSubResult {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
interface PagefindResult {
|
|
14
|
-
meta?: {
|
|
14
|
+
meta?: {
|
|
15
|
+
title?: string;
|
|
16
|
+
title_html?: string;
|
|
17
|
+
page?: string;
|
|
18
|
+
template?: string;
|
|
19
|
+
};
|
|
15
20
|
url: string;
|
|
16
21
|
excerpt?: string;
|
|
17
22
|
score: number;
|
|
@@ -74,6 +79,7 @@ async function doSearch(state: State) {
|
|
|
74
79
|
}));
|
|
75
80
|
return {
|
|
76
81
|
title,
|
|
82
|
+
titleHtml: d.meta?.title_html ?? null,
|
|
77
83
|
url: d.url,
|
|
78
84
|
excerpt: d.excerpt ?? '',
|
|
79
85
|
score: d.score ?? 0,
|
|
@@ -141,9 +147,10 @@ function render(
|
|
|
141
147
|
titleEl.id = `title-${i}`;
|
|
142
148
|
titleEl.className = 'title';
|
|
143
149
|
if (result.template === 'code') {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
titleEl.classList.add('code-page');
|
|
151
|
+
}
|
|
152
|
+
if (result.titleHtml) {
|
|
153
|
+
titleEl.innerHTML = result.titleHtml;
|
|
147
154
|
} else {
|
|
148
155
|
titleEl.textContent = result.title;
|
|
149
156
|
}
|
|
@@ -174,7 +181,14 @@ function render(
|
|
|
174
181
|
|
|
175
182
|
const subTitle = doc.createElement('div');
|
|
176
183
|
subTitle.className = 'title';
|
|
177
|
-
|
|
184
|
+
if (result.template === 'code') {
|
|
185
|
+
subTitle.classList.add('code-page');
|
|
186
|
+
const code = doc.createElement('code');
|
|
187
|
+
code.textContent = sub.title;
|
|
188
|
+
subTitle.appendChild(code);
|
|
189
|
+
} else {
|
|
190
|
+
subTitle.textContent = sub.title;
|
|
191
|
+
}
|
|
178
192
|
subA.appendChild(subTitle);
|
|
179
193
|
|
|
180
194
|
if (sub.excerpt) {
|
package/src/search/pdf-utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type SubResult = { title: string; url: string; excerpt: string };
|
|
2
2
|
export type Result = {
|
|
3
3
|
title: string;
|
|
4
|
+
titleHtml: string | null;
|
|
4
5
|
url: string;
|
|
5
6
|
excerpt: string;
|
|
6
7
|
score: number;
|
|
@@ -67,6 +68,7 @@ export function groupPdfResults(results: Result[]): Result[] {
|
|
|
67
68
|
|
|
68
69
|
grouped.push({
|
|
69
70
|
title: primary.title,
|
|
71
|
+
titleHtml: null,
|
|
70
72
|
url: baseUrl,
|
|
71
73
|
excerpt: primary.excerpt,
|
|
72
74
|
score: primary.score,
|
package/src/search/style.scss
CHANGED
package/templates/_heading.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<% if (page.parent) { %>
|
|
3
3
|
<a class="breadcrumb" href="<%= applyBasePath(page.parent) %>" data-pagefind-ignore><%= page.parentLabel %></a>
|
|
4
4
|
<% } %>
|
|
5
|
-
<h1 data-pagefind-weight="10"><%= page.titleHtml %></h1>
|
|
5
|
+
<h1 data-pagefind-weight="10" data-pagefind-meta="title_html[data-title-html]" data-title-html="<%- page.titleHtml %>"><%= page.titleHtml %></h1>
|
|
6
6
|
|
|
7
7
|
<div class="info" data-pagefind-ignore>
|
|
8
8
|
<% if (page.published) { %>
|
package/templates/_theme.scss
CHANGED
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
--icon-search: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><circle cx='11' cy='11' r='7' stroke='<%= iconColor %>' stroke-width='2' fill='none'/><line x1='16.5' y1='16.5' x2='22' y2='22' stroke='<%= iconColor %>' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
68
68
|
--icon-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><polyline points='9 18 15 12 9 6' stroke='<%= iconColor %>' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
|
|
69
69
|
--icon-breadcrumb: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path d='M3 7 H17 V22' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/><polyline points='11 16 17 22 23 16' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
|
|
70
|
+
--icon-tada: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 -960 960 960'><path d='m121-172 151-426q4-11 13.48-17.5 9.47-6.5 20.3-6.5 7.22 0 13.52 2.5T331-612l277 276q5 5.4 7.5 11.7 2.5 6.3 2.5 13.5 0 10.8-6.5 20.3T594-277L167-126q-11 4-20.53.97-9.54-3.04-16.47-9.97-6.93-6.93-9.97-16.47Q117-161 121-172Zm791-506q-8 8-17 8t-17-8l-17-17q-13.8-14-34.5-14T792-695L589-491q-7.36 7-17.18 7T555-491q-7-7-7-16.82t7-17.18l203-204q28.07-28 67.53-28Q865-757 894-729l18 18q7 7.09 7 16.55 0 9.45-7 16.45ZM418-797q7.36-7 17.18-7t16.82 7l17 17q27 28.53 27 67.77Q496-673 469-644l-17 17q-7.36 7-17.18 7T418-627q-7-7-7-16.82t7-17.18l17-17q14-13.79 14-33.5T435-745l-18-18q-7-7.09-7-16.55 0-9.45 8-17.45Zm119-50q7-7 16.82-7t17.18 7l51 51q29 29 29 68.47 0 39.46-29 67.53L521-559q-7.09 7-16.55 7-9.45 0-17.45-7t-8-17.18q0-10.18 8-17.82l101-101q14-13.6 14-34t-14-34l-51-50q-7-7.36-7-17.18t7-16.82Zm340 407q-7 7-16.82 7T843-440l-51-51q-13.6-14-34-14t-34 14l-68 68q-7.36 7-17.18 7T622-423q-7-7-7-16.82t7-17.18l68-68q29-27 68.5-27.5T826-525l51 51q7 7.36 7 17.18T877-440Z'/></svg>");
|
|
70
71
|
|
|
71
72
|
color-scheme: light dark;
|
|
72
73
|
}
|
package/templates/code.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div class="main-content">
|
|
4
4
|
<main class="body" data-pagefind-body>
|
|
5
5
|
<div class="file-header">
|
|
6
|
-
<h1 data-pagefind-weight="10"><%= page.titleHtml %></h1>
|
|
6
|
+
<h1 data-pagefind-weight="10" data-pagefind-meta="title_html[data-title-html]" data-title-html="<%- page.titleHtml %>"><%= page.titleHtml %></h1>
|
|
7
7
|
<%= render('_download.html') %>
|
|
8
8
|
</div>
|
|
9
9
|
<div class="code-body">
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
<% }); %>
|
|
23
23
|
</div>
|
|
24
24
|
<% } %>
|
|
25
|
+
<%= render('_footer.html') %>
|
|
25
26
|
</main>
|
|
26
27
|
<% if (page.tocHtml) { %>
|
|
27
28
|
<nav class="toc"><%= page.tocHtml %></nav>
|
package/templates/default.html
CHANGED
package/templates/literate.html
CHANGED