Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
stordahl committed Sep 3, 2021
0 parents commit e6c6ddc
Show file tree
Hide file tree
Showing 10 changed files with 282 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Set default behavior to automatically normalize line endings.
* text=auto

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.vsix
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}
4 changes: 4 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode/**
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Change Log

All notable changes to the "sveltekit-snippets" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]

- Initial release
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# sveltekit-snippets

The extension provides snippets for common patterns in SvelteKit & Vanilla Svelte including...

- Components
- Logic Blocks
- Endpoints
- Load Functions

## Issues

Issues are welcome and encouraged! Please describe the issue as thuroughly as you can – Contribution guidelines are forthcoming.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "sveltekit-snippets",
"displayName": "sveltekit-snippets",
"description": "Snippets for SvelteKit",
"version": "0.0.1",
"publisher": "stordahl",
"repository": {
"type": "git",
"url": "https://github.com/stordahl/sveltekit-snippets.git"
},
"engines": {
"vscode": "^1.60.0"
},
"categories": [
"Snippets"
],
"contributes": {
"snippets": [
{
"language": "javascript",
"path": "./snippets/snippets.code-snippets"
}
]
}
}
192 changes: 192 additions & 0 deletions snippets/snippets.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
{
"Svelte Component": {
"prefix": "kitComp",
"scope": "svelte",
"description": "Scaffold a Svelte component",
"body": [
"<script>",
"$0",
"</script>",
"",
"<style>",
"",
"</style>"
]
},
"Svelte TypeScript Component": {
"prefix": "kitCompTs",
"scope": "svelte",
"description": "Scaffold a TypeScript Svelte component",
"body": [
"<script lang=ts>",
"\t $0",
"</script>",
"",
"<style>",
"",
"</style>"
]
},
"SvelteKit Module Component": {
"prefix": "kitModule",
"scope": "svelte",
"description": "Scaffold a SvelteKit module component for a page",
"body": [
"<script context=module>",
"\t $0",
"</script>",
"<script>",
"",
"</script>",
"",
"<style>",
"",
"</style>"
]
},
"SvelteKit TypeScript Module Component": {
"prefix": "kitModuleTs",
"scope": "svelte",
"description": "Scaffold a SvelteKit module component for a page",
"body": [
"<script lang=ts context=module>",
"\t $0",
"</script>",
"<script>",
"",
"</script",
"",
"<style>",
"",
"</style>"
]
},
"SvelteKit Layout Component": {
"prefix": "kitLayout",
"scope": "svelte",
"description": "Scaffold a SvelteKit layout component",
"body": [
"<script>",
"\t $0",
"</script>",
"",
"<main>",
" <slot/>",
"</main",
"",
"<style>",
"",
"</style>"
]
},
"Svelte Prefetch": {
"prefix": "kitPrefetch",
"scope": "svelte, html",
"description": "Create sveltekit:prefetch anchor tag",
"body": ["<a sveltekit:prefetch href='${1:url}'>${2:text}</a>"]
},
"Svelte Each Block": {
"prefix": "kitEach",
"scope": "svelte",
"description": "Create a Svelte #each block",
"body": [
"{#each ${1:array} as ${2:element} }",
"\t",
"{/each}"
]
},
"Svelte If Block": {
"prefix": "kitIf",
"scope": "svelte",
"description": "Create a Svelte #if block",
"body": [
"{#if ${1:condition} }",
"\t",
"{/if}"
]
},
"Svelte Await Block": {
"prefix": "kitAwait",
"scope": "svelte",
"description": "Create a Svelte #await block",
"body": [
"{#await ${1:expression} }",
"\t",
"{:then ${2:name} }",
"\t",
"{:catch ${3:name} }",
"\t",
"{/await}"
]
},
"Svelte Key Block": {
"prefix": "kitKey",
"scope": "svelte",
"description": "Create a Svelte #key block",
"body": [
"{#key ${1:expression} }",
"\t",
"{/key}"
]
},
"Svelte Page Title": {
"prefix": "kitTitle",
"scope": "svelte",
"description": "Create a title element in the document head",
"body": [
"<svelte:head>",
"\t<title>${TM_FILENAME_BASE}</title>",
"</svelte:head>"
]
},
"SvelteKit Load Function": {
"prefix": "kitLoad",
"scope": "javascript",
"description": "Create a SvelteKit Load function",
"body": [
"/**",
" * @type {import('@sveltejs/kit').Load}",
" */",
"export async function load({ page, fetch, session, context }) {",
" const url = `${1:api}`;",
" const res = await fetch(url);",
"",
"if (res.ok) {",
" return {",
" props: {",
" ${2:propName}: await res.json()",
" }",
" };",
"}",
"",
"return {",
" status: res.status,",
" error: new Error(`Could not load ${url}`)",
" };",
"}"
]
},
"SvelteKit Endpoint": {
"prefix": "kitEndpoint",
"scope": "javascript",
"description": "Create a SvelteKit Endpoint",
"body": [
"/**",
"* @type {import('@sveltejs/kit').RequestHandler}",
"*/",
"export const ${1:method} = async ({ params }) => {",
" const { ${TM_FILENAME_BASE} } = params;",
"",
" const res = await ${2:something};",
"",
" if (res) {",
" return {",
" body: {",
" res",
" }",
" };",
" }",
"}"
]
},
}
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


0 comments on commit e6c6ddc

Please sign in to comment.