mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
24 lines
475 B
JavaScript
24 lines
475 B
JavaScript
/**
|
|
Edit title of a part in the summary
|
|
|
|
@param {Summary} summary
|
|
@param {Number} index
|
|
@param {String} newTitle
|
|
@return {Summary}
|
|
*/
|
|
function editPartTitle(summary, index, newTitle) {
|
|
var parts = summary.getParts();
|
|
|
|
var part = parts.get(index);
|
|
if (!part) {
|
|
return summary;
|
|
}
|
|
|
|
part = part.set('title', newTitle);
|
|
parts = parts.set(index, part);
|
|
|
|
return summary.set('parts', parts);
|
|
}
|
|
|
|
module.exports = editPartTitle;
|