vowel 0.1.41 → 0.1.42
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 +7 -0
- package/package.json +1 -1
- package/src/lib/utilities/mutateMarkdownAST.js +6 -6
- package/src/lib/utilities/mutateMarkdownFrontmatter.js +4 -4
- package/src/lib/utilities/processMarkdownFiles.js +1 -1
- package/src/lib/utilities/readMarkdownFile.js +2 -2
- package/src/lib/utilities/sendWebmention.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.42](https://github.com/samlfair/vowel/compare/v0.1.41...v0.1.42) (2024-10-18)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* un-hardcode webmention urls ([3421a69](https://github.com/samlfair/vowel/commit/3421a6998aa4ba20613b84c707e62fe273ddf327))
|
|
11
|
+
|
|
5
12
|
## [0.1.41](https://github.com/samlfair/vowel/compare/v0.1.40...v0.1.41) (2024-10-17)
|
|
6
13
|
|
|
7
14
|
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ function isURL(string) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export default async function mutateMarkdownAST(ast, cache, webmentions) {
|
|
13
|
+
export default async function mutateMarkdownAST(ast, cache, webmentions, pageURL) {
|
|
14
14
|
|
|
15
15
|
const promises = ast.map(async (node) => {
|
|
16
16
|
// TODO: Improve this URL regex
|
|
@@ -34,19 +34,19 @@ export default async function mutateMarkdownAST(ast, cache, webmentions) {
|
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
console.log(!!webmentions)
|
|
37
|
-
console.log({webmentions})
|
|
37
|
+
console.log({ webmentions })
|
|
38
38
|
console.log(webmentions.find(webmention => webmention.target === url))
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
if(webmentions && !webmentions.find(webmention => webmention.target === url)) {
|
|
40
|
+
|
|
41
|
+
if (webmentions && !webmentions.find(webmention => webmention.target === url)) {
|
|
42
42
|
webmentions.push({
|
|
43
43
|
target: url,
|
|
44
44
|
status: "new"
|
|
45
45
|
})
|
|
46
46
|
} else if (webmentions) {
|
|
47
47
|
const webmention = webmentions.find(webmention => webmention.target === url)
|
|
48
|
-
if(webmention.status === "new") {
|
|
49
|
-
webmention.status = await sendWebmention(response.responseBody)
|
|
48
|
+
if (webmention.status === "new") {
|
|
49
|
+
webmention.status = await sendWebmention({ body: response.responseBody, target: webmention.target, source: pageURL })
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -24,7 +24,7 @@ function imputeType(value) {
|
|
|
24
24
|
return 'other';
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export default async function mutateMarkdownFrontmatter(frontmatter, cache, webmentions) {
|
|
27
|
+
export default async function mutateMarkdownFrontmatter(frontmatter, cache, webmentions, pageURL) {
|
|
28
28
|
const keys = Object.keys(frontmatter);
|
|
29
29
|
|
|
30
30
|
const promises = keys.map(async (key) => {
|
|
@@ -96,15 +96,15 @@ export default async function mutateMarkdownFrontmatter(frontmatter, cache, webm
|
|
|
96
96
|
og_image: url['og:image']
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
if(webmentions && !webmentions.find(webmention => webmention.target === input)) {
|
|
99
|
+
if (webmentions && !webmentions.find(webmention => webmention.target === input)) {
|
|
100
100
|
webmentions.push({
|
|
101
101
|
target: input,
|
|
102
102
|
status: "new"
|
|
103
103
|
})
|
|
104
104
|
} else if (webmentions) {
|
|
105
105
|
const webmention = webmentions.find(webmention => webmention.target === input)
|
|
106
|
-
if(webmention.status === "new") {
|
|
107
|
-
webmention.status = await sendWebmention(metadata.responseBody)
|
|
106
|
+
if (webmention.status === "new") {
|
|
107
|
+
webmention.status = await sendWebmention({ body: metadata.responseBody, target: webmention.target, source: pageURL })
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -147,7 +147,7 @@ async function readFile(file, parents, cache, folderPath, hidden, publishedData)
|
|
|
147
147
|
filePublishedData = publishedData.at(-1)
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
const { ast, frontmatter, imputedProperties } = await readMarkdownFile(filePath, cache, filePublishedData);
|
|
150
|
+
const { ast, frontmatter, imputedProperties } = await readMarkdownFile(filePath, cache, filePublishedData, url);
|
|
151
151
|
|
|
152
152
|
const loadTime = (performance.now() - startLoad).toFixed(2);
|
|
153
153
|
// console.log(`📄 ${shortPath} (${loadTime}ms)`);
|
|
@@ -110,7 +110,7 @@ function imputeTitleFromAST(ast) {
|
|
|
110
110
|
* @returns {Promise<ParsedMarkdown>}
|
|
111
111
|
* @throws {Error} Will throw an error if the file cannot be read or parsed.
|
|
112
112
|
*/
|
|
113
|
-
export default async function readMarkdownFile(filePath, cache, publishedData) {
|
|
113
|
+
export default async function readMarkdownFile(filePath, cache, publishedData, url) {
|
|
114
114
|
const fileName = path.basename(filePath.slice(0, -3));
|
|
115
115
|
|
|
116
116
|
const fileContent = await fs.readFile(filePath, 'utf8');
|
|
@@ -170,7 +170,7 @@ export default async function readMarkdownFile(filePath, cache, publishedData) {
|
|
|
170
170
|
|
|
171
171
|
const webmentions = publishedData?.webmentions
|
|
172
172
|
|
|
173
|
-
const promises = [mutateMarkdownAST(ast.children, cache, webmentions)];
|
|
173
|
+
const promises = [mutateMarkdownAST(ast.children, cache, webmentions, url)];
|
|
174
174
|
|
|
175
175
|
// Don't mutate frontmatter on the settings pages
|
|
176
176
|
if (!filePath.endsWith('settings.md'))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { XMLParser } from "fast-xml-parser"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
export default async function sendWebmention(body) {
|
|
4
|
+
export default async function sendWebmention({ body, source, target }) {
|
|
5
5
|
try {
|
|
6
6
|
const parser = new XMLParser({
|
|
7
7
|
unpairedTags: ["!doctype", "meta", "link", "hr", "br", "img"],
|
|
@@ -18,8 +18,8 @@ export default async function sendWebmention(body) {
|
|
|
18
18
|
|
|
19
19
|
if (webmentionEndpoint) {
|
|
20
20
|
const params = new URLSearchParams()
|
|
21
|
-
params.append('source',
|
|
22
|
-
params.append('target',
|
|
21
|
+
params.append('source', source)
|
|
22
|
+
params.append('target', target)
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
const response = await fetch(webmentionEndpoint, {
|