DocsBuilt-in functions
Page parts
Build a page from parts instead of HTML. Blocks close like $if: $row ... $endrow. Settings go after the values, like gap=12 or look=primary.
$pagewebNaja page
$page ... $endpage
In a webNaja page: the whole page: its title, then the parts in it. Settings: lang=, description=.
$page[Najova;description=A language for bots, games and sites]
$heading[Write less, build more]
$paragraph[Every page gets a light and a dark look.]
$endpageGET / → 200 <main class="nj-page"> <h1 class="nj-heading">Write less, build more</h1> <p class="nj-paragraph">Every page gets a light and a dark look.</p> </main>
$headingwebNaja page
$heading[text] or $heading[text;level]
In a webNaja page: a heading (the first is level 1, later ones 2).
$page[Levels]
$heading[Levels]
$heading[World 1]
$heading[Secrets;3]
$endpageGET / → 200 <main class="nj-page"> <h1 class="nj-heading">Levels</h1> <h2 class="nj-heading" id="world-1">World 1</h2> <h3 class="nj-heading" id="secrets">Secrets</h3> </main>
$paragraphwebNaja page
$paragraph[text]
In a webNaja page: a paragraph of text.
$page[About]
$paragraph[Text is shown as written: <tags> & all.]
$endpageGET / → 200 <main class="nj-page"> <p class="nj-paragraph">Text is shown as written: <tags> & all.</p> </main>
$sectionwebNaja page
$section ... $endsection
In a webNaja page: a part of the page, with an optional title.
$page[Shop]
$section[Swords]
$paragraph[Sharp ones.]
$endsection
$endpageGET / → 200 <main class="nj-page"> <section class="nj-section"> <h2>Swords</h2> <p class="nj-paragraph">Sharp ones.</p> </section> </main>
$rowwebNaja page
$row ... $endrow
In a webNaja page: parts side by side (they wrap on narrow screens). Settings: gap=, align=, justify=.
$page[Links]
$row[gap=12]
$link[Install;/install;look=primary]
$link[Docs;/docs]
$endrow
$endpageGET / → 200 <main class="nj-page"> <div class="nj-row" style="gap:12px"> <a href="/install" class="nj-button primary">Install</a> <a href="/docs" class="nj-link">Docs</a> </div> </main>
$columnwebNaja page
$column ... $endcolumn
In a webNaja page: parts one under another. Settings: gap=, align=.
$page[Steps]
$column[gap=8]
$paragraph[1. Install]
$paragraph[2. Write]
$endcolumn
$endpageGET / → 200 <main class="nj-page"> <div class="nj-column" style="gap:8px"> <p class="nj-paragraph">1. Install</p> <p class="nj-paragraph">2. Write</p> </div> </main>
$gridwebNaja page
$grid ... $endgrid
In a webNaja page: parts in columns that become one column on phones. Settings: cols=, gap=.
$page[Features]
$grid[cols=3]
$section[Fast]
$endsection
$section[Simple]
$endsection
$section[Yours]
$endsection
$endgrid
$endpageGET / → 200 <main class="nj-page"> <div class="nj-grid" style="--cols:3"> <section class="nj-section"> <h2>Fast</h2> </section> <section class="nj-section"> <h2>Simple</h2> </section> <section class="nj-section"> <h2>Yours</h2> </section> </div> </main>
$itemswebNaja page
$items ... $enditems
In a webNaja page: a list: each part inside is one item.
$page[Todo]
$items
$paragraph[Feed the cat]
$link[Read the guide;/guide]
$enditems
$endpageGET / → 200 <main class="nj-page"> <ul class="nj-items"> <li><p class="nj-paragraph">Feed the cat</p></li> <li><a href="/guide" class="nj-link">Read the guide</a></li> </ul> </main>
$linkwebNaja page
$link[text;where]
In a webNaja page: a link; look=primary makes it a button. new=yes opens a new tab.
$page[Links]
$link[Docs;https://docs.najova.com;new=yes]
$endpageGET / → 200 <main class="nj-page"> <a href="https://docs.najova.com" class="nj-link" target="_blank" rel="noopener">Docs</a> </main>
$imagewebNaja page
$image[file;what it shows]
In a webNaja page: a picture, with words for people who cannot see it.
$page[Gallery]
$image[/cat.png;A cat asleep on a keyboard]
$endpageGET / → 200 <main class="nj-page"> <img src="/cat.png" alt="A cat asleep on a keyboard" loading="lazy" class="nj-image"> </main>
$buttonwebNaja page
$button[text] or $button[text;where]
In a webNaja page: a button; with a name= its click reaches $on[name.Clicked]; look=primary|quiet.
$page[Hello]
$button[Say hi;name=hi]
$paragraph[ ;name=answer]
$endpage
$on[hi.Clicked]
$setProperty[$get[answer];text;Hi there!]
$endonGET / → 200
<main class="nj-page">
<button type="button" class="nj-button" data-nj="hi">Say hi</button>
<p class="nj-paragraph" data-nj="answer"></p>
</main>
POST / → 200
{"changes":[{"part":"answer","what":"text","value":"Hi there!"}]}$inputwebNaja page
$input[name;label]
In a webNaja page: a field to type in. Settings: type=text|email|password|number|textarea|checkbox, placeholder=, value=, required=yes.
$page[Sign up]
$form[method=post]
$input[email;Your email;type=email;required=yes]
$button[Join]
$endform
$endpageGET / → 200 <main class="nj-page"> <form method="post" class="nj-form"> <label class="nj-field"><span>Your email</span><input type="email" name="email" required class="nj-input" data-nj="email" value=""></label> <button type="submit" class="nj-button">Join</button> </form> </main>
$formwebNaja page
$form ... $endform
In a webNaja page: fields and a button that send to the page (or the path given). Settings: method=post|get, name= for $on[name.Submitted].
$if[$request[method] == "POST"]
$redirect[/thanks]
$endif
$page[Contact]
$form[method=post]
$input[message;Message;type=textarea]
$button[Send]
$endform
$endpageGET / → 200 <main class="nj-page"> <form method="post" class="nj-form"> <label class="nj-field"><span>Message</span><textarea name="message" class="nj-input" data-nj="message"></textarea></label> <button type="submit" class="nj-button">Send</button> </form> </main>
$themewebNaja page
$theme ... $endtheme
In a webNaja page: the theme's named values, one per line: accent = #a690ff, and page = #0f1017 ; dark for the dark look only.
$theme
accent = #6a4cf0
accent = #a690ff ; dark
font = Onest
$endtheme
$page[Themed]
$link[Go;/go;look=primary]
$endpageGET / → 200
:root{color-scheme:light dark;--page:#ffffff;--text:#1d1d26;--muted:#5b5b6b;--surface:#f4f3fa;--border:#e3e1ee;--accent:#6a4cf0;--on-accent:#ffffff;--font:Onest, system-ui, sans-serif;--mono:ui-monospace, monospace;--radius:10px;--space:16px;--code-bg:#f7f6fc;--code-call:#5b3fd9;--code-text:#0b7a62;--code-num:#b4541a}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){--page:#0f1017;--text:#ecebf5;--muted:#a3a2b5;--surface:#181926;--border:#2a2b3d;--accent:#a690ff;--on-accent:#0f1017;--code-bg:#14151f;--code-call:#a690ff;--code-text:#46e3c2;--code-num:#f0a46b;--font:Onest, system-ui, sans-serif}}
:root[data-theme="dark"]{color-scheme:dark;--page:#0f1017;--text:#ecebf5;--muted:#a3a2b5;--surface:#181926;--border:#2a2b3d;--accent:#a690ff;--on-accent:#0f1017;--code-bg:#14151f;--code-call:#a690ff;--code-text:#46e3c2;--code-num:#f0a46b;--font:Onest, system-ui, sans-serif}
<main class="nj-page">
<a href="/go" class="nj-button primary">Go</a>
</main>$stylewebNaja page
$style[name] ... $endstyle
In a webNaja page: a named style parts take with style=name. Lines are name = value (padding, corner, text, background ... or CSS names like margin), and can end with when they count: ; hover, ; phone, ; below 960, ; dark, ; for link.
$style[card]
padding = 24
corner = 12
background = theme.surface
border = theme.border
border-color = theme.accent ; hover
text = theme.accent ; for link
padding = 16 ; phone
box-shadow = 0 0 0 1px theme.border ; dark
$endstyle
$page[Cards]
$section[Hello;style=card]
$link[Read more;/more]
$endsection
$endpageGET / → 200
.s-card{padding:24px;border-radius:12px;background:var(--surface);border:1px solid var(--border)}
.s-card a{color:var(--accent)}
.s-card:hover{border-color:var(--accent)}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .s-card{box-shadow:0 0 0 1px var(--border)}}
:root[data-theme="dark"] .s-card{box-shadow:0 0 0 1px var(--border)}
@media (max-width:640px){.s-card{padding:16px}}
<main class="nj-page">
<section class="nj-section s-card">
<h2>Hello</h2>
<a href="/more" class="nj-link">Read more</a>
</section>
</main>$motionwebNaja page
$motion[name] ... $endmotion
In a webNaja page: an animation styles use with animation = name 0.3s ease. Lines say when: opacity = 0 ; from, opacity = 1 ; to (or ; 50%).
$motion[fade-in]
opacity = 0 ; from
transform = translateY(8px) ; from
opacity = 1 ; to
transform = none ; to
$endmotion
$style[hero]
animation = fade-in 0.4s ease
animation = none ; still
$endstyle
$page[Welcome]
$heading[Hello;style=hero]
$endpageGET / → 200
@keyframes fade-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.s-hero{animation:fade-in 0.4s ease}
@media (prefers-reduced-motion:reduce){.s-hero{animation:none}}
<main class="nj-page">
<h1 class="nj-heading s-hero">Hello</h1>
</main>$fontwebNaja page
$font[name;file]
In a webNaja page: a font file the page uses, like $font[Onest;fonts/onest.woff2;weight=100 900]. Then font = Onest in $theme.
$font[Onest;fonts/onest.woff2;weight=100 900]
$theme
font = Onest
$endtheme
$page[Fonts]
$paragraph[Set in Onest.]
$endpageGET / → 200
@font-face{font-family:"Onest";src:url("fonts/onest.woff2") format("woff2");font-weight:100 900;font-style:normal;font-display:swap}
:root{color-scheme:light dark;--page:#ffffff;--text:#1d1d26;--muted:#5b5b6b;--surface:#f4f3fa;--border:#e3e1ee;--accent:#6a4cf0;--on-accent:#ffffff;--font:Onest, system-ui, sans-serif;--mono:ui-monospace, monospace;--radius:10px;--space:16px;--code-bg:#f7f6fc;--code-call:#5b3fd9;--code-text:#0b7a62;--code-num:#b4541a}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){--page:#0f1017;--text:#ecebf5;--muted:#a3a2b5;--surface:#181926;--border:#2a2b3d;--accent:#a690ff;--on-accent:#0f1017;--code-bg:#14151f;--code-call:#a690ff;--code-text:#46e3c2;--code-num:#f0a46b;--font:Onest, system-ui, sans-serif}}
:root[data-theme="dark"]{color-scheme:dark;--page:#0f1017;--text:#ecebf5;--muted:#a3a2b5;--surface:#181926;--border:#2a2b3d;--accent:#a690ff;--on-accent:#0f1017;--code-bg:#14151f;--code-call:#a690ff;--code-text:#46e3c2;--code-num:#f0a46b;--font:Onest, system-ui, sans-serif}
<main class="nj-page">
<p class="nj-paragraph">Set in Onest.</p>
</main>$sidebarwebNaja page
$sidebar[label] ... $endsidebar
In a webNaja page: a side column beside the rest of the page (straight inside $page). On a phone it folds into a Menu button.
$page[Docs]
$sidebar[Menu]
$nav
$link[Start;/]
$link[Loops;/loops]
$endnav
$endsidebar
$heading[Start here]
$endpageGET / → 200 <main class="nj-page"> <aside class="nj-side" aria-label="Menu"><button type="button" class="nj-menu nj-button" aria-expanded="false" aria-controls="nj-side1">Menu</button><div class="nj-side-body" id="nj-side1"> <nav class="nj-nav"><ul> <li><a href="/" class="nj-link" aria-current="page">Start</a></li> <li><a href="/loops" class="nj-link">Loops</a></li> </ul></nav> </div></aside> <h1 class="nj-heading">Start here</h1> </main>
$tabswebNaja page
$tabs ... $endtabs
In a webNaja page: tabs. Each $tab[title] ... $endtab inside is one; the first shows, arrow keys move between them.
$page[Install]
$tabs
$tab[Windows]
$paragraph[Run the installer.]
$endtab
$tab[Linux]
$paragraph[Unpack the archive.]
$endtab
$endtabs
$endpageGET / → 200 <main class="nj-page"> <div class="nj-tabs"> <div role="tablist"><button type="button" role="tab" id="nj-tabs1-0-b" aria-controls="nj-tabs1-0" aria-selected="true">Windows</button><button type="button" role="tab" id="nj-tabs1-1-b" aria-controls="nj-tabs1-1" aria-selected="false">Linux</button></div> <div class="nj-tab" role="tabpanel" id="nj-tabs1-0" aria-labelledby="nj-tabs1-0-b" tabindex="0"><h3 class="nj-tab-title">Windows</h3> <p class="nj-paragraph">Run the installer.</p> </div> <div class="nj-tab" role="tabpanel" id="nj-tabs1-1" aria-labelledby="nj-tabs1-1-b" tabindex="0"><h3 class="nj-tab-title">Linux</h3> <p class="nj-paragraph">Unpack the archive.</p> </div> </div> </main>
$tabwebNaja page
$tab[title] ... $endtab
In a webNaja page: one tab of a $tabs.
$page[Plans]
$tabs
$tab[Free]
$paragraph[For trying it out.]
$endtab
$tab[Team]
$paragraph[For groups.]
$endtab
$endtabs
$endpageGET / → 200 <main class="nj-page"> <div class="nj-tabs"> <div role="tablist"><button type="button" role="tab" id="nj-tabs1-0-b" aria-controls="nj-tabs1-0" aria-selected="true">Free</button><button type="button" role="tab" id="nj-tabs1-1-b" aria-controls="nj-tabs1-1" aria-selected="false">Team</button></div> <div class="nj-tab" role="tabpanel" id="nj-tabs1-0" aria-labelledby="nj-tabs1-0-b" tabindex="0"><h3 class="nj-tab-title">Free</h3> <p class="nj-paragraph">For trying it out.</p> </div> <div class="nj-tab" role="tabpanel" id="nj-tabs1-1" aria-labelledby="nj-tabs1-1-b" tabindex="0"><h3 class="nj-tab-title">Team</h3> <p class="nj-paragraph">For groups.</p> </div> </div> </main>
$sheetwebNaja page
$sheet[column;column...] ... $endsheet
In a webNaja page: a table with the columns named, and a $cells[...] line for each row.
$page[Prices]
$sheet[Plan;Price]
$cells[Free;0]
$cells[Team;12 a month]
$endsheet
$endpageGET / → 200 <main class="nj-page"> <div class="nj-sheet"><table><thead><tr><th scope="col">Plan</th><th scope="col">Price</th></tr></thead><tbody> <tr><td>Free</td><td>0</td></tr> <tr><td>Team</td><td>12 a month</td></tr> </tbody></table></div> </main>
$cellswebNaja page
$cells[value;value...]
In a webNaja page: one row of a $sheet.
$page[Scores]
$sheet[Player;Score]
$each[p;$list[Sam;Ada]]
$cells[$get[p];$random[1;100]]
$endeach
$endsheet
$endpageGET / → 200 <main class="nj-page"> <div class="nj-sheet"><table><thead><tr><th scope="col">Player</th><th scope="col">Score</th></tr></thead><tbody> <tr><td>Sam</td><td>81</td></tr> <tr><td>Ada</td><td>37</td></tr> </tbody></table></div> </main>
$codewebNaja page
$code[code;file=name]
In a webNaja page: a code panel with Najova code coloured, the file name on top and a Copy button. lang=plain shows other text as it is.
$page[Hello]
$code["$print[Hello, world!]";file=hello.naja]
$endpageGET / → 200 <main class="nj-page"> <figure class="nj-code"><figcaption>hello.naja</figcaption><pre><code><span class="t-call">$print</span><span class="t-punct">[</span>Hello, world<span class="t-op">!</span><span class="t-punct">]</span></code></pre><button type="button" class="nj-copy">Copy</button></figure> </main>
$searchwebNaja page
$search[placeholder;index]
In a webNaja page: a search box over the site's search.json (a list of title, url and text), with arrow keys and / to jump to it.
$page[Docs]
$search[Search the docs;/search.json]
$endpageGET / → 200 <main class="nj-page"> <div class="nj-search" role="search" data-index="/search.json"><input type="search" placeholder="Search the docs" aria-label="Search the docs" autocomplete="off"><ul class="nj-results" hidden></ul></div> </main>
$themePickwebNaja page
$themePick[light text;dark text]
In a webNaja page: Light and Dark buttons; the pick is remembered, else the computer's look is used.
$page[Settings]
$themePick
$endpageGET / → 200 <main class="nj-page"> <div class="nj-theme" role="group" aria-label="Light or dark"><button type="button" data-theme-set="light" aria-pressed="false">Light</button><button type="button" data-theme-set="dark" aria-pressed="false">Dark</button></div> </main>
$markdownwebNaja page
$markdown[text or file.md]
In a webNaja page: Markdown as page parts: # headings, lists, tables, > quotes and ``` code (Najova coloured). Give the text, or a .md file in the site's folder. level=3 makes a # heading an h3 (2 if not set).
$page[About]
$markdown["# Bots
Make **bots** with `$slash`.
- Fast
- Small"]
$endpageGET / → 200 <main class="nj-page"> <div class="nj-markdown"><p>"# Bots</p> <p>Make <strong>bots</strong> with <code>$slash</code>.</p> <ul><li>Fast</li><li>Small"</li></ul> </div> </main>
$childrenwebNaja page
$children
In a $function: where the parts written inside it go. Then $card[Title] ... $endcard holds other parts, like $section does.
$function[card;title]
$section[$get[title];style=card]
$children
$endsection
$endfunction
$page[Cards]
$card[Fast]
$paragraph[Starts in a blink.]
$endcard
$endpageGET / → 200 <main class="nj-page"> <section class="nj-section s-card"> <h2>Fast</h2> <p class="nj-paragraph">Starts in a blink.</p> </section> </main>