In this episode, we're focusing on getting our notes to actually show up in the sidebar so we can see all the notes we've created. We start by looping through the notes data and displaying each note in a list on the side—finally moving beyond just seeing a single note! You'll notice that as you type and edit a note, the sidebar updates in real-time because we're referencing the same data everywhere.
We run into a few issues, like trying to load notes that already exist in local storage, and handle cases where there might not be a current note set yet. To fix this, we add a method to set the current note automatically to the first one when the app initializes. Now, when we refresh or load in old notes, things are set up nicely.
For the display, we make the UI a bit smarter: if a note doesn't have a title, we show "untitled note" instead of a blank space. For the body, we limit the preview to 100 characters, so things look neat even if you write a whole novel in the note body!
By the end, we've got multiple notes listed in the sidebar, each updating live as we edit. Clicking to switch between notes isn't there yet, but we're well on our way to a proper notes app experience!