From 009ce45e634810b01cca113dc7cb0ff581cd6cf7 Mon Sep 17 00:00:00 2001
From: Ben McCann <322311+benmccann@users.noreply.github.com>
Date: Tue, 11 Apr 2023 10:14:14 -0700
Subject: [PATCH 1/4] site: tweak content layout (#8483)
---
...velte-files.md => 01-svelte-components.md} | 133 +----------------
.../02-template-syntax/02-basic-markup.md | 134 ++++++++++++++++++
...{02-logic-blocks.md => 03-logic-blocks.md} | 0
...{03-special-tags.md => 04-special-tags.md} | 0
...directives.md => 05-element-directives.md} | 0
...rectives.md => 06-component-directives.md} | 0
...ial-elements.md => 07-special-elements.md} | 0
sites/svelte.dev/package-lock.json | 8 +-
sites/svelte.dev/package.json | 2 +-
9 files changed, 140 insertions(+), 137 deletions(-)
rename site/content/docs/02-template-syntax/{01-dot-svelte-files.md => 01-svelte-components.md} (71%)
create mode 100644 site/content/docs/02-template-syntax/02-basic-markup.md
rename site/content/docs/02-template-syntax/{02-logic-blocks.md => 03-logic-blocks.md} (100%)
rename site/content/docs/02-template-syntax/{03-special-tags.md => 04-special-tags.md} (100%)
rename site/content/docs/02-template-syntax/{04-element-directives.md => 05-element-directives.md} (100%)
rename site/content/docs/02-template-syntax/{05-component-directives.md => 06-component-directives.md} (100%)
rename site/content/docs/02-template-syntax/{06-special-elements.md => 07-special-elements.md} (100%)
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 18c76b3944..e0774e548e 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.
@@ -340,134 +340,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 3ea482a9b5..2ac8620774 100644
--- a/sites/svelte.dev/package-lock.json
+++ b/sites/svelte.dev/package-lock.json
@@ -20,7 +20,7 @@
"devDependencies": {
"@resvg/resvg-js": "^2.4.1",
"@sveltejs/adapter-vercel": "^2.4.1",
- "@sveltejs/kit": "^1.15.1",
+ "@sveltejs/kit": "^1.15.4",
"@sveltejs/site-kit": "^3.4.0",
"@sveltejs/vite-plugin-svelte": "^2.0.4",
"@types/marked": "^4.0.8",
@@ -1248,9 +1248,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": {
diff --git a/sites/svelte.dev/package.json b/sites/svelte.dev/package.json
index 6a3104aa3a..543264f913 100644
--- a/sites/svelte.dev/package.json
+++ b/sites/svelte.dev/package.json
@@ -28,7 +28,7 @@
"devDependencies": {
"@resvg/resvg-js": "^2.4.1",
"@sveltejs/adapter-vercel": "^2.4.1",
- "@sveltejs/kit": "^1.15.1",
+ "@sveltejs/kit": "^1.15.4",
"@sveltejs/site-kit": "^3.4.0",
"@sveltejs/vite-plugin-svelte": "^2.0.4",
"@types/marked": "^4.0.8",
From ec733593e6165fa51c4a2d8a4c9cb973549cef0c Mon Sep 17 00:00:00 2001
From: Puru Vijay
Date: Tue, 11 Apr 2023 23:18:26 +0530
Subject: [PATCH 2/4] fix: Old site redirects
---
sites/svelte.dev/src/routes/docs/+page.svelte | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/sites/svelte.dev/src/routes/docs/+page.svelte b/sites/svelte.dev/src/routes/docs/+page.svelte
index f6ef383623..da1672c297 100644
--- a/sites/svelte.dev/src/routes/docs/+page.svelte
+++ b/sites/svelte.dev/src/routes/docs/+page.svelte
@@ -137,14 +137,15 @@
const pages_regex_map = new Map([
// Basic ones
[/(before-we-begin|getting-started)$/i, 'introduction'],
- [/(component-format|template-syntax)$/i, 'dot-svelte-files'],
+ [/template-syntax$/i, 'basic-markup'],
+ [/component-format$/i, 'svelte-components'],
[/run-time$/i, 'svelte'],
[/compile-time$/i, 'svelte-compiler'],
[/(accessibility-warnings)$/i, '$1'],
// component-format-
- [/component-format-(script|style|script-context-module)$/i, 'dot-svelte-files#$1'],
- [/component-format-(?:script)(?:-?(.*))$/i, 'dot-svelte-files#$1'],
+ [/component-format-(script|style|script-context-module)$/i, 'svelte-components#$1'],
+ [/component-format-(?:script)(?:-?(.*))$/i, 'svelte-components#$1'],
// template-syntax
[/template-syntax-((?:element|component)-directives)-?(.*)/i, '$1#$2'],
@@ -152,10 +153,7 @@
[/template-syntax-(?:slot)-?(.*)/i, 'special-elements#$1'],
[/template-syntax-(if|each|await|key)$/i, 'logic-blocks#$1'],
[/template-syntax-(const|debug|html)$/i, 'special-tags#$1'],
- [
- /template-syntax-(tags|attributes-and-props|text-expressions|comments)$/i,
- 'dot-svelte-files#$1'
- ],
+ [/template-syntax-(tags|attributes-and-props|text-expressions|comments)$/i, 'basic-markup#$1'],
// !!!! This one should stay at the bottom of `template-syntax`, or it may end up hijacking logic blocks and special tags
[/template-syntax-(.+)/i, 'special-elements#$1'],
From 71d173a4c0c48205f98b71015ebc8ee0cfadcb7a Mon Sep 17 00:00:00 2001
From: Puru Vijay
Date: Tue, 11 Apr 2023 23:25:20 +0530
Subject: [PATCH 3/4] feat: Add home slot
---
sites/svelte.dev/src/routes/+layout.svelte | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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 @@