nextjs-link-preview 1.0.3 → 1.0.4

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/bin/setup.js +8 -3
  2. package/package.json +1 -1
package/bin/setup.js CHANGED
@@ -76,13 +76,18 @@ function setupApiRoute() {
76
76
  process.exit(1);
77
77
  }
78
78
 
79
+ // Detect if project uses src/app or app directory structure
80
+ const hasSrcApp = fs.existsSync(path.join(cwd, "src", "app"));
81
+ const appDir = hasSrcApp ? path.join(cwd, "src", "app") : path.join(cwd, "app");
82
+ const relativePath = hasSrcApp ? "src/app/api/preview/route.ts" : "app/api/preview/route.ts";
83
+
79
84
  // Create the API route directory structure
80
- const apiRoutePath = path.join(cwd, "app", "api", "preview");
85
+ const apiRoutePath = path.join(appDir, "api", "preview");
81
86
  const routeFilePath = path.join(apiRoutePath, "route.ts");
82
87
 
83
88
  // Check if route already exists
84
89
  if (fs.existsSync(routeFilePath)) {
85
- console.log("⚠️ API route already exists at app/api/preview/route.ts");
90
+ console.log(`⚠️ API route already exists at ${relativePath}`);
86
91
  console.log("To reinstall, delete the existing file and run this command again.");
87
92
  process.exit(0);
88
93
  }
@@ -93,7 +98,7 @@ function setupApiRoute() {
93
98
  // Write the route file
94
99
  fs.writeFileSync(routeFilePath, API_ROUTE_CONTENT);
95
100
 
96
- console.log("✅ Successfully created API route at app/api/preview/route.ts");
101
+ console.log(`✅ Successfully created API route at ${relativePath}`);
97
102
  console.log("");
98
103
  console.log("📦 Make sure you have the required dependencies:");
99
104
  console.log(" npm install axios cheerio");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextjs-link-preview",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "description": "A Next.js component for generating beautiful link preview cards with server-side metadata fetching - No CORS issues!",
6
6
  "keywords": [