Another possible solution:
Create a passage called “StoryMenu” (this is a special passage used to add elements to the UI bar - see SugarCube v2 Documentation). Put the following code in that passage:
This assumes you have a passage named “ShowCodex” somewhere in the story (of course, you can name it something else), and after the player has visited that passage once, a button will be displayed in the sidebar for the rest of the playthrough, leading to the “Codex” passage.
In the “Codex” passage you can have code like this:
<<if $johnmet>>Description of John<</if>>
<<if $janemet>>Description of Jane<</if>>
<<set $johnmet to true>> in the passage where the player meets John, etc.)
previous() function makes sure you’ll always go back to the last visited passage when you close Codex. Just make sure to delete the passage named “previous()” Twine will create automatically.
(Edit: alternatively, if you always meet each NPC in one set passage, you can skip setting the
$johnmet, etc. variables and change the code in the “Codex” passage to the following:
<<if hasVisited("MeetJohn")>>Description of John<</if>>
<<if hasVisited("MeetJane")>>Description of Jane<</if>>
This of course assumes you meet John in the passage titled “MeetJohn” etc.)