-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
i18n(de): translate tutorial section 5 #12501
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
Open
trueberryless
wants to merge
35
commits into
withastro:de/tutorial
Choose a base branch
from
trueberryless:de-tutorial-section-5
base: de/tutorial
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
6dd2f6d
de(i18n): translate page 1: section 5 of 6
trueberryless 5ef9470
i18n(de): translate page index: section 5 of 6
trueberryless ec2e513
i18n(de): translate page 2: section 5 of 6
trueberryless 07da0d9
fix: better translation
trueberryless 915172b
Merge branch 'de/tutorial' into de-tutorial-section-5
trueberryless b15d100
i18n(de): translate page 4: section 5 of 6
trueberryless b882027
i18n(de): translate page 3: section 5 of 6
trueberryless 992b77d
Update src/content/docs/de/tutorial/5-astro-api/1.mdx
trueberryless f42c093
Update src/content/docs/de/tutorial/5-astro-api/1.mdx
trueberryless 4b798f1
Apply suggestion from @trueberryless
trueberryless 99427a5
Apply suggestion from @randomguy-2650
trueberryless ba4cfe4
Apply suggestion from @randomguy-2650
trueberryless 3508ea2
fix: remove empty line
trueberryless 351ff64
Apply suggestion from @trueberryless
trueberryless 996e056
Update src/content/docs/de/tutorial/5-astro-api/1.mdx
trueberryless 8827c69
Update src/content/docs/de/tutorial/5-astro-api/2.mdx
trueberryless 6daec25
Update src/content/docs/de/tutorial/5-astro-api/2.mdx
trueberryless 26b9cd5
Update src/content/docs/de/tutorial/5-astro-api/2.mdx
trueberryless a08f404
Update src/content/docs/de/tutorial/5-astro-api/2.mdx
trueberryless 7c8d8e0
Apply suggestion from @trueberryless
trueberryless 69e18b3
Update src/content/docs/de/tutorial/5-astro-api/3.mdx
trueberryless f5066c5
Apply suggestion from @trueberryless
trueberryless a17ffc3
Update src/content/docs/de/tutorial/5-astro-api/3.mdx
trueberryless 99eaa0d
Merge branch 'de/tutorial' into de-tutorial-section-5
trueberryless a61c4a9
Merge branch 'de/tutorial' into de-tutorial-section-5
yanthomasdev 3101bc2
Update src/content/docs/de/tutorial/5-astro-api/1.mdx
trueberryless bf91e2b
Update src/content/docs/de/tutorial/5-astro-api/2.mdx
trueberryless 676f4e9
Update src/content/docs/de/tutorial/5-astro-api/4.mdx
trueberryless b87132d
Merge branch 'de/tutorial' into de-tutorial-section-5
trueberryless 62b1834
Update src/content/docs/de/tutorial/5-astro-api/2.mdx
trueberryless 12b773e
Update src/content/docs/de/tutorial/5-astro-api/4.mdx
trueberryless 3bdb94a
Update src/content/docs/de/tutorial/5-astro-api/4.mdx
trueberryless 8b27e7b
Update src/content/docs/de/tutorial/5-astro-api/4.mdx
trueberryless 5e6fc6b
docs: update with recent changes
trueberryless b885cb1
Update src/content/docs/de/tutorial/5-astro-api/4.mdx
trueberryless File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,251 @@ | ||
--- | ||
type: tutorial | ||
title: Blog-Beitragsarchiv erstellen | ||
description: |- | ||
Tutorial: Erstelle deinen ersten Astro-Blog — | ||
Nutze import.meta.glob(), um auf Daten aus Dateien in deinem Projekt zuzugreifen | ||
i18nReady: true | ||
--- | ||
|
||
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'; | ||
|
||
Jetzt, wo du ein paar Blog-Beiträge hast, die du verlinken kannst, ist es Zeit, die Blog-Seite so einzurichten, dass automatisch eine Liste davon erstellt wird! | ||
|
||
<PreCheck> | ||
- Greife mit `import.meta.glob()` auf die Daten aller deiner Beiträge gleichzeitig zu | ||
- Zeige eine dynamisch generierte Liste der Beiträge auf deiner Blog-Seite an | ||
- Überarbeite den Code, um für jedes Listenelement eine `<BlogPost />`-Komponente zu verwenden | ||
</PreCheck> | ||
|
||
## Dynamische Anzeige einer Liste von Beiträgen | ||
|
||
<Steps> | ||
1. Füge den folgenden Code zu `blog.astro` hinzu, um Infos zu all deinen Markdown-Dateien zurückzugeben. | ||
`import.meta.glob()` gibt ein Array von Objekten zurück, wobei jedes einem Blogbeitrag entspricht. | ||
|
||
```astro title="src/pages/blog.astro" ins={3} | ||
--- | ||
import BaseLayout from '../layouts/BaseLayout.astro' | ||
const allPosts = Object.values(import.meta.glob('./posts/*.md', { eager: true })); | ||
const pageTitle = "Mein Astro-Lernblog"; | ||
--- | ||
<BaseLayout pageTitle={pageTitle}> | ||
<p>Hier werde ich über meine Erfahrungen beim Lernen von Astro berichten.</p> | ||
<ul> | ||
<li><a href="/posts/post-1/">Beitrag 1</a></li> | ||
<li><a href="/posts/post-2/">Beitrag 2</a></li> | ||
<li><a href="/posts/post-3/">Beitrag 3</a></li> | ||
</ul> | ||
</BaseLayout> | ||
``` | ||
|
||
2. Um die ganze Liste der Beiträge dynamisch zu erstellen, indem du die Beitragstitel und URLs nutzt, ersetze deine einzelnen `<li>`-Tags durch den folgenden Astro-Code: | ||
|
||
```astro title="src/pages/blog.astro" del={9,10,11} ins= {13} | ||
--- | ||
import BaseLayout from '../layouts/BaseLayout.astro' | ||
const allPosts = Object.values(import.meta.glob('./posts/*.md', { eager: true })); | ||
const pageTitle = "Mein Astro-Lernblog"; | ||
--- | ||
<BaseLayout pageTitle={pageTitle}> | ||
<p>Hier werde ich über meine Erfahrungen beim Lernen von Astro berichten.</p> | ||
<ul> | ||
<li><a href="/posts/post-1/">Beitrag 1</a></li> | ||
<li><a href="/posts/post-2/">Beitrag 2</a></li> | ||
<li><a href="/posts/post-3/">Beitrag 3</a></li> | ||
|
||
{allPosts.map((post: any) => <li><a href={post.url}>{post.frontmatter.title}</a></li>)} | ||
</ul> | ||
</BaseLayout> | ||
``` | ||
|
||
Deine ganze Liste von Blog-Beiträgen wird jetzt dynamisch mit der integrierten TypeScript-Unterstützung von Astro generiert, indem das von `import.meta.glob()` zurückgegebene Array zugeordnet wird. | ||
|
||
3. Füge einen neuen Blogbeitrag hinzu, indem du eine neue Datei `post-4.md` in `src/pages/posts/` erstellst und einige Markdown-Inhalte hinzufügst. | ||
Achte darauf, dass du mindestens die unten verwendeten Frontmatter-Eigenschaften einfügst. | ||
|
||
```markdown | ||
--- | ||
layout: ../../layouts/MarkdownPostLayout.astro | ||
title: Mein vierter Blogbeitrag | ||
author: Astro-Lernender | ||
description: "Dieser Beitrag wird eigenständig angezeigt!" | ||
image: | ||
url: "https://docs.astro.build/default-og-image.png" | ||
alt: "Das Wort 'astro' vor einer Illustration von Planeten und Sternen." | ||
pubDate: 2022-08-08 | ||
tags: ["astro", "successes"] | ||
--- | ||
Dieser Beitrag sollte zusammen mit meinen anderen Blogbeiträgen angezeigt werden, weil `import.meta.glob()` eine Liste aller meiner Beiträge zurückgibt, um meine Liste zu erstellen. | ||
``` | ||
|
||
4. Schau dir deine Blog-Seite in der Browser-Vorschau unter `http://localhost:4321/blog` an und such nach einer aktualisierten Liste mit vier Einträgen, darunter dein neuer Blogbeitrag! | ||
</Steps> | ||
|
||
<Box icon="puzzle-piece"> | ||
|
||
## Challenge: Erstelle eine BlogPost-Komponente | ||
|
||
Versuch selbst, alle notwendigen Änderungen an deinem Astro-Projekt vorzunehmen, damit du stattdessen den folgenden Code verwenden kannst, um deine Liste mit Blogbeiträgen zu erstellen: | ||
|
||
```astro title="src/pages/blog.astro" del={2} ins={3} | ||
<ul> | ||
{allPosts.map((post: any) => <li><a href={post.url}>{post.frontmatter.title}</a></li>)} | ||
{allPosts.map((post: any) => <BlogPost url={post.url} title={post.frontmatter.title} />)} | ||
</ul> | ||
``` | ||
|
||
<details> | ||
<summary>Erweitere, um die Schritte anzuzeigen</summary> | ||
|
||
<Steps> | ||
1. Erstelle eine neue Komponente in `src/components/`. | ||
|
||
<details> | ||
<summary>Zeige den Dateinamen an</summary> | ||
``` | ||
BlogPost.astro | ||
``` | ||
</details> | ||
|
||
2. Schreib die Codezeile in deine Komponente, damit sie einen `title` und eine `url` als `Astro.props` empfangen kann. | ||
|
||
<details> | ||
<summary>Code anzeigen</summary> | ||
```astro | ||
--- | ||
// src/components/BlogPost.astro | ||
const { title, url } = Astro.props; | ||
--- | ||
``` | ||
</details> | ||
|
||
3. Füge die Vorlage hinzu, mit der du jedes Element in deiner Blogpost-Liste erstellst. | ||
|
||
<details> | ||
<summary>Code anzeigen</summary> | ||
```astro | ||
<!-- src/components/BlogPost.astro --> | ||
<li><a href={url}>{title}</a></li> | ||
``` | ||
</details> | ||
|
||
4. Importiere die neue Komponente in deine Blog-Seite. | ||
|
||
<details> | ||
<summary>Code anzeigen</summary> | ||
```astro title="src/pages/blog.astro" ins={3} | ||
--- | ||
import BaseLayout from '../layouts/BaseLayout.astro'; | ||
import BlogPost from '../components/BlogPost.astro'; | ||
const allPosts = Object.values(import.meta.glob('../pages/posts/*.md', { eager: true })); | ||
const pageTitle = "Mein Astro-Lernblog"; | ||
--- | ||
``` | ||
</details> | ||
|
||
5. Überprüfe es selbst: Schau dir den fertigen Komponentencode an. | ||
|
||
<details> | ||
<summary>Code anzeigen</summary> | ||
```astro title="src/components/BlogPost.astro" | ||
--- | ||
const { title, url } = Astro.props | ||
--- | ||
<li><a href={url}>{title}</a></li> | ||
``` | ||
```astro title="src/pages/blog.astro" ins={3,10} | ||
--- | ||
import BaseLayout from '../layouts/BaseLayout.astro'; | ||
import BlogPost from '../components/BlogPost.astro'; | ||
const allPosts = Object.values(import.meta.glob('../pages/posts/*.md', { eager: true })); | ||
const pageTitle = "Mein Astro-Lernblog"; | ||
--- | ||
<BaseLayout pageTitle={pageTitle}> | ||
<p>Hier werde ich über meine Erfahrungen beim Lernen von Astro berichten.</p> | ||
<ul> | ||
{allPosts.map((post: any) => <BlogPost url={post.url} title={post.frontmatter.title} />)} | ||
</ul> | ||
</BaseLayout> | ||
``` | ||
</details> | ||
</Steps> | ||
</details> | ||
</Box> | ||
|
||
<Box icon="question-mark"> | ||
|
||
### Test dein Wissen | ||
|
||
Wenn deine Astro-Komponente die folgende Codezeile enthält: | ||
|
||
```astro | ||
--- | ||
const myPosts = Object.values(import.meta.glob('./posts/*.md', { eager: true })); | ||
--- | ||
``` | ||
|
||
Wähle die Syntax, die du schreiben könntest, um Folgendes darzustellen: | ||
|
||
1. Den Titel deines dritten Blogbeitrags. | ||
|
||
<MultipleChoice> | ||
<Option> | ||
`myPosts.map((post) => <LastUpdated date={post.frontmatter.pubDate} />)` | ||
</Option> | ||
<Option isCorrect> | ||
`myPosts[2].frontmatter.title` | ||
</Option> | ||
<Option> | ||
`<a href={myPosts[0].url}>Erster Beitrag!!</a>` | ||
</Option> | ||
</MultipleChoice> | ||
|
||
2. Einen Link zur URL deines ersten Blogbeitrags. | ||
|
||
<MultipleChoice> | ||
<Option> | ||
`myPosts.map((post) => <LastUpdated date={post.frontmatter.pubDate} />)` | ||
</Option> | ||
<Option> | ||
`myPosts[2].frontmatter.title` | ||
</Option> | ||
<Option isCorrect> | ||
`<a href={myPosts[0].url}>Erster Beitrag!!</a>` | ||
</Option> | ||
</MultipleChoice> | ||
|
||
3. Eine Komponente für jeden Beitrag, die das Datum der letzten Aktualisierung anzeigt. | ||
|
||
<MultipleChoice> | ||
<Option isCorrect> | ||
`myPosts.map((post) => <LastUpdated date={post.frontmatter.pubDate} />)` | ||
</Option> | ||
<Option> | ||
`myPosts[2].frontmatter.title` | ||
</Option> | ||
<Option> | ||
`<a href={myPosts[0].url}>Erster Beitrag!!</a>` | ||
</Option> | ||
</MultipleChoice> | ||
|
||
</Box> | ||
|
||
## Checkliste | ||
|
||
<Box icon="check-list"> | ||
|
||
<Checklist> | ||
- [ ] Ich kann Daten aus meinen lokalen Dateien abfragen. | ||
- [ ] Ich kann eine Liste aller meiner Blog-Beiträge anzeigen. | ||
</Checklist> | ||
</Box> | ||
|
||
### Ressourcen | ||
|
||
- [Importieren von Glob-Mustern in Astro](/de/guides/imports/#importmetaglob) | ||
Check failure on line 251 in src/content/docs/de/tutorial/5-astro-api/1.mdx
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.