Skip to content

Commit 38427b7

Browse files
authored
Add contentType frontmatter functionality to move-content script (#57050)
1 parent b6302d1 commit 38427b7

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/content-render/scripts/move-content.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,27 @@ function editFiles(files, updateParent, opts) {
505505
}
506506
}
507507

508+
// Add contentType frontmatter to moved files
509+
if (files.length > 0) {
510+
const filePaths = files.map(([oldPath, newPath, oldHref, newHref]) => newPath)
511+
try {
512+
const cmd = ['run', 'add-content-type', '--', '--paths', ...filePaths]
513+
const result = execFileSync('npm', cmd, { cwd: process.cwd(), encoding: 'utf8' })
514+
if (result.trim()) {
515+
console.log(result.trim())
516+
}
517+
} catch (error) {
518+
console.warn(`Warning: Failed to add contentType frontmatter: ${error.message}`)
519+
}
520+
}
521+
508522
if (useGit) {
509-
const cmd = ['commit', '-a', '-m', `set ${REDIRECT_FROM_KEY} on ${files.length} files`]
523+
const cmd = [
524+
'commit',
525+
'-a',
526+
'-m',
527+
`set ${REDIRECT_FROM_KEY} and contentType on ${files.length} files`,
528+
]
510529
execFileSync('git', cmd)
511530
if (verbose) {
512531
console.log(`git commit command: ${chalk.grey(cmd.join(' '))}`)

0 commit comments

Comments
 (0)