Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0073f1

Browse files
committed
fix(inherit): try resolve component from root directory
1 parent 873b768 commit b0073f1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/utils/collection.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ export function generateCollectionTableDefinition(collection: ResolvedCollection
251251
// Handle default values
252252
if ('default' in property) {
253253
let defaultValue = typeof property.default === 'string'
254-
? `'${property.default}'`
254+
? wrapWithSingleQuote(property.default)
255255
: property.default
256256

257257
if (!(defaultValue instanceof Date) && typeof defaultValue === 'object') {
258-
defaultValue = `'${JSON.stringify(defaultValue)}'`
258+
defaultValue = wrapWithSingleQuote(JSON.stringify(defaultValue))
259259
}
260260
constraints.push(`DEFAULT ${defaultValue}`)
261261
}
@@ -274,3 +274,13 @@ export function generateCollectionTableDefinition(collection: ResolvedCollection
274274

275275
return definition
276276
}
277+
278+
function wrapWithSingleQuote(value: string) {
279+
if (value.startsWith('`') && value.endsWith('`')) {
280+
value = value.slice(1, -1)
281+
}
282+
if (value.startsWith('\'') && value.endsWith('\'')) {
283+
return value
284+
}
285+
return `'${value}'`
286+
}

src/utils/schema/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export function replaceComponentSchemas<T = Draft07Definition | Draft07Definitio
120120
const nuxt = useNuxt()
121121
let path = String($content?.inherit)
122122
try {
123-
path = resolveModule(path)
123+
path = resolveModule(path, { paths: [nuxt.options.rootDir] })
124124
}
125125
catch {
126126
// Ignore error

0 commit comments

Comments
 (0)