You can pick up these shelf kits at your local home store pretty inexpensively.
Remove the wrapping and dry fit the shelf together. Use a pencil to mark each side of the shelf brackets. Then dissassemble the shelf.
The secret to making this a ledge is to install it up side down.
Use a screwdriver to removeand flip the hanging hardware on the back of the brackets.
Now, keep the shelf the same as it would be if it were hanging right side up and place the brackets on top of the shelf in the same spot they would have been on the bottom.
Now, because the weight will be sitting on that shelf you need to secure the shelf to the brackets from the underside.
Using the lines you drew as your guide. Drill pilot holes and attach the shelf with some screws.
All I did was paint this out and i've got myself a nice little book nook, I'm Mrs. Fixit and it's just that simple!