@uniweb/core 0.7.29 → 0.7.30

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/website.js +27 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.7.29",
3
+ "version": "0.7.30",
4
4
  "description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
5
5
  "type": "module",
6
6
  "exports": {
@@ -31,7 +31,7 @@
31
31
  "vitest": "^4.1.7"
32
32
  },
33
33
  "dependencies": {
34
- "@uniweb/semantic-parser": "1.1.18",
34
+ "@uniweb/semantic-parser": "1.1.19",
35
35
  "@uniweb/theming": "0.1.14"
36
36
  },
37
37
  "scripts": {
package/src/website.js CHANGED
@@ -1011,6 +1011,21 @@ export default class Website {
1011
1011
 
1012
1012
  return {
1013
1013
  enabled: this.isSearchEnabled(),
1014
+ // Which provider serves results. `index` (the default) downloads a
1015
+ // prebuilt index and queries it in the browser — free, and works on any
1016
+ // host. `endpoint` queries a server-side search API, which is what makes
1017
+ // dynamic/API-backed content searchable. Any other value names a
1018
+ // foundation-supplied search transport.
1019
+ //
1020
+ // Kit resolves and loads the provider; core only passes the declaration
1021
+ // through, so a site that never searches pays nothing for the vocabulary
1022
+ // (see kit's search module for the resolution rules).
1023
+ provider: config.provider || 'index',
1024
+ // Base-RELATIVE path for the `endpoint` provider. Left raw here: kit
1025
+ // resolves it against `basePath`, so one spelling works whether the site
1026
+ // is served from the root, from a subdirectory, or from a backend
1027
+ // subpath. Undefined unless declared.
1028
+ endpoint: config.endpoint,
1014
1029
  indexUrl: this.getSearchIndexUrl(),
1015
1030
  locale: this.getActiveLocale(),
1016
1031
  include: {
@@ -1029,7 +1044,14 @@ export default class Website {
1029
1044
  }
1030
1045
 
1031
1046
  /**
1032
- * Get the URL for the search index file
1047
+ * Get the URL for the search index file.
1048
+ *
1049
+ * Includes `basePath`, so the URL is correct on a site deployed under a
1050
+ * subdirectory (`base: /docs/`) and on a backend-hosted site served from a
1051
+ * subpath. Omitting it was a real bug: the returned path was fetched
1052
+ * verbatim, so search 404'd on every non-root deployment while data fetching
1053
+ * — which resolves the same base — worked.
1054
+ *
1033
1055
  * @returns {string} URL to fetch the search index
1034
1056
  */
1035
1057
  getSearchIndexUrl() {
@@ -1037,7 +1059,10 @@ export default class Website {
1037
1059
  const isDefault = locale === this.getDefaultLocale()
1038
1060
 
1039
1061
  // Default locale uses root path, others use locale prefix
1040
- return isDefault ? '/search-index.json' : `/${locale}/search-index.json`
1062
+ const path = isDefault ? '/search-index.json' : `/${locale}/search-index.json`
1063
+
1064
+ // `basePath` is already normalized without a trailing slash ('' at root).
1065
+ return `${this.basePath || ''}${path}`
1041
1066
  }
1042
1067
 
1043
1068
  /**