Skip to content

Commit

Permalink
chore: last try
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers committed Nov 4, 2023
1 parent 9787c10 commit 4562df7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 5 additions & 8 deletions apps/website/src/data/blocks/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,9 @@ function getComponentCode(componentFolder: string, componentName: string) {
}

const getRootFolder = () => {
return (
process.env.TEMPLATE_ROOT ??
path.join(
process.env.PROJECT_CWD ?? __dirname + '/../../../../',
'/packages/pro/saas-ui/templates/src'
)
return path.join(
process.env.PROJECT_CWD ?? __dirname + '/../../../../',
'/packages/pro/saas-ui/templates/src'
)
}

Expand Down Expand Up @@ -111,9 +108,9 @@ export function getAllComponents(): ComponentInfo[] {

export function getComponent(
categoryName: string,
componentName: string
componentName: string,
rootFolder = getRootFolder()
): ComponentInfo | null {
const rootFolder = getRootFolder()
const componentDirectory = path.join(rootFolder, categoryName, componentName)
const componentAttributes = path.join(componentDirectory, 'attributes.json')

Expand Down
6 changes: 5 additions & 1 deletion apps/website/src/pages/api/blocks/[category]/[component].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export default async function handler(
return res.status(404).json({ error: 'Missing component name' })
}

const attributes = getComponent(categoryName, componentName)
const attributes = getComponent(
categoryName,
componentName,
process.env.TEMPLATE_ROOT
)

if ((!attributes?.attributes.public && !data.session) || error) {
return res.status(401).json({ error: 'Unauthorized' })
Expand Down

0 comments on commit 4562df7

Please sign in to comment.