@nera-static/plugin-search 1.0.0 → 1.0.2

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
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.0.2] - 2025-07-25
9
+
10
+ ### Fix
11
+ - publish serach.js with publish-template command
12
+
13
+ ## [1.0.1] - 2025-07-25
14
+
15
+ ### Added
16
+ - missing script to publish templates
17
+
18
+ ### Fix
19
+ - publish templates command
20
+
21
+
8
22
  ## [1.0.0] - 2025-07-25
9
23
 
10
24
  ### Added
@@ -18,4 +32,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
32
  - Allows multiple search inputs per page via `[data-search-input]` selectors
19
33
  - Provides `publish-template` command to copy `search.pug` for customization
20
34
  - Comprehensive test suite to validate index generation and file handling
21
-
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+
3
+ import path from 'path'
4
+ import fs from 'fs/promises'
5
+ import { fileURLToPath } from 'url'
6
+ import { publishAllTemplates } from '@nera-static/plugin-utils'
7
+
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
+ const pluginName = 'plugin-search'
10
+ const sourceDir = path.resolve(__dirname, '../views/')
11
+
12
+ // Publish all pug templates to views/vendor/plugin-search/
13
+ const result = publishAllTemplates({
14
+ pluginName,
15
+ sourceDir,
16
+ expectedPackageName: 'dummy', // for test-only override
17
+ })
18
+
19
+ // Also publish search.js into assets/js/
20
+ const publishSearchJS = async () => {
21
+ try {
22
+ const jsSource = path.join(sourceDir, 'search.js')
23
+ const jsTarget = path.resolve(process.cwd(), 'assets/js/search.js')
24
+
25
+ await fs.mkdir(path.dirname(jsTarget), { recursive: true })
26
+ await fs.copyFile(jsSource, jsTarget)
27
+
28
+ console.log('✓ search.js copied to assets/js/search.js')
29
+ } catch (err) {
30
+ console.error('✗ Failed to copy search.js to assets/js/', err)
31
+ process.exit(1)
32
+ }
33
+ }
34
+
35
+ publishSearchJS().then(() => {
36
+ process.exit(result ? 0 : 1)
37
+ })
package/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import path from 'path'
2
2
  import fs from 'fs/promises'
3
3
  import { getConfig } from '@nera-static/plugin-utils'
4
- import { fileURLToPath } from 'url'
5
4
 
6
5
  const CONFIG_PATH = path.resolve(process.cwd(), 'config/search.yaml')
7
6
 
@@ -31,13 +30,8 @@ export async function getAppData({ app, pagesData }) {
31
30
  return item
32
31
  })
33
32
 
34
- fs.writeFile(outputPath, JSON.stringify(index, null, 2), 'utf-8')
35
-
36
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
37
- const sourceJS = path.join(__dirname, 'views', 'search.js')
38
- const targetJS = path.join(app.folders.assets, 'js', 'search.js')
39
- await fs.mkdir(path.dirname(targetJS), { recursive: true })
40
- await fs.copyFile(sourceJS, targetJS)
33
+ await fs.mkdir(path.dirname(outputPath), { recursive: true })
34
+ await fs.writeFile(outputPath, JSON.stringify(index, null, 2), 'utf-8')
41
35
 
42
36
  return {
43
37
  ...app,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nera-static/plugin-search",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A plugin for the Nera static site generator that builds a JSON search index and provides a client-side search script.",
5
5
  "main": "index.js",
6
6
  "scripts": {