vowel 0.1.43 → 0.1.45

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/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [0.1.45](https://github.com/samlfair/vowel/compare/v0.1.44...v0.1.45) (2024-10-21)
6
+
7
+
8
+ ### Features
9
+
10
+ * add h-name to h1 ([ae5cc82](https://github.com/samlfair/vowel/commit/ae5cc82bf260605b49d7f0bd29762358b89f0aa4))
11
+
12
+ ## [0.1.44](https://github.com/samlfair/vowel/compare/v0.1.43...v0.1.44) (2024-10-21)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * metadata retrieval bug ([566f7cf](https://github.com/samlfair/vowel/commit/566f7cf64be2749e30cddcb474f6385638c408a9))
18
+ * webmentions bug ([2215ff5](https://github.com/samlfair/vowel/commit/2215ff5f5668d140535f6df3d30754fd685f22ae))
19
+
5
20
  ## [0.1.43](https://github.com/samlfair/vowel/compare/v0.1.42...v0.1.43) (2024-10-18)
6
21
 
7
22
  ## [0.1.42](https://github.com/samlfair/vowel/compare/v0.1.41...v0.1.42) (2024-10-18)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vowel",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "homepage": "https://vowel.cc",
5
5
  "author": "Sam Littlefair (https://littlefair.ca)",
6
6
  "repository": {
@@ -27,9 +27,9 @@
27
27
  "dependencies": {
28
28
  "@picocss/pico": "^1.5.10",
29
29
  "@sveltejs/adapter-auto": "^3.0.0",
30
- "@sveltejs/adapter-static": "^3.0.1",
31
- "@sveltejs/kit": "^2.5.28",
32
- "@sveltejs/vite-plugin-svelte": "^4.0.0-next.7",
30
+ "@sveltejs/adapter-static": "^3.0.5",
31
+ "@sveltejs/kit": "^2.7.2",
32
+ "@sveltejs/vite-plugin-svelte": "^4.0.0",
33
33
  "any-date-parser": "^1.5.4",
34
34
  "change-case": "^5.4.1",
35
35
  "commit-and-tag-version": "^12.4.4",
@@ -54,7 +54,7 @@
54
54
  "remark-parse": "^11.0.0",
55
55
  "remark-rehype": "^11.1.0",
56
56
  "spectre.css": "^0.5.9",
57
- "svelte": "^5.0.0-next.251",
57
+ "svelte": "^5.0.4",
58
58
  "typescript": "^5.0.0",
59
59
  "unified": "^11.0.4",
60
60
  "url-metadata": "^3.4.9",
@@ -29,13 +29,13 @@
29
29
  <!-- Title -->
30
30
  {#if title}
31
31
  {#if link && page.url}
32
- <h1 class="p-name">
32
+ <h1>
33
33
  <a href={page.url}>
34
34
  {page.imputedProperties.title || title || page.imputedProperties?.fileName}
35
35
  </a>
36
36
  </h1>
37
37
  {:else}
38
- <h1>{page.imputedProperties.title || title || page.imputedProperties?.fileName}</h1>
38
+ <h1 class="p-name">{page.imputedProperties.title || title || page.imputedProperties?.fileName}</h1>
39
39
  {/if}
40
40
  {/if}
41
41
 
@@ -18,7 +18,7 @@ export default async function getMetadata({ cache, url }) {
18
18
  htmlEntities: true
19
19
  })
20
20
 
21
- let parsedData = parser.parse(allMetadata.body)
21
+ let parsedData = parser.parse(allMetadata.responseBody)
22
22
  const webmentionEndpoint = parsedData?.html?.head?.link?.find(link => {
23
23
  return link["@_rel"] === "webmention"
24
24
  })?.["@_href"]
@@ -26,14 +26,8 @@ export default async function mutateMarkdownAST(ast, cache, webmentions, pageURL
26
26
  const { url } = node.children[0];
27
27
  node.url = url
28
28
 
29
- console.log("It's a URL")
30
-
31
29
  const { metadata } = await getMetadata({ cache, url })
32
30
 
33
- console.log({metadata})
34
- console.log("Hey there!")
35
- console.log({webmentions})
36
-
37
31
  node.metadata = metadata;
38
32
  node.value = url;
39
33
  delete node.children;
@@ -90,7 +90,7 @@ function DefaultDirectory(path) {
90
90
  * @param {import('./loadCache').Cache} cache
91
91
  * @returns {Promise<Directory>}
92
92
  */
93
- async function readFolder(folderPath, parents, cache, hidden, publishedData) {
93
+ async function readFolder(folderPath, parents, cache, hidden, publishedData, domain) {
94
94
  function filterFiles(file) {
95
95
  if (file.name.startsWith('.')) return false;
96
96
  if (file.name.startsWith('README')) return false;
@@ -106,7 +106,7 @@ async function readFolder(folderPath, parents, cache, hidden, publishedData) {
106
106
  console.log(`filesfound:${files.length}`);
107
107
 
108
108
  const promises = files.map(
109
- async (file) => await readFile(file, parents, cache, folderPath, hidden, publishedData)
109
+ async (file) => await readFile(file, parents, cache, folderPath, hidden, publishedData, domain)
110
110
  );
111
111
 
112
112
  const folder = (await Promise.all(promises)).reduce((acc, obj) => ({ ...acc, ...obj }), {});
@@ -125,16 +125,28 @@ async function readFolder(folderPath, parents, cache, hidden, publishedData) {
125
125
  return folder;
126
126
  }
127
127
 
128
- async function readFile(file, parents, cache, folderPath, hidden, publishedData) {
128
+ function buildHREF(url, domain) {
129
+ try {
130
+ const urlObj = new URL(domain)
131
+ urlObj.pathname = url
132
+ return urlObj.href
133
+ } catch (e) {
134
+ return undefined
135
+
136
+ }
137
+ }
138
+
139
+ async function readFile(file, parents, cache, folderPath, hidden, publishedData, domain) {
129
140
  const route = path.parse(file.name).name;
130
141
  const url = buildURL(parents, route);
131
142
  const filePath = path.join(folderPath, file.name);
132
-
143
+
133
144
  const extension = path.extname(file.name);
134
-
145
+
135
146
  const hide = (file.name.startsWith('$') && file.name.length > 1) || hidden;
136
-
147
+
137
148
  if (file.isFile() && extension === '.md') {
149
+ const href = buildHREF(url, domain)
138
150
  const startLoad = performance.now();
139
151
  const shortPath = parents + '/' + file.name;
140
152
 
@@ -147,7 +159,7 @@ async function readFile(file, parents, cache, folderPath, hidden, publishedData)
147
159
  filePublishedData = publishedData.at(-1)
148
160
  }
149
161
 
150
- const { ast, frontmatter, imputedProperties } = await readMarkdownFile(filePath, cache, filePublishedData, url);
162
+ const { ast, frontmatter, imputedProperties } = await readMarkdownFile(filePath, cache, filePublishedData, href);
151
163
 
152
164
  const loadTime = (performance.now() - startLoad).toFixed(2);
153
165
  // console.log(`📄 ${shortPath} (${loadTime}ms)`);
@@ -189,7 +201,7 @@ async function readFile(file, parents, cache, folderPath, hidden, publishedData)
189
201
  const shortPath = parents + '/' + file.name;
190
202
 
191
203
  const startLoad = performance.now();
192
- const folder = await readFolder(path.join(folderPath, file.name), url, cache, hide, publishedData);
204
+ const folder = await readFolder(path.join(folderPath, file.name), url, cache, hide, publishedData, domain);
193
205
 
194
206
  const loadTime = (performance.now() - startLoad).toFixed(2);
195
207
  // console.log(`📁 ${shortPath} (${loadTime}ms)`);
@@ -221,11 +233,11 @@ async function readFile(file, parents, cache, folderPath, hidden, publishedData)
221
233
  * @param {import('./loadCache').Cache} cache
222
234
  * @returns {Promise<ProcessedFiles>}
223
235
  */
224
- export default async function processMarkdownFiles(cache, publishedData) {
236
+ export default async function processMarkdownFiles(cache, publishedData, domain) {
225
237
  /** @type {Array<string>} */
226
238
  // @ts-ignore
227
239
  const [homeDir] = $home;
228
- const folder = await readFolder(homeDir, '', cache, null, publishedData);
240
+ const folder = await readFolder(homeDir, '', cache, null, publishedData, domain);
229
241
 
230
242
  return { folder, finalCache: cache };
231
243
  }
@@ -5,7 +5,6 @@ export default async function sendWebmention({ endpoint, source, target }) {
5
5
  params.append('source', source)
6
6
  params.append('target', target)
7
7
 
8
-
9
8
  const response = await fetch(endpoint, {
10
9
  method: "POST",
11
10
  body: params,
@@ -15,6 +14,7 @@ export default async function sendWebmention({ endpoint, source, target }) {
15
14
  })
16
15
 
17
16
  console.log({
17
+ source, target,
18
18
  webmentionResponse: await response.json()
19
19
  })
20
20
 
@@ -25,22 +25,21 @@ export async function GET() {
25
25
  // everything.request.url
26
26
 
27
27
  let settings
28
-
28
+
29
29
  const settingsPath = join($home[0], "/settings.md")
30
30
  const settingsExists = await checkFileExists(settingsPath);
31
- if(settingsExists) {
31
+ if (settingsExists) {
32
32
  settings = await readMarkdownFile(settingsPath)
33
33
  }
34
34
 
35
35
  // Get published articles from live site
36
36
  const publishedData = await getPublishedData(settings.frontmatter.domain)
37
37
 
38
- console.log({publish: $publish[0]})
39
-
40
38
  if($publish[0]) {
41
39
  const initialCache = await loadCache($home[0]);
42
-
43
- const { folder: website } = await processMarkdownFiles(initialCache, publishedData);
40
+
41
+
42
+ const { folder: website } = await processMarkdownFiles(initialCache, publishedData, settings.frontmatter.domain);
44
43
  }
45
44
 
46
45
  const headers = {
@@ -48,8 +47,6 @@ export async function GET() {
48
47
  'Content-Type': 'text/plain'
49
48
  };
50
49
 
51
- console.log({ publishedData })
52
-
53
50
  const response = new Response(JSON.stringify(publishedData), {
54
51
  headers
55
52
  });