tecitheme 0.2.1 → 0.2.2
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/assets/TECi_logo.svelte +146 -119
- package/components/Banner.svelte +74 -42
- package/components/Button.svelte +6 -2
- package/components/CTA.svelte +31 -21
- package/components/Card.svelte +34 -17
- package/components/CountrySelector.svelte +133 -133
- package/components/Figure.svelte +24 -20
- package/components/Footer.svelte +292 -177
- package/components/Header.svelte +139 -107
- package/components/HeadingCentered.svelte +23 -21
- package/components/Icon.svelte +132 -124
- package/components/Math.svelte +15 -10
- package/components/MediaFeature.svelte +56 -32
- package/components/MetaSocial.svelte +12 -12
- package/components/Modal.svelte +33 -14
- package/components/NewsGrid.svelte +31 -25
- package/components/SidebarContent.svelte +84 -24
- package/components/Subscribe.svelte +4 -3
- package/components/ThreeColumn.svelte +1 -1
- package/components/TrialForm.svelte +249 -202
- package/components/TrialForm.svelte.d.ts +3 -3
- package/components/Video.svelte +14 -16
- package/components/Wrap.svelte +7 -7
- package/get-content.js +55 -40
- package/layouts/blocks.svelte +49 -36
- package/package.json +17 -17
- package/req_utils.js +52 -51
- package/site_config.json +2 -2
- package/utils.js +39 -22
- package/variables.js +1 -1
package/get-content.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
// get-content.js
|
|
2
2
|
// HTML parser from https://github.com/html-to-text/node-html-to-text
|
|
3
|
-
import { convert } from "html-to-text"
|
|
3
|
+
import { convert } from "html-to-text";
|
|
4
4
|
import { dev } from "$app/environment";
|
|
5
5
|
|
|
6
|
-
export async function getContent
|
|
7
|
-
let indexData = []
|
|
8
|
-
let iterableContentFiles = Object.entries([])
|
|
9
|
-
let sortedIndex = []
|
|
6
|
+
export async function getContent(content) {
|
|
7
|
+
let indexData = [];
|
|
8
|
+
let iterableContentFiles = Object.entries([]);
|
|
9
|
+
let sortedIndex = [];
|
|
10
10
|
|
|
11
11
|
// Use 'content' variable to determine files to import.
|
|
12
12
|
switch (content) {
|
|
13
13
|
case "news":
|
|
14
|
-
iterableContentFiles = Object.entries(
|
|
14
|
+
iterableContentFiles = Object.entries(
|
|
15
|
+
import.meta.glob("/src/routes/news/*(!(+page)).md")
|
|
16
|
+
);
|
|
15
17
|
break;
|
|
16
18
|
default:
|
|
17
|
-
iterableContentFiles = Object.entries(
|
|
19
|
+
iterableContentFiles = Object.entries(
|
|
20
|
+
import.meta.glob("/src/routes/**/*(!(+page)).md")
|
|
21
|
+
);
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
const allContent = await Promise.all(
|
|
@@ -23,58 +27,69 @@ export async function getContent (content) {
|
|
|
23
27
|
const file = await resolver();
|
|
24
28
|
const metadata = file.metadata;
|
|
25
29
|
const today = new Date();
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
metadata.notIndexed ||
|
|
33
|
+
(dev ? false : metadata.draft) ||
|
|
34
|
+
(dev ? false : new Date(metadata.date) > today)
|
|
35
|
+
) {
|
|
36
|
+
return;
|
|
29
37
|
} else {
|
|
30
|
-
var html = file.default.render().html
|
|
38
|
+
var html = file.default.render().html;
|
|
31
39
|
var plaintext = convert(html, {
|
|
32
40
|
baseElements: {
|
|
33
|
-
orderBy:
|
|
41
|
+
orderBy: "occurrence",
|
|
34
42
|
},
|
|
35
43
|
wordwrap: false,
|
|
36
44
|
selectors: [
|
|
37
|
-
{selector:
|
|
38
|
-
{selector:
|
|
39
|
-
{selector:
|
|
40
|
-
{selector:
|
|
41
|
-
{selector:
|
|
42
|
-
{selector:
|
|
43
|
-
{selector:
|
|
44
|
-
{selector:
|
|
45
|
-
]
|
|
46
|
-
})
|
|
45
|
+
{ selector: "h1", format: "skip" },
|
|
46
|
+
{ selector: "h2", options: { uppercase: false } },
|
|
47
|
+
{ selector: "a", options: { ignoreHref: true } },
|
|
48
|
+
{ selector: "a.button", format: "skip" },
|
|
49
|
+
{ selector: "a.btn", format: "skip" },
|
|
50
|
+
{ selector: "aside", format: "skip" },
|
|
51
|
+
{ selector: "ul", options: { itemPrefix: "- " } },
|
|
52
|
+
{ selector: "img", format: "skip" },
|
|
53
|
+
],
|
|
54
|
+
})
|
|
55
|
+
.replace(/\n\n\n/gm, " ")
|
|
56
|
+
.replace(/\n\n/g, " ")
|
|
57
|
+
.replace(/\n/g, " ")
|
|
58
|
+
.replace(/\"/g, "'")
|
|
59
|
+
.trim();
|
|
47
60
|
|
|
48
61
|
if (metadata && contentPath && plaintext) {
|
|
49
|
-
return {
|
|
62
|
+
return {
|
|
50
63
|
meta: metadata,
|
|
51
64
|
path: contentPath,
|
|
52
|
-
text: plaintext
|
|
53
|
-
}
|
|
65
|
+
text: plaintext,
|
|
66
|
+
};
|
|
54
67
|
}
|
|
55
68
|
}
|
|
56
69
|
})
|
|
57
|
-
)
|
|
58
|
-
|
|
70
|
+
);
|
|
71
|
+
|
|
59
72
|
for (let i = 0; i < allContent.length; i++) {
|
|
60
73
|
if (allContent[i]) {
|
|
61
74
|
let today = new Date();
|
|
62
|
-
let postdate = allContent[i].meta.date
|
|
75
|
+
let postdate = allContent[i].meta.date
|
|
76
|
+
? new Date(allContent[i].meta.date)
|
|
77
|
+
: today;
|
|
63
78
|
let entry = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
indexData.push(entry)
|
|
79
|
+
title: allContent[i].meta.title,
|
|
80
|
+
content: allContent[i].text,
|
|
81
|
+
summary: allContent[i].meta.summary,
|
|
82
|
+
date: postdate,
|
|
83
|
+
slug: allContent[i].path,
|
|
84
|
+
categories: allContent[i].meta.categories,
|
|
85
|
+
};
|
|
86
|
+
indexData.push(entry);
|
|
72
87
|
} else {
|
|
73
88
|
continue;
|
|
74
89
|
}
|
|
75
90
|
}
|
|
76
|
-
|
|
77
|
-
sortedIndex = indexData.slice().sort((a, b) => (b.date - a.date))
|
|
78
91
|
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
sortedIndex = indexData.slice().sort((a, b) => b.date - a.date);
|
|
93
|
+
|
|
94
|
+
return sortedIndex;
|
|
95
|
+
}
|
package/layouts/blocks.svelte
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { browser, dev } from
|
|
3
|
-
import { getContext } from
|
|
2
|
+
import { browser, dev } from "$app/environment";
|
|
3
|
+
import { getContext } from "svelte";
|
|
4
|
+
|
|
5
|
+
import CTA from "../components/CTA.svelte";
|
|
6
|
+
import HeadingCentered from "../components/HeadingCentered.svelte";
|
|
7
|
+
import MediaFeature from "../components/MediaFeature.svelte";
|
|
8
|
+
import Modal from "../components/Modal.svelte";
|
|
9
|
+
import NewsGrid from "../components/NewsGrid.svelte";
|
|
10
|
+
import SidebarContent from "../components/SidebarContent.svelte";
|
|
11
|
+
import ThreeColumn from "../components/ThreeColumn.svelte";
|
|
12
|
+
import TrialForm from "../components/TrialForm.svelte";
|
|
13
|
+
import Video from "../components/Video.svelte";
|
|
14
|
+
import MetaSocial from "../components/MetaSocial.svelte";
|
|
4
15
|
|
|
5
|
-
import CTA from '../components/CTA.svelte';
|
|
6
|
-
import HeadingCentered from '../components/HeadingCentered.svelte';
|
|
7
|
-
import MediaFeature from '../components/MediaFeature.svelte';
|
|
8
|
-
import Modal from '../components/Modal.svelte';
|
|
9
|
-
import NewsGrid from '../components/NewsGrid.svelte';
|
|
10
|
-
import SidebarContent from '../components/SidebarContent.svelte';
|
|
11
|
-
import ThreeColumn from '../components/ThreeColumn.svelte';
|
|
12
|
-
import TrialForm from '../components/TrialForm.svelte';
|
|
13
|
-
import Video from '../components/Video.svelte';
|
|
14
|
-
import MetaSocial from '../components/MetaSocial.svelte';
|
|
15
|
-
|
|
16
16
|
let blocks = [
|
|
17
|
-
{ref: "cta-center", component: CTA},
|
|
18
|
-
{ref: "heading-centered", component: HeadingCentered},
|
|
19
|
-
{ref: "media-feature", component: MediaFeature},
|
|
20
|
-
{ref: "modal", component: Modal},
|
|
21
|
-
{ref: "news-grid", component: NewsGrid},
|
|
22
|
-
{ref: "sidebar-content", component: SidebarContent},
|
|
23
|
-
{ref: "three-column", component: ThreeColumn},
|
|
24
|
-
{ref: "trial-form", component: TrialForm},
|
|
25
|
-
{ref: "video", component: Video},
|
|
26
|
-
]
|
|
17
|
+
{ ref: "cta-center", component: CTA },
|
|
18
|
+
{ ref: "heading-centered", component: HeadingCentered },
|
|
19
|
+
{ ref: "media-feature", component: MediaFeature },
|
|
20
|
+
{ ref: "modal", component: Modal },
|
|
21
|
+
{ ref: "news-grid", component: NewsGrid },
|
|
22
|
+
{ ref: "sidebar-content", component: SidebarContent },
|
|
23
|
+
{ ref: "three-column", component: ThreeColumn },
|
|
24
|
+
{ ref: "trial-form", component: TrialForm },
|
|
25
|
+
{ ref: "video", component: Video },
|
|
26
|
+
];
|
|
27
27
|
|
|
28
28
|
export let title;
|
|
29
29
|
export let date;
|
|
@@ -36,35 +36,48 @@
|
|
|
36
36
|
let featuredImage;
|
|
37
37
|
let url;
|
|
38
38
|
let host;
|
|
39
|
-
|
|
40
|
-
url = getContext(
|
|
41
|
-
host = getContext(
|
|
39
|
+
|
|
40
|
+
url = getContext("currentURL");
|
|
41
|
+
host = getContext("currentHost");
|
|
42
42
|
|
|
43
43
|
if (images.length > 0) {
|
|
44
44
|
if (dev) {
|
|
45
|
-
featuredImage = images[0]
|
|
45
|
+
featuredImage = images[0];
|
|
46
46
|
} else {
|
|
47
|
-
featuredImage =
|
|
47
|
+
featuredImage =
|
|
48
|
+
"https://thunderheadeng-www.imgix.net" +
|
|
49
|
+
images[0] +
|
|
50
|
+
"?w=1200&h=627&fit=crop&auto=compress&auto=format";
|
|
48
51
|
}
|
|
49
52
|
} else {
|
|
50
|
-
featuredImage =
|
|
53
|
+
featuredImage =
|
|
54
|
+
"https://files.thunderheadeng.com/www/images/teci_icon_250.png";
|
|
51
55
|
}
|
|
52
56
|
</script>
|
|
53
57
|
|
|
54
58
|
<svelte:head>
|
|
55
59
|
<title>{title} | Thunderhead Engineering</title>
|
|
56
|
-
<meta name="description" content={summary}
|
|
60
|
+
<meta name="description" content={summary} />
|
|
57
61
|
{#if browser}
|
|
58
|
-
|
|
62
|
+
<MetaSocial {title} description={summary} image={featuredImage} {url} />
|
|
59
63
|
{/if}
|
|
60
64
|
</svelte:head>
|
|
61
65
|
|
|
62
66
|
<article class="flex flex-col space-y-12 {layout}">
|
|
63
67
|
{#each page_sections as section}
|
|
64
|
-
{#if
|
|
65
|
-
<svelte:component
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
{#if section && section.fieldGroup === "sidebar-content"}
|
|
69
|
+
<svelte:component
|
|
70
|
+
this={blocks.find((obj) => obj.ref === section.fieldGroup).component}
|
|
71
|
+
data={section}
|
|
72
|
+
{title}
|
|
73
|
+
{date}
|
|
74
|
+
{lastmod}><slot /></svelte:component
|
|
75
|
+
>
|
|
76
|
+
{:else if section && section.fieldGroup != "sidebar-content"}
|
|
77
|
+
<svelte:component
|
|
78
|
+
this={blocks.find((obj) => obj.ref === section.fieldGroup).component}
|
|
79
|
+
data={section}
|
|
80
|
+
/>
|
|
68
81
|
{/if}
|
|
69
82
|
{/each}
|
|
70
|
-
</article>
|
|
83
|
+
</article>
|
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tecitheme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"svelte": true,
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@jsdevtools/rehype-toc": "^3.0.2",
|
|
7
|
-
"@sveltejs/adapter-netlify": "1.0.0-next.
|
|
8
|
-
"@sveltejs/kit": "1.0.0-next.
|
|
9
|
-
"@sveltejs/package": "^1.0.0-next.
|
|
7
|
+
"@sveltejs/adapter-netlify": "1.0.0-next.84",
|
|
8
|
+
"@sveltejs/kit": "1.0.0-next.551",
|
|
9
|
+
"@sveltejs/package": "^1.0.0-next.6",
|
|
10
10
|
"@tailwindcss/forms": "^0.5.3",
|
|
11
|
-
"@tailwindcss/typography": "^0.5.
|
|
11
|
+
"@tailwindcss/typography": "^0.5.8",
|
|
12
12
|
"@types/cookie": "^0.5.1",
|
|
13
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
14
|
-
"@typescript-eslint/parser": "^5.
|
|
15
|
-
"autoprefixer": "^10.4.
|
|
13
|
+
"@typescript-eslint/eslint-plugin": "^5.43.0",
|
|
14
|
+
"@typescript-eslint/parser": "^5.43.0",
|
|
15
|
+
"autoprefixer": "^10.4.13",
|
|
16
16
|
"dotenv": "^16.0.3",
|
|
17
17
|
"encoding": "^0.1.13",
|
|
18
|
-
"eslint": "^8.
|
|
18
|
+
"eslint": "^8.27.0",
|
|
19
19
|
"eslint-config-prettier": "^8.5.0",
|
|
20
20
|
"eslint-plugin-svelte3": "^4.0.0",
|
|
21
21
|
"html-to-text": "^8.2.1",
|
|
22
22
|
"markdown-yaml-metadata-parser": "^3.0.0",
|
|
23
23
|
"mdsvex": "^0.10.6",
|
|
24
|
-
"postcss": "^8.4.
|
|
24
|
+
"postcss": "^8.4.19",
|
|
25
25
|
"prettier": "^2.7.1",
|
|
26
26
|
"prettier-plugin-tailwindcss": "^0.1.13",
|
|
27
27
|
"rehype-parse": "^8.0.4",
|
|
28
|
-
"rehype-slug": "^5.0
|
|
28
|
+
"rehype-slug": "^5.1.0",
|
|
29
29
|
"rehype-stringify": "^9.0.3",
|
|
30
30
|
"stream": "^0.0.2",
|
|
31
|
-
"svelte": "^3.
|
|
31
|
+
"svelte": "^3.53.1",
|
|
32
32
|
"svelte-check": "^2.9.2",
|
|
33
33
|
"svelte-paginate": "^0.1.0",
|
|
34
34
|
"svelte-preprocess": "^4.10.7",
|
|
35
35
|
"svelte2tsx": "^0.5.20",
|
|
36
|
-
"tailwindcss": "^3.2.
|
|
37
|
-
"tslib": "^2.4.
|
|
38
|
-
"typescript": "^4.
|
|
36
|
+
"tailwindcss": "^3.2.4",
|
|
37
|
+
"tslib": "^2.4.1",
|
|
38
|
+
"typescript": "^4.9.3",
|
|
39
39
|
"uuid-by-string": "^4.0.0",
|
|
40
|
-
"vite": "^3.2.
|
|
40
|
+
"vite": "^3.2.4",
|
|
41
41
|
"vite-plugin-autoimport": "^1.6.6"
|
|
42
42
|
},
|
|
43
43
|
"type": "module",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@lukeed/uuid": "^2.0.0",
|
|
46
46
|
"cookie": "^0.5.0",
|
|
47
47
|
"katex": "^0.16.3",
|
|
48
|
-
"svelte": "^3.
|
|
48
|
+
"svelte": "^3.53.1"
|
|
49
49
|
},
|
|
50
50
|
"exports": {
|
|
51
51
|
"./package.json": "./package.json",
|
package/req_utils.js
CHANGED
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
import {browser} from
|
|
1
|
+
import { browser } from "$app/environment";
|
|
2
2
|
|
|
3
3
|
export function browserGet(key) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
4
|
+
if (browser) {
|
|
5
|
+
const item = localStorage.getItem(key);
|
|
6
|
+
if (item) {
|
|
7
|
+
return JSON.parse(item);
|
|
9
8
|
}
|
|
10
|
-
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function browserSet(key, value) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
if (browser) {
|
|
15
|
+
localStorage.setItem(key, value);
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export async function post(fetch, url, body) {
|
|
21
|
-
|
|
21
|
+
let customError = false;
|
|
22
|
+
try {
|
|
23
|
+
let headers = {};
|
|
24
|
+
if (!(body instanceof FormData)) {
|
|
25
|
+
headers["Content-Type"] = "application/json";
|
|
26
|
+
body = JSON.stringify(body);
|
|
27
|
+
}
|
|
28
|
+
const token = browserGet("token");
|
|
29
|
+
if (token) {
|
|
30
|
+
headers["X-UltraCart-Api-Version"] = "2017-03-01";
|
|
31
|
+
headers[Accept] = "application/json";
|
|
32
|
+
headers["x-ultracart-simple-key"] = token;
|
|
33
|
+
}
|
|
34
|
+
const res = await fetch(url, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
body,
|
|
37
|
+
headers,
|
|
38
|
+
});
|
|
39
|
+
if (!res.ok) {
|
|
40
|
+
try {
|
|
41
|
+
const data = await res.json();
|
|
42
|
+
const error = data.message[0].messages[0];
|
|
43
|
+
customError = true;
|
|
44
|
+
throw { id: error.id, message: error.message };
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.log(err);
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
22
50
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const token = browserGet('token')
|
|
29
|
-
if(token) {
|
|
30
|
-
headers['X-UltraCart-Api-Version'] = '2017-03-01'
|
|
31
|
-
headers[Accept] = 'application/json'
|
|
32
|
-
headers['x-ultracart-simple-key'] = token
|
|
33
|
-
}
|
|
34
|
-
const res = await fetch(url, {
|
|
35
|
-
method: 'POST',
|
|
36
|
-
body,
|
|
37
|
-
headers
|
|
38
|
-
})
|
|
39
|
-
if(!res.ok) {
|
|
40
|
-
try{
|
|
41
|
-
const data = await res.json()
|
|
42
|
-
const error = data.message[0].messages[0]
|
|
43
|
-
customError = true
|
|
44
|
-
throw {id: error.id, message: error.message}
|
|
45
|
-
} catch(err) {
|
|
46
|
-
console.log(err)
|
|
47
|
-
throw err
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
const json = await res.json()
|
|
52
|
-
return json
|
|
53
|
-
} catch(err) {
|
|
54
|
-
console.log(err)
|
|
55
|
-
throw{id:'',message:'An unknown error has occured.'}
|
|
56
|
-
}
|
|
57
|
-
} catch(err) {
|
|
58
|
-
console.log(err)
|
|
59
|
-
throw customError ? err : { id: '', message: 'An unknown error has occured'}
|
|
51
|
+
const json = await res.json();
|
|
52
|
+
return json;
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.log(err);
|
|
55
|
+
throw { id: "", message: "An unknown error has occured." };
|
|
60
56
|
}
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.log(err);
|
|
59
|
+
throw customError
|
|
60
|
+
? err
|
|
61
|
+
: { id: "", message: "An unknown error has occured" };
|
|
62
|
+
}
|
|
63
|
+
}
|
package/site_config.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"showBanner": true,
|
|
3
|
-
"bannerData":{
|
|
3
|
+
"bannerData": {
|
|
4
4
|
"showCTA": true,
|
|
5
5
|
"shortText": "Short text in a few words to show how it works.",
|
|
6
6
|
"longText": "Long test text that goes on and on for a while with some information about something that people should know about.",
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
"ctaLink": "https://www.thunderheadeng.com",
|
|
9
9
|
"allowClose": false
|
|
10
10
|
}
|
|
11
|
-
}
|
|
11
|
+
}
|
package/utils.js
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
1
|
export function scrollTo(anchor) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
document.querySelector("#" + anchor).scrollIntoView({
|
|
3
|
+
behavior: "smooth",
|
|
4
|
+
});
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function validateEmail(email) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const re =
|
|
9
|
+
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
10
|
+
return re.test(String(email).toLowerCase());
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export const slugFromPath = (path) =>
|
|
13
|
+
export const slugFromPath = (path) =>
|
|
14
|
+
path.match(/([\w-]+)\.(svelte\.md|md|svx)/i)?.[1] ?? null;
|
|
13
15
|
|
|
14
16
|
export function buildToC() {
|
|
15
17
|
// Based on https://projectcodeed.blogspot.com/2020/04/an-automatic-table-of-contents.html
|
|
16
|
-
|
|
18
|
+
|
|
17
19
|
// Get ToC div
|
|
18
20
|
let toc = document.getElementById("ToC");
|
|
19
|
-
|
|
21
|
+
|
|
20
22
|
//Add a header
|
|
21
23
|
var tocHeader = document.createElement("a");
|
|
22
|
-
tocHeader.classList.add(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
tocHeader.classList.add(
|
|
25
|
+
"mb-2",
|
|
26
|
+
"inline-block",
|
|
27
|
+
"w-auto",
|
|
28
|
+
"text-center",
|
|
29
|
+
"bg-gray-50",
|
|
30
|
+
"hover:bg-gray-100",
|
|
31
|
+
"py-1",
|
|
32
|
+
"px-2",
|
|
33
|
+
"border"
|
|
34
|
+
);
|
|
35
|
+
tocHeader.innerHTML =
|
|
36
|
+
"<span class='material-icons-outlined text-sm font-bold text-gray-500 align-text-bottom'>vertical_align_top</span>";
|
|
37
|
+
tocHeader.setAttribute("href", "#top");
|
|
38
|
+
tocHeader.setAttribute("title", "To Top of Page");
|
|
26
39
|
toc.appendChild(tocHeader);
|
|
27
40
|
|
|
28
41
|
// Create a list for the ToC entries
|
|
29
42
|
let tocList = document.createElement("ul");
|
|
30
43
|
|
|
31
44
|
// Find the primary content section
|
|
32
|
-
let content = document.getElementById("content")
|
|
45
|
+
let content = document.getElementById("content");
|
|
33
46
|
|
|
34
47
|
// Get the h2 tags - ToC entries
|
|
35
48
|
let headers = content.getElementsByTagName("h2");
|
|
@@ -38,19 +51,23 @@ export function buildToC() {
|
|
|
38
51
|
console.log("There are not any H2 elements in the document.");
|
|
39
52
|
} else {
|
|
40
53
|
// For each h2
|
|
41
|
-
for (let i = 0; i < headers.length; i++){
|
|
42
|
-
|
|
54
|
+
for (let i = 0; i < headers.length; i++) {
|
|
43
55
|
// Get Heading ID
|
|
44
|
-
let name = headers[i].id
|
|
45
|
-
|
|
56
|
+
let name = headers[i].id;
|
|
57
|
+
|
|
46
58
|
// list item for the entry
|
|
47
59
|
let tocListItem = document.createElement("li");
|
|
48
|
-
tocListItem.classList.add(
|
|
60
|
+
tocListItem.classList.add(
|
|
61
|
+
"text-teci-blue-light",
|
|
62
|
+
"hover:text-teci-blue-dark",
|
|
63
|
+
"text-sm",
|
|
64
|
+
"truncate"
|
|
65
|
+
);
|
|
49
66
|
|
|
50
67
|
// link for the h2
|
|
51
68
|
let tocEntry = document.createElement("a");
|
|
52
|
-
tocEntry.setAttribute("href","#"+name);
|
|
53
|
-
tocEntry.innerText=headers[i].innerText;
|
|
69
|
+
tocEntry.setAttribute("href", "#" + name);
|
|
70
|
+
tocEntry.innerText = headers[i].innerText;
|
|
54
71
|
|
|
55
72
|
// add link to list item list
|
|
56
73
|
tocListItem.appendChild(tocEntry);
|
|
@@ -58,7 +75,7 @@ export function buildToC() {
|
|
|
58
75
|
// add list item to list
|
|
59
76
|
tocList.appendChild(tocListItem);
|
|
60
77
|
}
|
|
61
|
-
|
|
78
|
+
|
|
62
79
|
// add list to toc element
|
|
63
80
|
toc.appendChild(tocList);
|
|
64
81
|
|
|
@@ -72,4 +89,4 @@ export function buildToC() {
|
|
|
72
89
|
|
|
73
90
|
return true;
|
|
74
91
|
}
|
|
75
|
-
}
|
|
92
|
+
}
|
package/variables.js
CHANGED