diff --git a/site/content/docs/02-template-syntax/01-dot-svelte-files.md b/site/content/docs/02-template-syntax/01-svelte-components.md similarity index 71% rename from site/content/docs/02-template-syntax/01-dot-svelte-files.md rename to site/content/docs/02-template-syntax/01-svelte-components.md index 61da7adaa2..487abc8afc 100644 --- a/site/content/docs/02-template-syntax/01-dot-svelte-files.md +++ b/site/content/docs/02-template-syntax/01-svelte-components.md @@ -1,5 +1,5 @@ --- -title: .svelte files +title: Svelte components --- Components are the building blocks of Svelte applications. They are written into `.svelte` files, using a superset of HTML. @@ -342,134 +342,3 @@ In that case, the ` ``` - -## Tags - -A lowercase tag, like `
`, denotes a regular HTML element. A capitalised tag, such as `` or ``, indicates a _component_. - -```svelte - - -
- -
-``` - -## Attributes and props - -By default, attributes work exactly like their HTML counterparts. - -```svelte -
- -
-``` - -As in HTML, values may be unquoted. - -```svelte - -``` - -Attribute values can contain JavaScript expressions. - -```svelte -page {p} -``` - -Or they can _be_ JavaScript expressions. - -```svelte - -``` - -Boolean attributes are included on the element if their value is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) and excluded if it's [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy). - -All other attributes are included unless their value is [nullish](https://developer.mozilla.org/en-US/docs/Glossary/Nullish) (`null` or `undefined`). - -```svelte - -
This div has no title attribute
-``` - -An expression might include characters that would cause syntax highlighting to fail in regular HTML, so quoting the value is permitted. The quotes do not affect how the value is parsed: - -```svelte - -``` - -When the attribute name and value match (`name={name}`), they can be replaced with `{name}`. - -```svelte - - - -``` - -By convention, values passed to components are referred to as _properties_ or _props_ rather than _attributes_, which are a feature of the DOM. - -As with elements, `name={name}` can be replaced with the `{name}` shorthand. - -```svelte - -``` - -_Spread attributes_ allow many attributes or properties to be passed to an element or component at once. - -An element or component can have multiple spread attributes, interspersed with regular ones. - -```svelte - -``` - -_`$$props`_ references all props that are passed to a component, including ones that are not declared with `export`. It is not generally recommended, as it is difficult for Svelte to optimise. But it can be useful in rare cases – for example, when you don't know at compile time what props might be passed to a component. - -```svelte - -``` - -_`$$restProps`_ contains only the props which are _not_ declared with `export`. It can be used to pass down other unknown attributes to an element in a component. It shares the same optimisation problems as _`$$props`_, and is likewise not recommended. - -```svelte - -``` - -> The `value` attribute of an `input` element or its children `option` elements must not be set with spread attributes when using `bind:group` or `bind:checked`. Svelte needs to be able to see the element's `value` directly in the markup in these cases so that it can link it to the bound variable. - -> Sometimes, the attribute order matters as Svelte sets attributes sequentially in JavaScript. For example, ``, Svelte will attempt to set the value to `1` (rounding up from 0.5 as the step by default is 1), and then set the step to `0.1`. To fix this, change it to ``. - -> Another example is ``. Svelte will set the img `src` before making the img element `loading="lazy"`, which is probably too late. Change this to `` to make the image lazily loaded. - -## Text expressions - -```svelte -{expression} -``` - -Text can also contain JavaScript expressions: - -> If you're using a regular expression (`RegExp`) [literal notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#literal_notation_and_constructor), you'll need to wrap it in parentheses. - -```svelte -

Hello {name}!

-

{a} + {b} = {a + b}.

- -
{/^[A-Za-z ]+$/.test(value) ? x : y}
-``` - -## Comments - -You can use HTML comments inside components. - -```svelte -

Hello world

-``` - -Comments beginning with `svelte-ignore` disable warnings for the next block of markup. Usually, these are accessibility warnings; make sure that you're disabling them for a good reason. - -```svelte - - -``` diff --git a/site/content/docs/02-template-syntax/02-basic-markup.md b/site/content/docs/02-template-syntax/02-basic-markup.md new file mode 100644 index 0000000000..83f11861e5 --- /dev/null +++ b/site/content/docs/02-template-syntax/02-basic-markup.md @@ -0,0 +1,134 @@ +--- +title: Basic markup +--- + +## Tags + +A lowercase tag, like `
`, denotes a regular HTML element. A capitalised tag, such as `` or ``, indicates a _component_. + +```svelte + + +
+ +
+``` + +## Attributes and props + +By default, attributes work exactly like their HTML counterparts. + +```svelte +
+ +
+``` + +As in HTML, values may be unquoted. + +```svelte + +``` + +Attribute values can contain JavaScript expressions. + +```svelte +page {p} +``` + +Or they can _be_ JavaScript expressions. + +```svelte + +``` + +Boolean attributes are included on the element if their value is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) and excluded if it's [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy). + +All other attributes are included unless their value is [nullish](https://developer.mozilla.org/en-US/docs/Glossary/Nullish) (`null` or `undefined`). + +```svelte + +
This div has no title attribute
+``` + +An expression might include characters that would cause syntax highlighting to fail in regular HTML, so quoting the value is permitted. The quotes do not affect how the value is parsed: + +```svelte + +``` + +When the attribute name and value match (`name={name}`), they can be replaced with `{name}`. + +```svelte + + + +``` + +By convention, values passed to components are referred to as _properties_ or _props_ rather than _attributes_, which are a feature of the DOM. + +As with elements, `name={name}` can be replaced with the `{name}` shorthand. + +```svelte + +``` + +_Spread attributes_ allow many attributes or properties to be passed to an element or component at once. + +An element or component can have multiple spread attributes, interspersed with regular ones. + +```svelte + +``` + +_`$$props`_ references all props that are passed to a component, including ones that are not declared with `export`. It is not generally recommended, as it is difficult for Svelte to optimise. But it can be useful in rare cases – for example, when you don't know at compile time what props might be passed to a component. + +```svelte + +``` + +_`$$restProps`_ contains only the props which are _not_ declared with `export`. It can be used to pass down other unknown attributes to an element in a component. It shares the same optimisation problems as _`$$props`_, and is likewise not recommended. + +```svelte + +``` + +> The `value` attribute of an `input` element or its children `option` elements must not be set with spread attributes when using `bind:group` or `bind:checked`. Svelte needs to be able to see the element's `value` directly in the markup in these cases so that it can link it to the bound variable. + +> Sometimes, the attribute order matters as Svelte sets attributes sequentially in JavaScript. For example, ``, Svelte will attempt to set the value to `1` (rounding up from 0.5 as the step by default is 1), and then set the step to `0.1`. To fix this, change it to ``. + +> Another example is ``. Svelte will set the img `src` before making the img element `loading="lazy"`, which is probably too late. Change this to `` to make the image lazily loaded. + +## Text expressions + +```svelte +{expression} +``` + +Text can also contain JavaScript expressions: + +> If you're using a regular expression (`RegExp`) [literal notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#literal_notation_and_constructor), you'll need to wrap it in parentheses. + +```svelte +

Hello {name}!

+

{a} + {b} = {a + b}.

+ +
{/^[A-Za-z ]+$/.test(value) ? x : y}
+``` + +## Comments + +You can use HTML comments inside components. + +```svelte +

Hello world

+``` + +Comments beginning with `svelte-ignore` disable warnings for the next block of markup. Usually, these are accessibility warnings; make sure that you're disabling them for a good reason. + +```svelte + + +``` diff --git a/site/content/docs/02-template-syntax/02-logic-blocks.md b/site/content/docs/02-template-syntax/03-logic-blocks.md similarity index 100% rename from site/content/docs/02-template-syntax/02-logic-blocks.md rename to site/content/docs/02-template-syntax/03-logic-blocks.md diff --git a/site/content/docs/02-template-syntax/03-special-tags.md b/site/content/docs/02-template-syntax/04-special-tags.md similarity index 100% rename from site/content/docs/02-template-syntax/03-special-tags.md rename to site/content/docs/02-template-syntax/04-special-tags.md diff --git a/site/content/docs/02-template-syntax/04-element-directives.md b/site/content/docs/02-template-syntax/05-element-directives.md similarity index 100% rename from site/content/docs/02-template-syntax/04-element-directives.md rename to site/content/docs/02-template-syntax/05-element-directives.md diff --git a/site/content/docs/02-template-syntax/05-component-directives.md b/site/content/docs/02-template-syntax/06-component-directives.md similarity index 100% rename from site/content/docs/02-template-syntax/05-component-directives.md rename to site/content/docs/02-template-syntax/06-component-directives.md diff --git a/site/content/docs/02-template-syntax/06-special-elements.md b/site/content/docs/02-template-syntax/07-special-elements.md similarity index 100% rename from site/content/docs/02-template-syntax/06-special-elements.md rename to site/content/docs/02-template-syntax/07-special-elements.md diff --git a/sites/svelte.dev/package-lock.json b/sites/svelte.dev/package-lock.json index 0a0f8e9c81..dd1a1eaee5 100644 --- a/sites/svelte.dev/package-lock.json +++ b/sites/svelte.dev/package-lock.json @@ -8,7 +8,7 @@ "name": "svelte.dev", "version": "1.0.0", "dependencies": { - "@supabase/supabase-js": "^2.14.0", + "@supabase/supabase-js": "^2.20.0", "@sveltejs/repl": "^0.2.0", "cookie": "^0.5.0", "devalue": "^4.3.0", @@ -20,9 +20,8 @@ "devDependencies": { "@resvg/resvg-js": "^2.4.1", "@sveltejs/adapter-vercel": "^2.4.1", - "@sveltejs/kit": "^1.15.1", - "@sveltejs/site-kit": "^3.4.0", - "@sveltejs/vite-plugin-svelte": "^2.0.4", + "@sveltejs/kit": "^1.15.4", + "@sveltejs/site-kit": "^4.0.2", "@types/marked": "^4.0.8", "@types/prismjs": "^1.26.0", "degit": "^2.8.4", @@ -36,14 +35,14 @@ "prismjs": "^1.29.0", "rollup": "^3.20.2", "rollup-plugin-dts": "^5.3.0", - "satori": "^0.4.4", + "satori": "^0.4.7", "satori-html": "^0.3.2", "shelljs": "^0.8.5", "shiki": "^0.14.1", "shiki-twoslash": "^3.1.1", "svelte": "^3.58.0", "svelte-check": "^3.2.0", - "typescript": "^5.0.3", + "typescript": "^5.0.4", "vite": "^4.2.1", "vite-imagetools": "^4.0.18" } @@ -1228,9 +1227,9 @@ } }, "node_modules/@supabase/gotrue-js": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/@supabase/gotrue-js/-/gotrue-js-2.20.0.tgz", - "integrity": "sha512-dbbEXrzb6OdWeYJQ8VYnJj2sMiZYw8XGj1B5rZlbcjDxkW0Za04x+wWn6g6T5/6RwNm2kReqgAR5ufYeCPuCDA==", + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/@supabase/gotrue-js/-/gotrue-js-2.22.0.tgz", + "integrity": "sha512-YBxg1AoMgXSFbEuamMyuJhKwscmK/eCkL8K7CenCjJJRVKfNHDYkM9F7VX9+atDDY6ejufdYz1auVfsqRrt9pQ==", "dependencies": { "cross-fetch": "^3.1.5" } @@ -1244,9 +1243,9 @@ } }, "node_modules/@supabase/realtime-js": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.7.1.tgz", - "integrity": "sha512-WC0yPArBF/wPXwxKWTrRSMWWnFQCbhhUsX0u42x4OqUdDJtow6rzvDIZHWFZLh85UUBYIQ2++AabSNgzd3ubQg==", + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.7.2.tgz", + "integrity": "sha512-Fi6xAl5PUkqnjl3wo4rdcQIbMG3+yTRX1aUZe/yfvTG84RMvmCXJ1yN6MmafVLeZpU1xkaz5Vx4L0tnHcLiy6w==", "dependencies": { "@types/phoenix": "^1.5.4", "@types/websocket": "^1.0.3", @@ -1254,23 +1253,23 @@ } }, "node_modules/@supabase/storage-js": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.4.0.tgz", - "integrity": "sha512-uCT6WjeZsyxH/Br1MnXieJnXrYxS3DpIkdNxEFTKCoaPX/KZ2t62v++R2IMNB/XGI1LMuJfN5wM28uuK6DMpfw==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.5.1.tgz", + "integrity": "sha512-nkR0fQA9ScAtIKA3vNoPEqbZv1k5B5HVRYEvRWdlP6mUpFphM9TwPL2jZ/ztNGMTG5xT6SrHr+H7Ykz8qzbhjw==", "dependencies": { "cross-fetch": "^3.1.5" } }, "node_modules/@supabase/supabase-js": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.14.0.tgz", - "integrity": "sha512-pdcYDaxTUqv5A8NqDnLn731rTP0Wm469H+0ag6Jb8YpWR95rmusfpGY7vrykWXvdnvCMxoG6eEwSF9vQtxVrow==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.20.0.tgz", + "integrity": "sha512-6sNX4WEaVBbmOS1K2U3PcpAhp0FcjVo1FRSEoj4N+NZ6DIokX+yut8IBhF176pg5kFCdFIL2wyNhf3SltREmWw==", "dependencies": { "@supabase/functions-js": "^2.1.0", - "@supabase/gotrue-js": "^2.18.1", + "@supabase/gotrue-js": "^2.22.0", "@supabase/postgrest-js": "^1.1.1", - "@supabase/realtime-js": "^2.7.1", - "@supabase/storage-js": "^2.3.1", + "@supabase/realtime-js": "^2.7.2", + "@supabase/storage-js": "^2.5.1", "cross-fetch": "^3.1.5" } }, @@ -1288,9 +1287,9 @@ } }, "node_modules/@sveltejs/kit": { - "version": "1.15.1", - "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.15.1.tgz", - "integrity": "sha512-Wexy3N+COoClTuRawVJRbLoH5HFxNrXG3uoHt/Yd5IGx8WAcJM9Nj/CcBLw/tjCR9uDDYMnx27HxuPy3YIYQUA==", + "version": "1.15.4", + "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.15.4.tgz", + "integrity": "sha512-m+Tid9nbtFawmiu85lDlal0AQ7UeuV48UsuKMe06QLr3ntMQSUzIPqyswNRZqFrar6NhVTUXQ0aO61M3U4MWpQ==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -1340,10 +1339,13 @@ "integrity": "sha512-HBLtfNdLr5Ykl8i8CvJcYjib7zMIJupg4T/omplp3ccpgpiUh26tk71vRG1+a6yMkfbfy0ShoPb9uwNril5cnw==" }, "node_modules/@sveltejs/site-kit": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/@sveltejs/site-kit/-/site-kit-3.4.0.tgz", - "integrity": "sha512-jMwL8eWNBN0WeWoO8qXx8zUvDywiittc4GGNfX1CXwC6i2bgbrfHke+RrZmNxOrMeSgDcoCnYL0kKZmmg6al7w==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@sveltejs/site-kit/-/site-kit-4.0.2.tgz", + "integrity": "sha512-gqxBMZW5ZiO61m7Bn4x0fMUJC1M27ku1u7u0KJrg0zRSN3Zu30VdwE1SwWO4ueKxOxLXD2gzfUMdvoez7ZoBuQ==", "dev": true, + "dependencies": { + "svelte-local-storage-store": "^0.4.0" + }, "peerDependencies": { "@sveltejs/kit": "^1.0.0", "svelte": "^3.54.0" @@ -1399,9 +1401,9 @@ "integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==" }, "node_modules/@types/phoenix": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.5.5.tgz", - "integrity": "sha512-1eWWT19k0L4ZiTvdXjAvJ9KvW0B8SdiVftQmFPJGTEx78Q4PCSIQDpz+EfkFVR1N4U9gREjlW4JXL8YCIlY0bw==" + "version": "1.5.6", + "resolved": "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.5.6.tgz", + "integrity": "sha512-e7jZ6I9uyRGsg7MNwQcarmBvRlbGb9DibbocE9crVnxqsy6C23RMxLWbJ2CQ3vgCW7taoL1L+F02EcjA6ld7XA==" }, "node_modules/@types/prismjs": { "version": "1.26.0", @@ -3754,9 +3756,9 @@ } }, "node_modules/satori": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/satori/-/satori-0.4.4.tgz", - "integrity": "sha512-UCgoY7CXibFQmgI4ay4QSWUOca07nI9pY56w8NKrBq+bkGgiMbcPXZWj9bxukyJkEl/cgAICGjjxvwlDF2NYRw==", + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/satori/-/satori-0.4.7.tgz", + "integrity": "sha512-angaQXTa5geGKxSD9+n85GlH71SfPJTMmrUJf76PZeV4gXWz8aOAxSEH0M1Ok/yUacrWxVto0WjV7iGkK0h3CQ==", "dev": true, "dependencies": { "@shuding/opentype.js": "1.4.0-beta.0", @@ -4169,6 +4171,18 @@ "resolved": "https://registry.npmjs.org/svelte-json-tree/-/svelte-json-tree-1.0.0.tgz", "integrity": "sha512-scs1OdkC8uFpTN4MX0yKkOzZ1/EG3eP1ARC+xcFthXp2IfcwBaXgab0FqA4Am0vQwffNNB+1Gd1LFkJBlynWTA==" }, + "node_modules/svelte-local-storage-store": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/svelte-local-storage-store/-/svelte-local-storage-store-0.4.0.tgz", + "integrity": "sha512-ctPykTt4S3BE5bF0mfV0jKiUR1qlmqLvnAkQvYHLeb9wRyO1MdIFDVI23X+TZEFleATHkTaOpYZswIvf3b2tWA==", + "dev": true, + "engines": { + "node": ">=0.14" + }, + "peerDependencies": { + "svelte": "^3.48.0" + } + }, "node_modules/svelte-preprocess": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-5.0.3.tgz", @@ -4403,9 +4417,9 @@ } }, "node_modules/typescript": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.3.tgz", - "integrity": "sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/sites/svelte.dev/package.json b/sites/svelte.dev/package.json index a2735b6bfc..f6a9a3573a 100644 --- a/sites/svelte.dev/package.json +++ b/sites/svelte.dev/package.json @@ -17,7 +17,7 @@ "test": "uvu -r ts-node/register src/lib/server/markdown" }, "dependencies": { - "@supabase/supabase-js": "^2.14.0", + "@supabase/supabase-js": "^2.20.0", "@sveltejs/repl": "^0.2.0", "cookie": "^0.5.0", "devalue": "^4.3.0", @@ -29,9 +29,8 @@ "devDependencies": { "@resvg/resvg-js": "^2.4.1", "@sveltejs/adapter-vercel": "^2.4.1", - "@sveltejs/kit": "^1.15.1", - "@sveltejs/site-kit": "^3.4.0", - "@sveltejs/vite-plugin-svelte": "^2.0.4", + "@sveltejs/kit": "^1.15.4", + "@sveltejs/site-kit": "^4.0.2", "@types/marked": "^4.0.8", "@types/prismjs": "^1.26.0", "degit": "^2.8.4", @@ -45,14 +44,14 @@ "prismjs": "^1.29.0", "rollup": "^3.20.2", "rollup-plugin-dts": "^5.3.0", - "satori": "^0.4.4", + "satori": "^0.4.7", "satori-html": "^0.3.2", "shelljs": "^0.8.5", "shiki": "^0.14.1", "shiki-twoslash": "^3.1.1", "svelte": "^3.58.0", "svelte-check": "^3.2.0", - "typescript": "^5.0.3", + "typescript": "^5.0.4", "vite": "^4.2.1", "vite-imagetools": "^4.0.18" } diff --git a/sites/svelte.dev/src/routes/+layout.svelte b/sites/svelte.dev/src/routes/+layout.svelte index 6d48972e86..8c96bed230 100644 --- a/sites/svelte.dev/src/routes/+layout.svelte +++ b/sites/svelte.dev/src/routes/+layout.svelte @@ -16,7 +16,11 @@
-