Skip to content

Commit 477cdb6

Browse files
Merge branch 'main' into astro-pages
2 parents 3e27f8f + 5ad205f commit 477cdb6

2 files changed

Lines changed: 50 additions & 2 deletions

File tree

src/pages/en/reference/cli-reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ If you started your project using [the `create astro` wizard](/en/install/auto/#
5858

5959
Runs Astro's development server. This is a local HTTP server that doesn't bundle assets. It uses Hot Module Replacement (HMR) to update your browser as you save changes in your editor.
6060

61-
### Flags
61+
<h3>Flags</h3>
6262

6363
Use these flags to customize the behavior of the Astro dev server. For flags shared with other Astro commands, see [common flags](#common-flags) below.
6464

@@ -81,7 +81,7 @@ Do not use the `--host` flag to expose the dev server in a production environmen
8181

8282
Builds your site for deployment. By default, this will generate static files and place them in a `dist/` directory. If [SSR is enabled](/en/guides/server-side-rendering/), this will generate the necessary server files to serve your site.
8383

84-
### Flags
84+
<h3>Flags</h3>
8585

8686
Use these flags to customize your build. For flags shared with other Astro commands, see [common flags](#common-flags) below.
8787

src/pages/es/guides/markdown-content.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,34 @@ const { frontmatter } = Astro.props;
7777
</html>
7878
```
7979

80+
Puedes establecer los [tipos de `Props`](/es/guides/typescript/#props-de-componentes) de un layout con el helper `MarkdownLayoutProps`:
81+
```
82+
astro title="src/layouts/BaseLayout.astro" ins={2,4-9}
83+
---
84+
import type { MarkdownLayoutProps } from 'astro';
85+
type Props = MarkdownLayoutProps<{
86+
// Acá defines las props del frontmatter
87+
title: string;
88+
author: string;
89+
date: string;
90+
}>;
91+
// Ahora, `frontmatter`, `url` y otras propiedades del layout en Markdown
92+
// son accesibles con seguridad de tipos
93+
const { frontmatter, url } = Astro.props;
94+
---
95+
<html>
96+
<head>
97+
<meta rel="canonical" href={new URL(url, Astro.site).pathname}>
98+
<title>{frontmatter.title}</title>
99+
</head>
100+
<body>
101+
<h1>{frontmatter.title} por {frontmatter.author}</h1>
102+
<slot />
103+
<p>Escrito en: {frontmatter.date}</p>
104+
</body>
105+
</html>
106+
```
107+
80108
### Props de la plantilla de Markdown
81109

82110
:::note
@@ -556,3 +584,23 @@ Cuando uses Prism, deberás agregar una hoja de estilos a tu proyecto para resal
556584
4. Cargar esta en el [`<head>` de su página](/es/core-concepts/astro-pages/#páginas-html) a través de una etiqueta `<link>`.
557585

558586
También puedes visitar la [lista de lenguajes de programación soportados por Prism](https://prismjs.com/#supported-languages) para conocer las opciones y su uso.
587+
588+
## Fetching de Markdown Remoto
589+
590+
Astro fue diseñado principalmente para archivos Markdown locales que podrían ser guardados dentro del directorio del proyecto. Sin embargo, pueden ocurrir casos donde necesites obtener Markdown de una fuente remota. Por ejemplo, puedes necesitar hacer fetching y renderizar Markdown de una API remota al estar construyendo un sitio web (o cuando el usuario ejecute una request a su página, al usar [SSR](/es/guides/server-side-rendering/)).
591+
592+
**¡Astro no incluye soporte para Markdown remoto!**. Para hacer fetching de Markdown remoto y renderizarlo a HTML, necesitarás instalar y configurar tu propio parser de Markdown desde npm. Este **no** heredará ajustes que hayas configurado del Markdown y MDX de Astro. Asegúrate de comprender estas limitaciones antes de implementar esto en tu proyecto.
593+
594+
```
595+
astro title="src/pages/remote-example.astro"
596+
---
597+
// Ejemplo: Fetching Markdown de una API remota
598+
// y renderizarlo a HTML al ser ejecutado
599+
// Usando "marked" (https://github.com/markedjs/marked)
600+
import { marked } from 'marked';
601+
const response = await fetch('https://raw.githubusercontent.com/wiki/adam-p/markdown-here/Markdown-Cheatsheet.md');
602+
const markdown = await response.text();
603+
const content = marked.parse(markdown);
604+
---
605+
<article set:html={content} />
606+
```

0 commit comments

Comments
 (0)