File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 6
6
} from '../actions/get-emails-directory-metadata' ;
7
7
import { useHotreload } from '../hooks/use-hot-reload' ;
8
8
import {
9
+ emailsDirRelativePath ,
9
10
emailsDirectoryAbsolutePath ,
11
+ normalizePath ,
10
12
pathSeparator ,
11
13
} from '../utils/emails-directory-absolute-path' ;
12
14
import {
@@ -70,11 +72,16 @@ export const EmailsProvider = (props: {
70
72
} ) ;
71
73
72
74
for ( const change of changes ) {
75
+ const normalizedEmailsDirRelativePath = normalizePath (
76
+ emailsDirRelativePath ,
77
+ ) ;
73
78
const slugForChangedEmail =
74
79
// filename ex: emails/apple-receipt.tsx
75
80
// so we need to remove the "emails/" because it isn't used
76
81
// on the slug parameter for the preview page
77
- change . filename . split ( pathSeparator ) . slice ( 1 ) . join ( '/' ) ;
82
+ change . filename
83
+ . replace ( `${ normalizedEmailsDirRelativePath } ${ pathSeparator } ` , '' )
84
+ . replace ( normalizedEmailsDirRelativePath , '' ) ;
78
85
79
86
const lastResult = renderingResultPerEmailSlug [ slugForChangedEmail ] ;
80
87
Original file line number Diff line number Diff line change 1
1
/* eslint-disable @typescript-eslint/no-non-null-assertion */
2
- const emailsDirRelativePath =
2
+ export const emailsDirRelativePath =
3
3
process . env . NEXT_PUBLIC_EMAILS_DIR_RELATIVE_PATH ?? 'emails' ;
4
4
5
5
export const userProjectLocation =
@@ -11,7 +11,7 @@ export const pathSeparator = process.env.NEXT_PUBLIC_OS_PATH_SEPARATOR! as
11
11
| '/'
12
12
| '\\' ;
13
13
14
- const normalizePath = ( path : string ) => {
14
+ export const normalizePath = ( path : string ) => {
15
15
let newPath = path ;
16
16
17
17
while ( newPath . startsWith ( './' ) ) {
You can’t perform that action at this time.
0 commit comments