@tryghost/algolia-fragmenter 0.2.8 → 0.2.9
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/README.md +1 -1
- package/lib/transformer.js +4 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ const fragments = records.reduce(transforms.fragmentTransformer, []);
|
|
|
29
29
|
|
|
30
30
|
## Development
|
|
31
31
|
|
|
32
|
-
Install dependencies from the repository root with `pnpm install`. From the root, run this package's tests and
|
|
32
|
+
Install dependencies from the repository root with `pnpm install`. From the root, run this package's tests and lint checks with:
|
|
33
33
|
|
|
34
34
|
```sh
|
|
35
35
|
pnpm --filter @tryghost/algolia-fragmenter test
|
package/lib/transformer.js
CHANGED
|
@@ -56,12 +56,8 @@ module.exports.fragmentTransformer = (recordAccumulator, node) => {
|
|
|
56
56
|
|
|
57
57
|
// TODO: switch this on in verbose mode only
|
|
58
58
|
// // If fragments are too long, we need this to see which fragment it was
|
|
59
|
-
// console.log(`Created fragment: `, objectID, fragment.url || node.url, fragment.html.length); // eslint-disable-line no-console
|
|
60
59
|
|
|
61
|
-
return [
|
|
62
|
-
...fragmentAccumulator,
|
|
63
|
-
{...node, ...fragment, objectID: objectID}
|
|
64
|
-
];
|
|
60
|
+
return [...fragmentAccumulator, {...node, ...fragment, objectID: objectID}];
|
|
65
61
|
}, []);
|
|
66
62
|
|
|
67
63
|
return [...recordAccumulator, ...records];
|
|
@@ -78,7 +74,7 @@ module.exports._testReduceFragmentsUnderHeadings = reduceFragmentsUnderHeadings;
|
|
|
78
74
|
module.exports.transformToAlgoliaObject = (posts, ignoreSlugs) => {
|
|
79
75
|
const algoliaObjects = [];
|
|
80
76
|
|
|
81
|
-
posts.map(
|
|
77
|
+
posts.map(post => {
|
|
82
78
|
// Define the properties we need for Algolia
|
|
83
79
|
const algoliaPost = {
|
|
84
80
|
objectID: post.id,
|
|
@@ -100,13 +96,13 @@ module.exports.transformToAlgoliaObject = (posts, ignoreSlugs) => {
|
|
|
100
96
|
}
|
|
101
97
|
|
|
102
98
|
if (post.tags && post.tags.length) {
|
|
103
|
-
post.tags.forEach(
|
|
99
|
+
post.tags.forEach(tag => {
|
|
104
100
|
algoliaPost.tags.push({name: tag.name, slug: tag.slug});
|
|
105
101
|
});
|
|
106
102
|
}
|
|
107
103
|
|
|
108
104
|
if (post.authors && post.authors.length) {
|
|
109
|
-
post.authors.forEach(
|
|
105
|
+
post.authors.forEach(author => {
|
|
110
106
|
algoliaPost.authors.push({name: author.name, slug: author.slug});
|
|
111
107
|
});
|
|
112
108
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/algolia-fragmenter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/TryGhost/algolia.git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"dev": "echo \"Implement me!\"",
|
|
27
27
|
"test": "NODE_ENV=testing vitest run --root .",
|
|
28
|
-
"lint": "
|
|
28
|
+
"lint": "oxlint --quiet . && oxfmt --check .",
|
|
29
29
|
"posttest": "pnpm lint"
|
|
30
30
|
}
|
|
31
31
|
}
|