@teleporthq/teleport-plugin-next-data-source 0.43.60 → 0.43.62

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/src/utils.ts CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  } from '@teleporthq/teleport-types'
11
11
  import * as types from '@babel/types'
12
12
  import { ASTUtils } from '@teleporthq/teleport-plugin-common'
13
- import { StringUtils } from '@teleporthq/teleport-shared'
13
+ import { GenericUtils, StringUtils } from '@teleporthq/teleport-shared'
14
14
  import { generateDataSourceFetcherWithCore } from './data-source-fetchers'
15
15
  import type { EcommerceProductTransformOptions } from './transformations'
16
16
  import { DATA_SOURCE_ISR_REVALIDATE_SECONDS } from './isr'
@@ -1253,13 +1253,11 @@ export const extractDataSourceIntoGetStaticProps = (
1253
1253
 
1254
1254
  // Add dependency for the fetcher
1255
1255
  const fetcherImportName = StringUtils.dashCaseToCamelCase(fileName)
1256
- // Calculate the correct relative path based on page folder depth.
1257
- // folderPath contains subfolders within pages/ (e.g. ['admin'] for pages/admin/X.js).
1258
- // We add 1 for the pages/ directory itself.
1259
- // Pages at pages/X.js (folderPath=[]) need '../' (1 level up)
1260
- // Pages at pages/admin/X.js (folderPath=['admin']) need '../../' (2 levels up)
1261
- const depth = (folderPath ? folderPath.length : 0) + 1
1262
- const relativePrefix = '../'.repeat(depth)
1256
+ // Relative path from the page back to the project root. `folderPath` holds
1257
+ // the subfolders WITHIN pages/ (e.g. ['admin'] for pages/admin/X.js), so
1258
+ // the pages/ folder itself has to be counted too — which is exactly what
1259
+ // the shared helper does (see `generatePageDependenciesPrefix`).
1260
+ const relativePrefix = GenericUtils.generatePageToRootPrefix({ folderPath })
1263
1261
  dependencies[fetcherImportName] = {
1264
1262
  type: 'local',
1265
1263
  path: `${relativePrefix}utils/data-sources/${fileName}`,