vowel 0.1.0 → 0.1.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/package.json +1 -1
- package/src/lib/components/Breadcrumbs.svelte +1 -1
- package/src/lib/components/DefaultStyles.svelte +12 -0
- package/src/lib/components/Sitemap.svelte +3 -3
- package/src/lib/utilities/getFileLabel.js +20 -4
- package/src/lib/utilities/getFolderLabel.js +6 -2
- package/src/lib/utilities/readMarkdownFile.js +5 -4
- package/src/routes/[...path]/+layout.server.js +4 -3
- package/src/routes/[...path]/+page.svelte +4 -6
- package/vite.config.js +3 -0
- package/content/vercel.json +0 -5
- package/vercel.json +0 -5
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
const path = $derived($page.data.segments.slice(0, level).join('/'));
|
|
8
8
|
// The page for the current crumb
|
|
9
9
|
const crumbyPage = $derived(getFolder($page.data.website, path));
|
|
10
|
-
const folderLabel = $derived(getFolderLabel(crumbyPage));
|
|
10
|
+
const folderLabel = $derived(getFolderLabel(crumbyPage, true, false));
|
|
11
11
|
|
|
12
12
|
const active = $derived(level === $page.data.segments.length);
|
|
13
13
|
</script>
|
|
@@ -29,6 +29,14 @@
|
|
|
29
29
|
overflow-x: hidden;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/* Global */
|
|
33
|
+
|
|
34
|
+
:global(:where(img)) {
|
|
35
|
+
display: block;
|
|
36
|
+
width: 100%;
|
|
37
|
+
height: auto;
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
/* Header */
|
|
33
41
|
|
|
34
42
|
:global(:where(nav)) {
|
|
@@ -54,6 +62,10 @@
|
|
|
54
62
|
font-size: 2em;
|
|
55
63
|
}
|
|
56
64
|
|
|
65
|
+
:global(:where(.sitemap)) {
|
|
66
|
+
margin: auto;
|
|
67
|
+
}
|
|
68
|
+
|
|
57
69
|
:global(:where(nav, aside.sitemap) :where([aria-current='page'], [aria-current='true'])) {
|
|
58
70
|
text-decoration: none;
|
|
59
71
|
color: unset;
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
</li>
|
|
20
20
|
{/if}
|
|
21
21
|
{#each Object.keys(section) as key}
|
|
22
|
-
{#if Object.keys(section[key]).length === 1 && section[key].$}
|
|
22
|
+
{#if Object.keys(section[key]).length === 1 && section[key].$ && !section[key].$.date}
|
|
23
23
|
<li class={key}>
|
|
24
24
|
<a aria-current={isActiveLink(segments, key)} href={section[key].$.url}>
|
|
25
|
-
{getFileLabel(section[key]['$']) || getFolderLabel(section[key])}
|
|
25
|
+
{getFileLabel(section[key]['$'], true) || getFolderLabel(section[key], true)}
|
|
26
26
|
</a>
|
|
27
27
|
</li>
|
|
28
|
-
{:else if section[key].$}
|
|
28
|
+
{:else if section[key].$ && !section[key].$.date}
|
|
29
29
|
<li class={key}>
|
|
30
30
|
<a aria-current={isActiveLink(segments, key)} href={section[key].$.url}>
|
|
31
31
|
{getFileLabel(section[key]['$']) || getFolderLabel(section[key])}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { capitalCase } from 'change-case';
|
|
2
|
+
|
|
1
3
|
function createTitleFromDescription(description) {
|
|
2
4
|
if (description?.length > 30) {
|
|
3
5
|
return description.slice(0, 30) + '...';
|
|
@@ -5,14 +7,28 @@ function createTitleFromDescription(description) {
|
|
|
5
7
|
return description;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
export default function getFileLabel(page) {
|
|
10
|
+
export default function getFileLabel(page, shorter = false, date = true) {
|
|
11
|
+
const description = createTitleFromDescription(
|
|
12
|
+
page?.description || page?.imputedProperties?.description
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const fileName = page?.imputedProperties?.fileName
|
|
16
|
+
? capitalCase(page?.imputedProperties?.fileName)
|
|
17
|
+
: false;
|
|
18
|
+
|
|
19
|
+
const formattedDate =
|
|
20
|
+
page?.date && date
|
|
21
|
+
? new Intl.DateTimeFormat('en-US').format(new Date(page?.date?.output))
|
|
22
|
+
: false;
|
|
23
|
+
|
|
9
24
|
return (
|
|
10
25
|
page?.breadcrumb ||
|
|
11
26
|
page?.title ||
|
|
12
27
|
page?.imputedProperties?.title ||
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
formattedDate ||
|
|
29
|
+
(shorter && fileName) ||
|
|
30
|
+
description ||
|
|
31
|
+
fileName ||
|
|
16
32
|
null
|
|
17
33
|
);
|
|
18
34
|
}
|
|
@@ -2,7 +2,11 @@ import { getFileLabel } from '.';
|
|
|
2
2
|
|
|
3
3
|
const fallBackLabel = 'Untitled';
|
|
4
4
|
|
|
5
|
-
export default function getFolderLabel(folder) {
|
|
5
|
+
export default function getFolderLabel(folder, shorter, date) {
|
|
6
6
|
if (typeof folder !== 'object') return 'Untitled';
|
|
7
|
-
return
|
|
7
|
+
return (
|
|
8
|
+
getFileLabel(folder['_'], shorter, date) ||
|
|
9
|
+
getFileLabel(folder['$'], shorter, date) ||
|
|
10
|
+
fallBackLabel
|
|
11
|
+
);
|
|
8
12
|
}
|
|
@@ -30,13 +30,14 @@ function parseFrontmatter(frontmatterNode) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function deduceDescriptionFromAST(ast) {
|
|
33
|
-
for (let i = 0; i < ast?.
|
|
34
|
-
if (ast?.
|
|
33
|
+
for (let i = 0; i < ast?.length; i++) {
|
|
34
|
+
if (ast?.[i]?.type === 'paragraph') {
|
|
35
35
|
const firstParagraph = toString(ast[i]);
|
|
36
36
|
if (firstParagraph.length > 150) {
|
|
37
37
|
return firstParagraph.slice(0, 150);
|
|
38
|
+
} else if (firstParagraph.length > 1) {
|
|
39
|
+
return firstParagraph;
|
|
38
40
|
}
|
|
39
|
-
return firstParagraph;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
return null;
|
|
@@ -117,7 +118,7 @@ export default async function readMarkdownFile(filePath, cache) {
|
|
|
117
118
|
if (!frontmatter.title && imputedTitle) frontmatter.title = imputedTitle;
|
|
118
119
|
|
|
119
120
|
const imputedProperties = {
|
|
120
|
-
description: deduceDescriptionFromAST(
|
|
121
|
+
description: deduceDescriptionFromAST(filteredAST),
|
|
121
122
|
title: imputedTitle,
|
|
122
123
|
fileName
|
|
123
124
|
};
|
|
@@ -2,10 +2,11 @@ import { loadCache, writeCache, processMarkdownFiles } from '$lib/utilities';
|
|
|
2
2
|
import { access } from 'fs/promises';
|
|
3
3
|
import { constants } from 'fs';
|
|
4
4
|
import { normalize, join, basename } from 'path';
|
|
5
|
+
import { dev } from '$app/environment';
|
|
5
6
|
|
|
6
7
|
export const prerender = true;
|
|
7
|
-
|
|
8
|
-
// export const ssr =
|
|
8
|
+
export const csr = dev;
|
|
9
|
+
// export const ssr = true;
|
|
9
10
|
|
|
10
11
|
let contentCache;
|
|
11
12
|
let contentCacheTime;
|
|
@@ -67,5 +68,5 @@ export async function load() {
|
|
|
67
68
|
|
|
68
69
|
const folderName = basename($home[0]);
|
|
69
70
|
|
|
70
|
-
return { website, homeDir: $home[0], folderName, files };
|
|
71
|
+
return { website, homeDir: $home[0], folderName, files, dev };
|
|
71
72
|
}
|
|
@@ -6,15 +6,13 @@
|
|
|
6
6
|
import { error } from '@sveltejs/kit';
|
|
7
7
|
import { getFolder, getFolderLabel } from '../../lib/utilities';
|
|
8
8
|
import { page as pageStore } from '$app/stores';
|
|
9
|
-
import { dev, building } from '$app/environment';
|
|
10
9
|
|
|
11
10
|
let { data } = $props();
|
|
12
11
|
|
|
13
12
|
const { website, folderName } = $derived(data);
|
|
14
13
|
const { slogan } = website;
|
|
15
14
|
|
|
16
|
-
if (data.files.css.exists
|
|
17
|
-
// Import styles in dev mode
|
|
15
|
+
if (data.dev && data.files.css.exists) {
|
|
18
16
|
import(/* @vite-ignore */ data.files.css.path);
|
|
19
17
|
}
|
|
20
18
|
|
|
@@ -73,6 +71,7 @@
|
|
|
73
71
|
|
|
74
72
|
<!-- svelte-ignore state_referenced_locally -->
|
|
75
73
|
<!-- svelte-ignore state_referenced_locally -->
|
|
74
|
+
|
|
76
75
|
<svelte:head>
|
|
77
76
|
<title>{makePageMetaTitle()}</title>
|
|
78
77
|
<meta property="”og:url”" content={page.url} />
|
|
@@ -86,9 +85,8 @@
|
|
|
86
85
|
{#if favicon}
|
|
87
86
|
<link rel="icon" href={favicon} />
|
|
88
87
|
{/if}
|
|
89
|
-
{#if data.files.css.exists
|
|
90
|
-
|
|
91
|
-
<link rel="stylesheet" href="styles.css" />
|
|
88
|
+
{#if !data.dev && data.files.css.exists}
|
|
89
|
+
<link rel="stylesheet" href="/styles.css" />
|
|
92
90
|
{/if}
|
|
93
91
|
</svelte:head>
|
|
94
92
|
|
package/vite.config.js
CHANGED
package/content/vercel.json
DELETED