@nera-static/plugin-search 1.0.1 → 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,11 @@ 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
+
8
13
  ## [1.0.1] - 2025-07-25
9
14
 
10
15
  ### Added
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import path from 'path'
4
+ import fs from 'fs/promises'
4
5
  import { fileURLToPath } from 'url'
5
6
  import { publishAllTemplates } from '@nera-static/plugin-utils'
6
7
 
@@ -8,10 +9,29 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
8
9
  const pluginName = 'plugin-search'
9
10
  const sourceDir = path.resolve(__dirname, '../views/')
10
11
 
12
+ // Publish all pug templates to views/vendor/plugin-search/
11
13
  const result = publishAllTemplates({
12
14
  pluginName,
13
15
  sourceDir,
14
16
  expectedPackageName: 'dummy', // for test-only override
15
17
  })
16
18
 
17
- process.exit(result ? 0 : 1)
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.1",
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": {