Skip to content

Commit 32133a5

Browse files
committed
Added nuxt script snippets
1 parent c8f0f73 commit 32133a5

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ You can enable tab completion (recommended) by opening `Code > Preferences > Set
129129
| `nfont` | link to include fonts in a nuxt project, in nuxt-config |
130130
| `ncss` | link to css assets such as normalize |
131131

132+
### Nuxt Page
133+
134+
| Snippet | Purpose |
135+
| ------- | ------------------------------------------------------- |
136+
| `nasyncdata` | Nuxt asyncData |
137+
| `nfetch` | Nuxt Fetch |
138+
| `nhead` | Nuxt Head |
139+
132140
### Extra (plaintext)
133141

134142
| Snippet | Purpose |

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
"language": "javascript",
5858
"path": "./snippets/nuxt-config.json"
5959
},
60+
{
61+
"language": "javascript",
62+
"path": "./snippets/nuxt-script.json"
63+
},
6064
{
6165
"language": "typescript",
6266
"path": "./snippets/vue-script.json"
@@ -73,6 +77,10 @@
7377
"language": "typescript",
7478
"path": "./snippets/nuxt-config.json"
7579
},
80+
{
81+
"language": "typescript",
82+
"path": "./snippets/nuxt-script.json"
83+
},
7684
{
7785
"language": "plaintext",
7886
"path": "./snippets/plaintext.json"

snippets/nuxt-script.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"Nuxt Async": {
3+
"prefix": "nasyncdata",
4+
"body": ["async asyncData ({ ${1:params} }) {", "\tconst { data } = await fetch(`${2:endpoint}`).then(res => res.json())", "\treturn { ${3:key}:${4:value} }", "},"],
5+
"description": "Nuxt asyncData"
6+
},
7+
"Nuxt Fetch": {
8+
"prefix": "nfetch",
9+
"body": ["async fetch ({ store, ${1:params} }) {", "\tlet { data } = await fetch('${2:endpoint}').then(res => res.json())", "\tstore.commit('${3:MUTATION_TYPE}', data)", "},"],
10+
"description": "Nuxt Fetch"
11+
},
12+
"Nuxt Head": {
13+
"prefix": "nhead",
14+
"body": ["head () {", "\treturn {", "\t\ttitle: ${1:'Page Title'},", "\t\tmeta: [", "\t\t\t// hid is used as unique identifier. Do not use `vmid` for it as it will not work","\t\t\t{ hid: 'description', name: 'description', content: ${2:'My custom description'} }", "\t\t]", "\t}", "},"],
15+
"description": "Nuxt Head"
16+
}
17+
}

0 commit comments

Comments
 (0)