Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): splitting target path while coping content files #749

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions scripts/catalog-to-astro-content-directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ import os from 'node:os';
const __filename = fileURLToPath(import.meta.url);
const scriptsDir = path.dirname(__filename);

const cleanRelativePath = (relativePath, type) => {
const position = relativePath.indexOf(`${type}${path.sep}`);

return relativePath.slice(position + `${type}${path.sep}`.length);
};

const getTargetPath = (source, target, type, file) => {
const relativePath = path.relative(source, file);
const cleanedRelativePath = relativePath.split(type);
const targetForEvents = path.join(type, cleanedRelativePath[1]);
const cleanedRelativePath = cleanRelativePath(relativePath, type);
const targetForEvents = path.join(type, cleanedRelativePath);

return path.join(target, targetForEvents);
};

Expand Down Expand Up @@ -64,9 +71,9 @@ const copyFiles = async ({ source, target, catalogFilesDir, pathToMarkdownFiles,
}

const relativePath = path.relative(source, file);
const cleanedRelativePath = relativePath.split(type);
if (!cleanedRelativePath[1]) continue;
const targetForEvents = path.join(type, cleanedRelativePath[1]);
const cleanedRelativePath = cleanRelativePath(relativePath, type);
if (!cleanedRelativePath) continue;
const targetForEvents = path.join(type, cleanedRelativePath);

// Catalog-files-directory
const targetPath = path.join(catalogFilesDir, targetForEvents);
Expand Down