-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
i18n(de): tutorial #12502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i18n(de): tutorial #12502
Changes from 83 commits
6eb9f7d
34bae56
fbf98d2
00841cd
5c184bb
56763fa
49e91dd
4503baf
e23730c
b040220
be0c774
d126213
7d9e81a
0251115
eb6b8d3
e5e8bd2
ea446f0
105e265
10e3171
ad860e9
3d23ea7
d598ea6
2699a30
4485e15
994ec2a
883797d
97c64aa
5dc8f11
b543ad6
6c9be41
e179e6c
62479a5
d900679
b8b25ad
a3330d0
58ea258
330ffe9
bf07125
566fc4c
793bf10
7894985
3fc47f5
7eb9d2a
f7acb88
d17d5ec
de45193
4390bac
555ab68
7baad00
a538812
3eb0cc5
f7c5d01
ac81d57
9f95691
0ff7fdb
35cea00
70f0bb0
8a5dae9
5879616
afe342c
b199ad2
6c09a3c
3d6f1f8
27f257f
53cafeb
92d4d4c
03ebe4d
db72b4d
55f9d47
1d422e9
d2c8a96
6c5c701
79de05e
86963ca
0afdf18
e9e9e32
d506372
bf33942
9011de5
b3ce3da
787324b
ff444ca
1d41e7e
00354d3
45eb780
fb42152
01c192f
0d55b04
3dffb57
597dd2e
5536be3
3ad2995
17ebd88
6adcda1
f0e25e6
88cb352
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,156 @@ | ||||||
| --- | ||||||
| type: tutorial | ||||||
| title: Erstelle eine wiederverwendbare Navigationskomponente | ||||||
| description: |- | ||||||
| Tutorial: Baue deinen ersten Astro-Blog — | ||||||
| Ersetze Elemente, die auf mehreren Seiten wiederholt werden, durch eine wiederverwendbare Komponente | ||||||
| i18nReady: true | ||||||
| --- | ||||||
louisescher marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| import Badge from '~/components/Badge.astro'; | ||||||
| import Box from '~/components/tutorial/Box.astro'; | ||||||
| import Checklist from '~/components/Checklist.astro'; | ||||||
| import MultipleChoice from '~/components/tutorial/MultipleChoice.astro'; | ||||||
| import Option from '~/components/tutorial/Option.astro'; | ||||||
| import PreCheck from '~/components/tutorial/PreCheck.astro'; | ||||||
| import { Steps } from '@astrojs/starlight/components'; | ||||||
|
|
||||||
| Nun, da du denselben HTML-Code auf mehreren Seiten deiner Astro-Website wiederholt hast, ist es an der Zeit, diesen doppelten Inhalt durch eine wiederverwendbare Astro-Komponente zu ersetzen! | ||||||
|
|
||||||
| <PreCheck> | ||||||
| - Erstelle einen neuen Ordner für Komponenten | ||||||
louisescher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| - Baue eine Astro-Komponente, um deine Navigationslinks anzuzeigen | ||||||
| - Ersetze den bestehenden HTML-Code durch eine neue, wiederverwendbare Navigationskomponente | ||||||
| </PreCheck> | ||||||
|
|
||||||
| ## Erstelle einen neuen `src/components/`-Ordner | ||||||
|
|
||||||
| Um `.astro`-Dateien aufzunehmen, die HTML generieren, aber keine neuen Seiten auf deiner Website werden, benötigst du einen neuen Ordner in deinem Projekt: `src/components/`. | ||||||
|
|
||||||
| ## Erstelle eine Navigationskomponente | ||||||
|
|
||||||
| <Steps> | ||||||
| 1. Erstelle eine neue Datei: `src/components/Navigation.astro`. | ||||||
|
|
||||||
| 2. Kopiere deine Links für die Navigation zwischen den Seiten aus dem oberen Bereich einer beliebigen Seite und füge sie in deine neue Datei `Navigation.astro` ein: | ||||||
|
|
||||||
| ```astro title="src/components/Navigation.astro" "---" | ||||||
| --- | ||||||
| --- | ||||||
| <a href="/">Startseite</a> | ||||||
| <a href="/about/">Über mich</a> | ||||||
| <a href="/blog/">Blog</a> | ||||||
| ``` | ||||||
| :::tip | ||||||
| Wenn im Frontmatter deiner `.astro`-Datei nichts steht, musst du auch die Code-Abgrenzung nicht schreiben. Du kannst sie jederzeit wieder hinzufügen, wenn du sie brauchst. | ||||||
| ::: | ||||||
| </Steps> | ||||||
|
|
||||||
| ### Importieren und Verwenden von Navigation.astro | ||||||
|
|
||||||
| <Steps> | ||||||
| 1. Gehe zurück zu `index.astro` und importiere deine neue Komponente innerhalb der Code-Abgrenzung: | ||||||
|
|
||||||
| ```astro title="src/pages/index.astro" ins={2} | ||||||
| import "../styles/global.css"; | ||||||
|
|
||||||
| const pageTitle = "Startseite"; | ||||||
| --- | ||||||
| import Navigation from '../components/Navigation.astro'; | ||||||
| --- | ||||||
| ``` | ||||||
|
|
||||||
| 2. Ersetze dann darunter die vorhandenen Navigations-HTML-Link-Elemente durch die neu importierte Navigationskomponente: | ||||||
|
|
||||||
| ```astro title="src/pages/index.astro" del={1-3} ins={4} | ||||||
| <a href="/">Startseite</a> | ||||||
| <a href="/about/">Über mich</a> | ||||||
| <a href="/blog/">Blog</a> | ||||||
| <Navigation /> | ||||||
| ``` | ||||||
|
|
||||||
| 3. Überprüfe die Vorschau in deinem Browser und stelle fest, dass sie genau gleich aussehen sollte … und das ist genau das, was du erreichen wolltest! | ||||||
| </Steps> | ||||||
|
|
||||||
| Deine Website enthält nun denselben HTML-Code wie zuvor. Aber jetzt werden diese drei Zeilen Code durch deine `<Navigation />`-Komponente bereitgestellt. | ||||||
|
|
||||||
| <Box icon="puzzle-piece"> | ||||||
|
|
||||||
| ## Probiere es selbst aus - Füge Navigation zum Rest deiner Website hinzu | ||||||
|
|
||||||
| Importiere die `<Navigation />`-Komponente und verwende sie auf den anderen beiden Seiten deiner Website (`about.astro` und `blog.astro`) mit derselben Methode. | ||||||
|
|
||||||
| Vergiss nicht, | ||||||
| - eine Import-Anweisung am Anfang des Komponenten-Skripts, innerhalb der Code-Abgrenzung, hinzuzufügen. | ||||||
| - den vorhandenen Code durch die Navigationskomponente zu ersetzen. | ||||||
|
|
||||||
| </Box> | ||||||
|
|
||||||
| :::note | ||||||
| Wenn du deinen Code umstrukturierst, aber das Aussehen deiner Seite im Browser nicht veränderst, **refaktorisierst** du. In dieser Lektion wirst du mehrmals **refaktorisieren**, indem du Teile deines Seiten-HTMLs durch Komponenten ersetzt. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
@trueberryless said that we should do this, not sure if it should be placed in the second person singular or infinitive form, but…?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll wait for Felix's comment here! |
||||||
|
|
||||||
| Das ermöglicht es dir, schnell mit beliebigem funktionierenden Code zu beginnen, der oft in deinem Projekt dupliziert wird. Dann kannst du das Design deines bestehenden Codes schrittweise verbessern, ohne das äußere Erscheinungsbild deiner Website zu verändern. | ||||||
| ::: | ||||||
|
|
||||||
louisescher marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| <Box icon="question-mark"> | ||||||
|
|
||||||
| ### Teste dein Wissen | ||||||
|
|
||||||
louisescher marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| 1. Das kannst du tun, wenn Elemente auf mehreren Seiten wiederholt werden: | ||||||
| <MultipleChoice> | ||||||
| <Option> | ||||||
| den Entwicklungsserver neu starten | ||||||
| </Option> | ||||||
| <Option isCorrect> | ||||||
| Refaktorisierung, um eine wiederverwendbare Komponente zu nutzen | ||||||
| </Option> | ||||||
| <Option> | ||||||
| eine neue Seite erstellen | ||||||
| </Option> | ||||||
| </MultipleChoice> | ||||||
|
|
||||||
| 2. Astro-Komponenten sind: | ||||||
| <MultipleChoice> | ||||||
| <Option> | ||||||
| wiederverwendbar | ||||||
| </Option> | ||||||
| <Option> | ||||||
| Fragmente von HTML | ||||||
| </Option> | ||||||
| <Option isCorrect> | ||||||
| beides! | ||||||
| </Option> | ||||||
| </MultipleChoice> | ||||||
|
|
||||||
| 3. Astro-Komponenten erstellen automatisch eine neue Seite auf deiner Website, wenn du … | ||||||
| <MultipleChoice> | ||||||
| <Option> | ||||||
| `<html></html>` einfügst | ||||||
| </Option> | ||||||
| <Option> | ||||||
| refaktorisierst | ||||||
| </Option> | ||||||
| <Option isCorrect> | ||||||
| die `.astro`-Datei innerhalb von `src/pages/` ablegst | ||||||
| </Option> | ||||||
| </MultipleChoice> | ||||||
| </Box> | ||||||
|
|
||||||
| <Box icon="check-list"> | ||||||
|
|
||||||
| ## Checkliste | ||||||
|
|
||||||
| <Checklist> | ||||||
| - [ ] Ich kann Inhalte in wiederverwendbare Komponenten umwandeln. | ||||||
| - [ ] Ich kann eine neue Komponente zu einer `.astro`-Seite hinzufügen. | ||||||
| </Checklist> | ||||||
|
|
||||||
| </Box> | ||||||
|
|
||||||
| ### Ressourcen | ||||||
|
|
||||||
| - [Mehr über Astro-Komponenten](/de/basics/astro-components/) | ||||||
|
|
||||||
| - [Refactoring](https://refactoring.com/) <Badge class="neutral-badge" text="extern" /> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
All other badges stay in English, what should we use? I haven’t seen all badges yet, but we should decide on one.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ich hätte Badges eigentlich auch Übersetzt
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did it in a follow-up PR, this thread could be resolved 👍 |
||||||
Uh oh!
There was an error while loading. Please reload this page.