diff --git a/lib/remark/last-modified.ts b/lib/remark/last-modified.ts index 6865219..73b4d72 100644 --- a/lib/remark/last-modified.ts +++ b/lib/remark/last-modified.ts @@ -5,17 +5,28 @@ import { resolve } from 'path' function remarkModifiedTime() { return function (tree, file) { + console.log('tree:', tree) + console.log('file:', file) const filepath = file.history[0] + console.log('filepath:', filepath) + + if (!filepath) { + console.error('Error: filepath is undefined') + return + } try { // Resolve the absolute path of the file const absoluteFilePath = resolve(filepath) + console.log('absoluteFilePath:', absoluteFilePath) // Get the root directory of the repository const repoRoot = execSync('git rev-parse --show-toplevel').toString().trim() + console.log('repoRoot:', repoRoot) // Get the relative path of the file from the repository root const relativeFilePath = absoluteFilePath.replace(`${repoRoot}/`, '') + console.log('relativeFilePath:', relativeFilePath) // Check if the file is within a submodule const submodulePath = execSync(`git submodule foreach --quiet 'echo $path'`) @@ -23,6 +34,7 @@ function remarkModifiedTime() { .trim() .split('\n') .find(submodule => relativeFilePath.startsWith(submodule)) + console.log('submodulePath:', submodulePath) let result if (submodulePath) { @@ -40,6 +52,7 @@ function remarkModifiedTime() { } file.data.astro.frontmatter.lastModified = result + console.log('lastModified:', result) } catch (error) { console.error('Error getting last modified time:', error) }