Skip to content

Commit 03a618c

Browse files
authored
feat: Add nuxt-script snippets (#16)
* Add data-fetching snippets #6 - nfetch - nfetch-lazy - nasyncdata - nasyncdata-lazy * Add head-management snippets #6 - nhead - nhead-description - nhead-template - npagemeta - npagemeta-description
1 parent 9c8c2aa commit 03a618c

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

Diff for: package.json

+8
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@
5757
{
5858
"language": "html",
5959
"path": "./snippets/nuxt-template.code-snippets"
60+
},
61+
{
62+
"language": "javascript",
63+
"path": "./snippets/nuxt-script.code-snippets"
64+
},
65+
{
66+
"language": "typescript",
67+
"path": "./snippets/nuxt-script.code-snippets"
6068
}
6169
]
6270
}

Diff for: snippets/nuxt-script.code-snippets

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"Nuxt useFetch": {
3+
"prefix": "nfetch",
4+
"body": [
5+
"const { data: ${1:name} } = await useFetch('${2:path}')"
6+
],
7+
"description": "Nuxt useFetch composable"
8+
},
9+
"Nuxt useLazyFetch": {
10+
"prefix": "nfetch-lazy",
11+
"body": [
12+
"const { pending, data: ${1:name} } = await useLazyFetch('${2:path}')"
13+
],
14+
"description": "Nuxt useLazyFetch composable"
15+
},
16+
"Nuxt useAsyncData": {
17+
"prefix": "nasyncdata",
18+
"body": [
19+
"const { data: ${1:name} } = await useAsyncData('${2:requestKey}', () => \\$fetch('${3:path}'))"
20+
],
21+
"description": "Nuxt useAsyncData composable"
22+
},
23+
"Nuxt useLazyAsyncData": {
24+
"prefix": "nasyncdata-lazy",
25+
"body": [
26+
"const { pending, data: ${1:name} } = await useLazyAsyncData('${2:requestKey}', () => \\$fetch('${3:path}'))"
27+
],
28+
"description": "Nuxt useLazyAsyncData composable"
29+
},
30+
"Nuxt useHead": {
31+
"prefix": "nhead",
32+
"body": [
33+
"useHead({",
34+
"\ttitle: ${1:pageTitle},",
35+
"})"
36+
],
37+
"description": "Nuxt useHead composable"
38+
},
39+
"Nuxt useHead with description": {
40+
"prefix": "nhead-description",
41+
"body": [
42+
"useHead({",
43+
"\ttitle: ${1:pageTitle},",
44+
"\tmeta: [",
45+
"\t\t{ name: 'description', content: ${2:pageDescription} },",
46+
"\t],",
47+
"})"
48+
],
49+
"description": "Nuxt useHead composable with description"
50+
},
51+
"Nuxt useHead - Title template": {
52+
"prefix": "nhead-template",
53+
"body": [
54+
"useHead({",
55+
"\ttitleTemplate: (titleChunk) => {",
56+
"\t\treturn titleChunk ? `\\${titleChunk} - ${1:siteTitle}` : '${1:siteTitle}'",
57+
"\t}",
58+
"})"
59+
],
60+
"description": "Nuxt useHead composable with title template"
61+
},
62+
"Nuxt definePageMeta": {
63+
"prefix": "npagemeta",
64+
"body": [
65+
"definePageMeta({",
66+
"\ttitle: '${1:pageTitle}',",
67+
"})"
68+
],
69+
"description": "Nuxt definePageMeta composable"
70+
},
71+
"Nuxt definePageMeta with description": {
72+
"prefix": "npagemeta-description",
73+
"body": [
74+
"definePageMeta({",
75+
"\ttitle: '${1:pageTitle}',",
76+
"\tmeta: [",
77+
"\t\t{ name: 'description', content: '${2:pageDescription}' },",
78+
"\t],",
79+
"})"
80+
],
81+
"description": "Nuxt definePageMeta composable with description"
82+
},
83+
}

0 commit comments

Comments
 (0)