Skip to content

Commit

Permalink
fix: change reconnectLink behavior for page move (#1991)
Browse files Browse the repository at this point in the history
  • Loading branch information
sesajad committed Jun 29, 2020
1 parent 370cd10 commit 3c5352f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/models/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,21 @@ 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,
locale: opts.destinationLocale,
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'
})
}

/**
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit 3c5352f

Please sign in to comment.