@tryghost/algolia-fragmenter 0.2.6 → 0.2.8
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/LICENSE +1 -1
- package/README.md +23 -20
- package/package.json +16 -15
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
# Algolia Fragmenter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@tryghost/algolia-fragmenter` converts Ghost posts into Algolia records and breaks long HTML into heading-based fragments.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```sh
|
|
8
|
+
npm install @tryghost/algolia-fragmenter
|
|
9
|
+
```
|
|
8
10
|
|
|
9
11
|
or
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
```sh
|
|
14
|
+
pnpm add @tryghost/algolia-fragmenter
|
|
15
|
+
```
|
|
13
16
|
|
|
14
17
|
## Usage
|
|
15
18
|
|
|
19
|
+
Convert Ghost Content API posts, then reduce the resulting records into fragments:
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
This is a mono repository, managed with [lerna](https://lernajs.io/).
|
|
20
|
-
|
|
21
|
-
Follow the instructions for the top-level repo.
|
|
22
|
-
1. `git clone` this repo & `cd` into it as usual
|
|
23
|
-
2. Run `yarn` to install top-level dependencies.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## Run
|
|
21
|
+
```js
|
|
22
|
+
const transforms = require('@tryghost/algolia-fragmenter');
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
const records = transforms.transformToAlgoliaObject(posts);
|
|
25
|
+
const fragments = records.reduce(transforms.fragmentTransformer, []);
|
|
26
|
+
```
|
|
29
27
|
|
|
28
|
+
`transformToAlgoliaObject` accepts an optional array of post slugs to exclude as its second argument. `fragmentTransformer` is designed to be passed directly to `Array#reduce`.
|
|
30
29
|
|
|
31
|
-
##
|
|
30
|
+
## Development
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
- `yarn test` run lint and tests
|
|
32
|
+
Install dependencies from the repository root with `pnpm install`. From the root, run this package's tests and ESLint checks with:
|
|
35
33
|
|
|
34
|
+
```sh
|
|
35
|
+
pnpm --filter @tryghost/algolia-fragmenter test
|
|
36
|
+
```
|
|
36
37
|
|
|
38
|
+
Run the full monorepo suite with `pnpm test`.
|
|
37
39
|
|
|
40
|
+
---
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
## Copyright & License
|
|
40
43
|
|
|
41
|
-
Copyright (c) 2013-
|
|
44
|
+
Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE). Ghost and the Ghost Logo are trademarks of Ghost Foundation Ltd. Please see our [trademark policy](https://ghost.org/trademark/) for info on acceptable usage.
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/algolia-fragmenter",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"repository":
|
|
3
|
+
"version": "0.2.8",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/TryGhost/algolia.git",
|
|
7
|
+
"directory": "packages/algolia-fragmenter"
|
|
8
|
+
},
|
|
5
9
|
"author": "Ghost Foundation",
|
|
6
10
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"dev": "echo \"Implement me!\"",
|
|
10
|
-
"test": "NODE_ENV=testing mocha './test/**/*.test.js'",
|
|
11
|
-
"lint": "eslint . --ext .js --cache",
|
|
12
|
-
"posttest": "yarn lint"
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=24"
|
|
13
13
|
},
|
|
14
|
+
"main": "index.js",
|
|
14
15
|
"files": [
|
|
15
16
|
"index.js",
|
|
16
17
|
"lib"
|
|
@@ -18,13 +19,13 @@
|
|
|
18
19
|
"publishConfig": {
|
|
19
20
|
"access": "public"
|
|
20
21
|
},
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"mocha": "10.2.0",
|
|
23
|
-
"should": "13.2.3",
|
|
24
|
-
"sinon": "15.2.0"
|
|
25
|
-
},
|
|
26
22
|
"dependencies": {
|
|
27
23
|
"algolia-html-extractor": "0.0.1"
|
|
28
24
|
},
|
|
29
|
-
"
|
|
30
|
-
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "echo \"Implement me!\"",
|
|
27
|
+
"test": "NODE_ENV=testing vitest run --root .",
|
|
28
|
+
"lint": "eslint . --ext .js --cache",
|
|
29
|
+
"posttest": "pnpm lint"
|
|
30
|
+
}
|
|
31
|
+
}
|