const moment = require("moment") module.exports = class { onCreate(input) { this.state = { selectedChapter: "", } } onMount() { this.state.selectedChapter = (window.location.hash||"#").slice(1) } chapterTitle(chapter) { let title = "Chapter " + (this.input.story.chapters.indexOf(chapter) + 1) if (chapter.title) { title = chapter.title } else if (chapter.fictionalDate && chapter.fictionalDate.getUTCFullYear() > 1) { title = moment.utc(chapter.fictionalDate).format("MMM D, YYYY") } return title } select(kind, id) { if (kind === "chapter") { this.state.selectedChapter = id } this.emit("select", kind, id) } }