Here is a template for Observable p5.js notebooks:
- p5.js sketch on Observable: Template (forkable template by me)
Also, Tom MacWright has created a helper function which you can import into a notebook to get started quickly, as well as a template with it already in-place:
- p5 (twcw tutorial)
- p5 basic example (forkable template)
These are instance mode sketches,and you need to prefix everything – get ready write sketch.foo
sketch.bar
sketch.baz
sketch.etc
…
One thing I discovered while writing the first template is that the sketches work well, but you cannot currently include libraries like p5.dom and p5.sound in Observable notebooks. I have an open question about that.
Edit:: Including p5.dom in Observable is quite possible – there is a trick to it, shared by twcw and now included in my template notebook (linked above).