Mastodon Feed: Post

Mastodon Feed

aral@mastodon.ar.al ("Aral Balkan") wrote:

OK, so here’s likely the simplest possible example demonstrating:

• The same route, implemented as both a Kitten JavaScript Page (.page.js) and as a Kitten Markdown Page (.page.md)

• How to persist to the default Kitten JSDB¹ database.

(That first line with the nullish coalescing operator creates a “table” on the database with a default value for the count if it doesn’t already exist.)

https://kitten.small-web.org

¹ https://kitten.small-web.org/tutorials/persistence/

#Kitten #SmallWeb #web #dev #JavaScript #HTML #Markdown #example #comingSoon

Three windows: top-left, source of page.js version of Kitten count example, bottom-left, source of page.md version, and on the right, the output in a browser. Top-left: kitten.db.kittens ??= { count: 0 } export default () => kitten.html  <h1>Kitten count</h1>   <p>${'🐱️'.repeat(++kitten.db.kittens.count)}</p> Bottom-left: --- script: |   kitten.db.kittens ??= { count: 0 } ---   # Kitten count      ${'🐱️'.repeat(++kitten.db.kittens.count)} Right: Kitten count (heading) and 15 🐱️ emojis.