@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.
Files changed (3) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +23 -20
  3. package/package.json +16 -15
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2013-2023 Ghost Foundation
3
+ Copyright (c) 2013-2025 Ghost Foundation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,41 +1,44 @@
1
1
  # Algolia Fragmenter
2
2
 
3
- Fragment transformer converts a Ghost post into an Algolia Object and breaks down large HTML strings into sensible fragments based on headings.
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
- `npm install @tryghost/algolia-fragmenter --save`
7
+ ```sh
8
+ npm install @tryghost/algolia-fragmenter
9
+ ```
8
10
 
9
11
  or
10
12
 
11
- `yarn add @tryghost/algolia-fragmenter`
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
- ## Develop
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
- - `yarn dev`
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
- ## Test
30
+ ## Development
32
31
 
33
- - `yarn lint` run just eslint
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
- # Copyright & License
42
+ ## Copyright & License
40
43
 
41
- Copyright (c) 2013-2023 Ghost Foundation - Released under the [MIT license](LICENSE).
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.6",
4
- "repository": "https://github.com/TryGhost/algolia/tree/master/packages/algolia-fragmenter",
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
- "main": "index.js",
8
- "scripts": {
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
- "gitHead": "0f0d8a416adb0f78fda0ec72f872146406d76eae"
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
+ }