Files
WRNexusJS/editors/vscode/snippets/wrn.json
T
2026-07-12 15:55:18 +05:30

115 lines
3.3 KiB
JSON

{
"Page": {
"prefix": "page",
"body": [
"page ${1:Home} {",
" layout = \"${2:public}\"",
"",
" seo {",
" title = \"${3:Home}\"",
" description = \"${4:A WrNexus page.}\"",
" }",
"",
" view {",
" <h1>$5</h1>",
" }",
"}",
""
],
"description": "A WrNexus page (a route) with layout, seo and view."
},
"Component": {
"prefix": "component",
"body": [
"component ${1:Counter} {",
" props {",
" ${2:start} = ${3:0}",
" }",
"",
" state ${4:count} = ${2:start}",
"",
" view {",
" <button @click=\"${4:count}++\">{${4:count}}</button>",
" }",
"}",
""
],
"description": "A reusable, prop-driven component."
},
"View block": {
"prefix": "view",
"body": ["view {", " $0", "}"],
"description": "The server-rendered HTML view block."
},
"State declaration": {
"prefix": "state",
"body": ["state ${1:count} = ${2:0}"],
"description": "Reactive state seeded into the scope."
},
"Props block": {
"prefix": "props",
"body": ["props {", " ${1:label} = ${2:\"Label\"}", "}"],
"description": "Component props with typed defaults."
},
"SEO block": {
"prefix": "seo",
"body": ["seo {", " title = \"${1:Title}\"", " description = \"${2:Description}\"", "}"],
"description": "Per-page SEO metadata."
},
"API route": {
"prefix": "api",
"body": [
"api ${1|GET,POST,PUT,PATCH,DELETE|} ${2:/path} {",
" $0",
" return Response.json({ ok: true });",
"}"
],
"description": "A colocated API route handler."
},
"Functions block": {
"prefix": "functions",
"body": ["functions {", " $0", "}"],
"description": "Shared helper functions for this file."
},
"Style block": {
"prefix": "style",
"body": ["style {", " .${1:box} {", " $0", " }", "}"],
"description": "Scoped CSS inlined with the page."
},
"SSR data block": {
"prefix": "ssr",
"body": ["ssr {", " api ${1:load} ${2|GET,POST|} ${3:/api/data} {", " $0", " }", "}"],
"description": "Server-side data fetching block."
},
"Client data block": {
"prefix": "client",
"body": ["client {", " api ${1:load} ${2|GET,POST|} ${3:/api/data} {", " $0", " }", "}"],
"description": "Client-side data fetching block."
},
"Realtime block": {
"prefix": "realtime",
"body": ["realtime ${1:chat} {", " on ${2:message}(${3:data}) {", " $0", " }", "}"],
"description": "A realtime channel with event handlers."
},
"Component mount": {
"prefix": "mount",
"body": ["<div data-component=\"${1:counter}\" ${2:start=\"0\"}></div>"],
"description": "Mount a component in a view."
},
"List rendering (data-for)": {
"prefix": "for",
"body": ["<${1:li} data-for=\"${2:item} in ${3:items}\" data-text=\"${2:item}\"></${1:li}>"],
"description": "Repeat an element for each item."
},
"Conditional (data-show)": {
"prefix": "show",
"body": ["<div data-show=\"${1:condition}\">$0</div>"],
"description": "Toggle visibility reactively."
},
"Translation": {
"prefix": "t",
"body": ["{t:${1:key}}"],
"description": "Localized text via the i18n dictionary."
}
}