opentwig 1.0.2 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opentwig",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "opentwig 🌿 is an open source link in bio page generator.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -37,7 +37,7 @@
37
37
  "homepage": "https://github.com/tufantunc/opentwig#readme",
38
38
  "dependencies": {
39
39
  "autoprefixer": "^10.4.21",
40
- "html-minifier": "^4.0.0",
40
+ "html-minifier-terser": "^7.2.0",
41
41
  "postcss": "^8.5.6",
42
42
  "postcss-minify": "^1.2.0",
43
43
  "qrcode": "^1.5.4",
@@ -20,7 +20,7 @@ const buildPage = async (config) => {
20
20
  const theme = loadTheme(config);
21
21
 
22
22
  // Generate HTML
23
- const html = generateHTML(config, theme);
23
+ const html = await generateHTML(config, theme);
24
24
 
25
25
  // Process CSS (async)
26
26
  const css = await processCSS(config);
@@ -1,14 +1,13 @@
1
- const htmlMinifier = require('html-minifier');
1
+ const htmlMinifier = require('html-minifier-terser');
2
2
 
3
- module.exports = function(config, theme) {
3
+ module.exports = async function(config, theme) {
4
4
  let html = theme(config);
5
5
 
6
6
  if (config.minify) {
7
- const minifiedHtml = htmlMinifier.minify(html, {
7
+ const minifiedHtml = await htmlMinifier.minify(html, {
8
8
  removeComments: true,
9
9
  collapseWhitespace: true,
10
10
  minifyCSS: true,
11
- minifyJS: true
12
11
  });
13
12
  html = minifiedHtml;
14
13
  }
@@ -6,11 +6,18 @@ const postcss = require('postcss');
6
6
  const minify = require('postcss-minify');
7
7
 
8
8
  module.exports = async function(config) {
9
- // Check if the theme has a style.css file
10
- const cssPath = path.join(cwd, 'theme', config.theme, 'style.css');
11
-
12
- const hasCss = fs.existsSync(cssPath);
13
- if (!hasCss) {
9
+ // Try package directory first (for NPX), then current directory (for local dev)
10
+ const packageDir = path.dirname(require.main.filename);
11
+ const currentDir = process.cwd();
12
+
13
+ const cssPaths = [
14
+ path.join(packageDir, '..', 'theme', config.theme, 'style.css'), // NPX package
15
+ path.join(currentDir, 'theme', config.theme, 'style.css') // Local development
16
+ ];
17
+
18
+ const cssPath = cssPaths.find(p => fs.existsSync(p));
19
+
20
+ if (!cssPath) {
14
21
  return null;
15
22
  }
16
23
 
@@ -9,8 +9,8 @@ module.exports = function(filePath) {
9
9
 
10
10
  const absolutePath = path.join(cwd, filePath);
11
11
  if (!fs.existsSync(absolutePath)) {
12
- console.error(`File not found: ${absolutePath}`);
13
- process.exit(1);
12
+ console.warn(`Avatar file not found: ${absolutePath}. Continuing without avatar.`);
13
+ return '';
14
14
  }
15
15
 
16
16
  const extension = path.extname(absolutePath).toLowerCase();
@@ -17,7 +17,7 @@ module.exports = function(html, css, avatar,ogImage, qrImage) {
17
17
  fs.writeFileSync(path.join(distDir, 'style.css'), css);
18
18
  }
19
19
 
20
- if (avatar && avatar.path) {
20
+ if (avatar && avatar.path && fs.existsSync(path.join(cwd, avatar.path))) {
21
21
  // Get the original file extension from the avatar path
22
22
  const originalExtension = path.extname(avatar.path);
23
23
  const avatarFileName = `avatar${originalExtension}`;