попытка настроить время материала
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Struchkov Mark 2024-09-07 10:25:07 +03:00
parent 78e27044f4
commit 6d1edebaaa
No known key found for this signature in database
GPG Key ID: A3F0AC3F0FA52F3C

View File

@ -41,7 +41,8 @@ export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (u
let published: MaybeDate = undefined let published: MaybeDate = undefined
const fp = file.data.filePath! const fp = file.data.filePath!
const fullFp = path.isAbsolute(fp) ? fp : path.posix.join(file.cwd, fp) const repoRoot = path.resolve(file.cwd, "content"); // Указываем путь к корневой папке репозитория
const fullFp = path.isAbsolute(fp) ? fp : path.join(repoRoot, fp); // Создаем абсолютный путь
for (const source of opts.priority) { for (const source of opts.priority) {
if (source === "filesystem") { if (source === "filesystem") {
const st = await fs.promises.stat(fullFp) const st = await fs.promises.stat(fullFp)
@ -58,12 +59,13 @@ export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (u
// Get a reference to the main git repo. // Get a reference to the main git repo.
// It's either the same as the workdir, // It's either the same as the workdir,
// or 1+ level higher in case of a submodule/subtree setup // or 1+ level higher in case of a submodule/subtree setup
repo = Repository.discover("/usr/src/app/content") repo = Repository.discover(repoRoot)
console.log(chalk.green(`Git repository found at: ${repo.path()}`)); console.log(chalk.green(`Git repository found at: ${repo.path()}`));
} }
try { try {
modified ||= await repo.getFileLatestModifiedDateAsync(file.data.filePath!) const relativePathToRepo = path.relative(repoRoot, fullFp);
modified ||= await repo.getFileLatestModifiedDateAsync(relativePathToRepo)
} catch { } catch {
console.log( console.log(
chalk.yellow( chalk.yellow(