vowel 0.1.20 → 0.1.22
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/DefaultStyles.svelte +4 -0
- package/src/lib/components/Frontmatter.svelte +2 -1
- package/src/lib/components/Markdown/LinkPreview.svelte +5 -5
- package/src/lib/utilities/mutateMarkdownFrontmatter.js +17 -3
- package/src/lib/utilities/writeCache.js +1 -0
- package/src/routes/[...path]/+layout.server.js +7 -5
- package/src/routes/[...path]/+page.server.js +4 -0
- package/src/routes/[...path]/+page.svelte +2 -4
- package/svelte.config.js +1 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
let { metadata, url, format } = $props();
|
|
3
|
-
let { image, description, author } = $derived(metadata || {});
|
|
3
|
+
let { image, description, og_description, author } = $derived(metadata || {});
|
|
4
4
|
|
|
5
|
-
const href = $derived(metadata?.
|
|
5
|
+
const href = $derived(metadata?.og_url || metadata?.canonical || url || '');
|
|
6
6
|
|
|
7
|
-
const title = $derived(metadata?.
|
|
7
|
+
const title = $derived(metadata?.og_title || metadata?.title || '');
|
|
8
8
|
|
|
9
9
|
const urlObject = new URL(url);
|
|
10
10
|
</script>
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
By {author}
|
|
25
25
|
</p>
|
|
26
26
|
{/if}
|
|
27
|
-
{#if description}
|
|
27
|
+
{#if description || og_description}
|
|
28
28
|
<p>
|
|
29
|
-
{description}
|
|
29
|
+
{description || og_description}
|
|
30
30
|
</p>
|
|
31
31
|
{/if}
|
|
32
32
|
</a>
|
|
@@ -81,15 +81,29 @@ export default async function mutateMarkdownFrontmatter(frontmatter, cache) {
|
|
|
81
81
|
includeResponseBody: false,
|
|
82
82
|
ensureSecureImageRequest: true
|
|
83
83
|
});
|
|
84
|
-
|
|
84
|
+
|
|
85
|
+
const selectedMetadata = {
|
|
86
|
+
url: metadata.url,
|
|
87
|
+
canonical: metadata.canonical,
|
|
88
|
+
title: metadata.title,
|
|
89
|
+
image: metadata.image,
|
|
90
|
+
favicons: url.favicons,
|
|
91
|
+
og_url: url['og:url'],
|
|
92
|
+
og_title: url['og:title'],
|
|
93
|
+
og_description: url['og:description'],
|
|
94
|
+
og_site_name: url['og:side_name'],
|
|
95
|
+
og_image: url['og:image']
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
cache[input] = selectedMetadata;
|
|
85
99
|
|
|
86
100
|
frontmatter[key] = {
|
|
87
101
|
type: 'url',
|
|
88
|
-
output:
|
|
102
|
+
output: selectedMetadata,
|
|
89
103
|
input
|
|
90
104
|
};
|
|
91
105
|
} catch (e) {
|
|
92
|
-
|
|
106
|
+
console.error(`Error on URL in frontmatter: ${frontmatter[key]}`);
|
|
93
107
|
frontmatter[key] = {
|
|
94
108
|
type: 'string',
|
|
95
109
|
output: input,
|
|
@@ -29,7 +29,9 @@ async function checkFileExists(filePath, homeDir) {
|
|
|
29
29
|
export async function load() {
|
|
30
30
|
// const startLoad = performance.now();
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const hotURLCache = await loadCache($home[0]);
|
|
33
|
+
|
|
34
|
+
const initialURLCache = JSON.parse(JSON.stringify(hotURLCache));
|
|
33
35
|
|
|
34
36
|
const cssExists = await checkFileExists(normalize('/assets/styles.css'), $home[0]);
|
|
35
37
|
|
|
@@ -56,15 +58,15 @@ export async function load() {
|
|
|
56
58
|
data = contentCache;
|
|
57
59
|
} else {
|
|
58
60
|
console.log('Not using content cache');
|
|
59
|
-
data = await processMarkdownFiles(
|
|
61
|
+
data = await processMarkdownFiles(hotURLCache);
|
|
60
62
|
if ($build[0]) contentCache = data;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
// const { folder: website, finalCache } = await processMarkdownFiles(initialCache);
|
|
64
|
-
const { folder: website
|
|
66
|
+
const { folder: website } = data;
|
|
65
67
|
|
|
66
|
-
if (JSON.stringify(initialURLCache) !== JSON.stringify(
|
|
67
|
-
writeCache(
|
|
68
|
+
if (JSON.stringify(initialURLCache) !== JSON.stringify(hotURLCache)) {
|
|
69
|
+
writeCache(hotURLCache, $home[0]);
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
// console.log(`Load time: ${(performance.now() - startLoad).toFixed(2)} ms`);
|
|
@@ -27,8 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
const { website, folderName } = $derived(data);
|
|
29
29
|
|
|
30
|
-
throw error(404, { message: 'Page not found', ...data });
|
|
31
|
-
|
|
32
30
|
const { slogan, theme } = $derived(website._);
|
|
33
31
|
|
|
34
32
|
// Import CSS for HMR in dev mode
|
|
@@ -38,8 +36,8 @@
|
|
|
38
36
|
|
|
39
37
|
const page = $derived(getPage(website, data.path));
|
|
40
38
|
|
|
41
|
-
if (!page) {
|
|
42
|
-
error(404, 'Page not found');
|
|
39
|
+
if (!page || page.url === '/404') {
|
|
40
|
+
throw error(404, { message: 'Page not found', ...data });
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
const websiteTitle = data.website._.title || data.folderName;
|