vowel 0.1.0 → 0.1.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/package.json +1 -1
- package/src/lib/components/Breadcrumbs.svelte +1 -1
- package/src/lib/components/DefaultStyles.svelte +12 -0
- package/src/lib/components/Frontmatter.svelte +4 -2
- package/src/lib/components/FrontmatterProperty.svelte +21 -13
- package/src/lib/components/Markdown/LinkPreview.svelte +25 -19
- package/src/lib/components/Markdown/index.svelte +6 -5
- package/src/lib/components/Page.svelte +4 -2
- 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 +6 -8
- package/src/routes/feed.xml/+server.js +1 -1
- 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;
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
let { props } = $props();
|
|
12
12
|
// TODO: Normalize frontmatter props
|
|
13
|
-
let { properties, website } = $derived(props);
|
|
13
|
+
let { properties, website, format } = $derived(props);
|
|
14
|
+
|
|
15
|
+
console.log(`Frontmatter format ${format}`);
|
|
14
16
|
|
|
15
17
|
const excludedProperties = [
|
|
16
18
|
'title',
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
{#if website.hasOwnProperty(key)}
|
|
48
50
|
<FrontmatterTaxonomy {property} {key} {website} />
|
|
49
51
|
{:else}
|
|
50
|
-
<FrontmatterProperty {property} {key} />
|
|
52
|
+
<FrontmatterProperty {property} {key} {format} />
|
|
51
53
|
{/if}
|
|
52
54
|
{/if}
|
|
53
55
|
{/each}
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
import Image from './Markdown/Image.svelte';
|
|
5
5
|
|
|
6
6
|
/** @type {{ property: any, key: string }}*/
|
|
7
|
-
let { property, key } = $props();
|
|
7
|
+
let { property, key, format } = $props();
|
|
8
|
+
|
|
9
|
+
console.log(`Frontmatter property format: ${format}`);
|
|
8
10
|
</script>
|
|
9
11
|
|
|
10
12
|
{#if property}
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
{#if value.type === 'array'}
|
|
31
33
|
{@render array(value.output)}
|
|
32
34
|
{:else if value.type === 'object'}
|
|
33
|
-
<Frontmatter props={{ properties: value.output }} />
|
|
35
|
+
<Frontmatter props={{ properties: value.output, format }} />
|
|
34
36
|
{:else if value.type === 'image'}
|
|
35
37
|
{@render image(value.output)}
|
|
36
38
|
{:else if value.type === 'date'}
|
|
@@ -52,19 +54,25 @@
|
|
|
52
54
|
{/snippet}
|
|
53
55
|
|
|
54
56
|
{#snippet url(value)}
|
|
55
|
-
|
|
57
|
+
{#if format === 'rss'}
|
|
56
58
|
<a href={value.url}>
|
|
57
|
-
{
|
|
58
|
-
<img src={value['og:image']} alt="" />
|
|
59
|
-
{/if}
|
|
60
|
-
<h2>
|
|
61
|
-
{value['og:title'] || value.title}
|
|
62
|
-
</h2>
|
|
63
|
-
<p>
|
|
64
|
-
{value['og:description']}
|
|
65
|
-
</p>
|
|
59
|
+
{value.title || value['og:title']}
|
|
66
60
|
</a>
|
|
67
|
-
|
|
61
|
+
{:else}
|
|
62
|
+
<article>
|
|
63
|
+
<a href={value.url}>
|
|
64
|
+
{#if value['og:image']}
|
|
65
|
+
<img src={value['og:image']} alt="" />
|
|
66
|
+
{/if}
|
|
67
|
+
<h2>
|
|
68
|
+
{value.title || value['og:title']}
|
|
69
|
+
</h2>
|
|
70
|
+
<p>
|
|
71
|
+
{value['og:description']}
|
|
72
|
+
</p>
|
|
73
|
+
</a>
|
|
74
|
+
</article>
|
|
75
|
+
{/if}
|
|
68
76
|
{/snippet}
|
|
69
77
|
|
|
70
78
|
{#snippet pdf(value)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
let { metadata, url } = $props();
|
|
2
|
+
let { metadata, url, format } = $props();
|
|
3
3
|
let { image, description, author } = $derived(metadata || {});
|
|
4
4
|
|
|
5
5
|
const href = $derived(metadata?.ogURL || metadata?.canonicalURL || url || '');
|
|
@@ -10,24 +10,30 @@
|
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
{#if metadata}
|
|
13
|
-
|
|
14
|
-
<a {href}>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
{#if format === 'rss'}
|
|
14
|
+
<p><a {href}>{title ? title + ' - ' : ''}{urlObject.host}</a></p>
|
|
15
|
+
{:else}
|
|
16
|
+
<article class="link-preview">
|
|
17
|
+
<a {href}>
|
|
18
|
+
{#if image}
|
|
19
|
+
<img src={image} alt="" />
|
|
20
|
+
{/if}
|
|
21
|
+
<h2>{title ? title + ' - ' : ''}<span class="host">{urlObject.host}</span></h2>
|
|
22
|
+
{#if author}
|
|
23
|
+
<p>
|
|
24
|
+
By {author}
|
|
25
|
+
</p>
|
|
26
|
+
{/if}
|
|
27
|
+
{#if description}
|
|
28
|
+
<p>
|
|
29
|
+
{description}
|
|
30
|
+
</p>
|
|
31
|
+
{/if}
|
|
32
|
+
</a>
|
|
33
|
+
</article>
|
|
34
|
+
{/if}
|
|
35
|
+
{:else if format === 'rss'}
|
|
36
|
+
<p><a {href}>{urlObject.host}</a></p>
|
|
31
37
|
{:else}
|
|
32
38
|
<article class="link-preview">
|
|
33
39
|
<a {href}>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
let { props } = $props();
|
|
13
13
|
|
|
14
|
-
let { ast, level, website } = $derived(props);
|
|
14
|
+
let { ast, level, website, format } = $derived(props);
|
|
15
15
|
|
|
16
16
|
function getElement(node) {
|
|
17
17
|
if (node.type === 'heading') {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
<section class={createFolderClass(path)}>
|
|
44
44
|
{#each pages as page}
|
|
45
45
|
<article class={createPageClass(page.url, 'thumbnail')}>
|
|
46
|
-
<Page link={true} {content} {page} level={level + 1} {website} />
|
|
46
|
+
<Page link={true} {content} {page} level={level + 1} {website} {format} />
|
|
47
47
|
</article>
|
|
48
48
|
{/each}
|
|
49
49
|
</section>
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
level={level + 1}
|
|
56
56
|
{website}
|
|
57
57
|
content={false}
|
|
58
|
+
{format}
|
|
58
59
|
/>
|
|
59
60
|
</article>
|
|
60
61
|
{:else if node.type === 'heading'}
|
|
@@ -62,16 +63,16 @@
|
|
|
62
63
|
<svelte:self props={{ ast: node.children, level }} />
|
|
63
64
|
</svelte:element>
|
|
64
65
|
{:else if node.type === 'link' && node.children}
|
|
65
|
-
<Link {node} {level} {website} />
|
|
66
|
+
<Link {node} {level} {website} {format} />
|
|
66
67
|
{:else if node.type === 'thematicBreak'}
|
|
67
68
|
<hr />
|
|
68
69
|
{:else if node.type === 'image'}
|
|
69
70
|
<Image {node} />
|
|
70
71
|
{:else if node.type === 'url'}
|
|
71
|
-
<LinkPreview url={node.value} metadata={node.metadata} />
|
|
72
|
+
<LinkPreview url={node.value} metadata={node.metadata} {format} />
|
|
72
73
|
{:else if node.children}
|
|
73
74
|
<svelte:element this={getElement(node)}>
|
|
74
|
-
<svelte:self props={{ ast: node.children, level }} />
|
|
75
|
+
<svelte:self props={{ ast: node.children, level, format }} />
|
|
75
76
|
</svelte:element>
|
|
76
77
|
{:else if node.type === 'text'}
|
|
77
78
|
<Text {node} />
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
let { page, content = true, link, level = 0, website = {}, format = 'html' } = $props();
|
|
6
6
|
let { ast, title, date, image, imputedProperties } = $derived(page || {});
|
|
7
7
|
|
|
8
|
+
console.log(`Page format: ${format}`);
|
|
9
|
+
|
|
8
10
|
const dateObject = date?.type === 'date' && new Date(date.output);
|
|
9
11
|
// TODO: Add conditional logic for format = 'xml'
|
|
10
12
|
</script>
|
|
@@ -46,7 +48,7 @@
|
|
|
46
48
|
<time datetime={dateObject.toISOString()}>{dateObject.toLocaleDateString()}</time>
|
|
47
49
|
{/if}
|
|
48
50
|
|
|
49
|
-
<Frontmatter props={{ properties: page, website }} />
|
|
51
|
+
<Frontmatter props={{ properties: page, website, format }} />
|
|
50
52
|
|
|
51
53
|
{#if page?.description || (!content && page?.imputedProperties?.description)}
|
|
52
54
|
<p class="description">{page?.description || page?.imputedProperties.description}</p>
|
|
@@ -54,6 +56,6 @@
|
|
|
54
56
|
|
|
55
57
|
{#if level < 2 && content}
|
|
56
58
|
<div class="content">
|
|
57
|
-
<Markdown props={{ ast, level, website }} />
|
|
59
|
+
<Markdown props={{ ast, level, website, format }} />
|
|
58
60
|
</div>
|
|
59
61
|
{/if}
|
|
@@ -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
|
|
|
@@ -44,8 +42,8 @@
|
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
const breadcrumbs = getBreadcrumbs().slice(1, -1).reverse();
|
|
47
|
-
const breadcrumbSegment = breadcrumbs.length ?
|
|
48
|
-
return `${pageMetaTitle}
|
|
45
|
+
const breadcrumbSegment = breadcrumbs.length ? ` - ${breadcrumbs.join(' - ')} - ` : '';
|
|
46
|
+
return `${pageMetaTitle}${breadcrumbSegment}${siteTitle}`;
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
function getFavicon() {
|
|
@@ -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