fix: change reconnectLink behavior for page move (#1991)

This commit is contained in:
Seyed Sajad Kahani 2020-06-29 01:08:17 +00:00 committed by GitHub
parent 370cd10096
commit 3c5352fb53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -559,7 +559,7 @@ module.exports = class Page extends Model {
})
}
// -> Reconnect Links
// -> Reconnect Links : Changing old links to the new path
await WIKI.models.pages.reconnectLinks({
sourceLocale: page.localeCode,
sourcePath: page.path,
@ -567,6 +567,13 @@ module.exports = class Page extends Model {
path: opts.destinationPath,
mode: 'move'
})
// -> Reconnect Links : Validate invalid links to the new path
await WIKI.models.pages.reconnectLinks({
locale: opts.destinationLocale,
path: opts.destinationPath,
mode: 'create'
})
}
/**
@ -655,7 +662,7 @@ module.exports = class Page extends Model {
break
case 'move':
const prevPageHref = `/${opts.sourceLocale}/${opts.sourcePath}`
replaceArgs.from = `<a href="${prevPageHref}" class="is-internal-link is-invalid-page">`
replaceArgs.from = `<a href="${prevPageHref}" class="is-internal-link is-valid-page">`
replaceArgs.to = `<a href="${pageHref}" class="is-internal-link is-valid-page">`
break
case 'delete':