fuwari icon indicating copy to clipboard operation
fuwari copied to clipboard

If a category contains #, problems occur during the build process

Open PIXELHIZE opened this issue 1 year ago • 0 comments

While I was making a post using these sources, I accidentally found out that if a category contains #, an error occurs during the birch. I've been looking for a way to fix this error. My conclusion is that in the path node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]\node_modules\astro\dist\core\fs\index.js, in the

function removeEmptyDirs(root) {
  const dir = fileURLToPath(root);
  if (!fs.statSync(dir).isDirectory()) return;
  let files = fs.readdirSync(dir);
  if (files.length > 0) {
    files.map((file) => {
      const url = new URL(`./${file}`, appendForwardSlash(root.toString()));
      removeEmptyDirs(url);
    });
    files = fs.readdirSync(dir);
  }
  if (files.length === 0) {
    fs.rmdirSync(dir);
  }
}

is modified as follows.

function removeEmptyDirs(root) {
  const dir = fileURLToPath(root);
  if (!fs.statSync(dir).isDirectory()) return;
  let files = fs.readdirSync(dir);
  if (files.length > 0) {
    files.map((file) => {
      // fix
      const encodedFile = encodeURIComponent(file);
      const url = new URL(`./${encodedFile}`, appendForwardSlash(root.toString()));
      removeEmptyDirs(url);
    });
    files = fs.readdirSync(dir);
  }
  if (files.length === 0) {
    fs.rmdirSync(dir);
  }
}

Yes, that's right. As you can see from the path, to fix that error, you need to upload node_modules along with the site build. This is a waste of resources and a lot of work. I need your help.

PIXELHIZE avatar Oct 03 '24 14:10 PIXELHIZE