From e6c6ddc2d293b44d81a9333911f0bed56c988e63 Mon Sep 17 00:00:00 2001 From: Jacob Stordahl Date: Fri, 3 Sep 2021 08:03:47 -0500 Subject: [PATCH] init --- .gitattributes | 3 + .gitignore | 2 + .vscode/launch.json | 17 +++ .vscodeignore | 4 + CHANGELOG.md | 9 ++ README.md | 12 ++ package-lock.json | 14 +++ package.json | 25 +++++ snippets/snippets.code-snippets | 192 ++++++++++++++++++++++++++++++++ yarn.lock | 4 + 10 files changed, 282 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscodeignore create mode 100644 CHANGELOG.md create mode 100644 README.md create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 snippets/snippets.code-snippets create mode 100644 yarn.lock diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..13bc9c2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Set default behavior to automatically normalize line endings. +* text=auto + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aeee732 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +*.vsix diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0e191b5 --- /dev/null +++ b/.vscode/launch.json @@ -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}" + ] + } + ] +} \ No newline at end of file diff --git a/.vscodeignore b/.vscodeignore new file mode 100644 index 0000000..f369b5e --- /dev/null +++ b/.vscodeignore @@ -0,0 +1,4 @@ +.vscode/** +.vscode-test/** +.gitignore +vsc-extension-quickstart.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..72d5f1b --- /dev/null +++ b/CHANGELOG.md @@ -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 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..374faae --- /dev/null +++ b/README.md @@ -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. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..6628620 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,14 @@ +{ + "name": "sveltekit-snippets", + "version": "0.0.1", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "version": "0.0.1", + "engines": { + "vscode": "^1.60.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..73a7660 --- /dev/null +++ b/package.json @@ -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" + } + ] + } +} diff --git a/snippets/snippets.code-snippets b/snippets/snippets.code-snippets new file mode 100644 index 0000000..1a0d974 --- /dev/null +++ b/snippets/snippets.code-snippets @@ -0,0 +1,192 @@ +{ + "Svelte Component": { + "prefix": "kitComp", + "scope": "svelte", + "description": "Scaffold a Svelte component", + "body": [ + "", + "", + "" + ] + }, + "Svelte TypeScript Component": { + "prefix": "kitCompTs", + "scope": "svelte", + "description": "Scaffold a TypeScript Svelte component", + "body": [ + "", + "", + "" + ] + }, + "SvelteKit Module Component": { + "prefix": "kitModule", + "scope": "svelte", + "description": "Scaffold a SvelteKit module component for a page", + "body": [ + "", + "", + "", + "" + ] + }, + "SvelteKit TypeScript Module Component": { + "prefix": "kitModuleTs", + "scope": "svelte", + "description": "Scaffold a SvelteKit module component for a page", + "body": [ + "", + "", + "", + "
", + " ", + "", + "", + "" + ] + }, + "Svelte Prefetch": { + "prefix": "kitPrefetch", + "scope": "svelte, html", + "description": "Create sveltekit:prefetch anchor tag", + "body": ["${2:text}"] + }, + "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": [ + "", + "\t${TM_FILENAME_BASE}", + "" + ] + }, + "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", + " }", + " };", + " }", + "}" + ] + }, +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +