Ir al contenido

Una primera página, y una segunda ​

Traducción automática

Esta página se tradujo automáticamente del inglés y todavía no la revisó un hablante nativo; las correcciones son bienvenidas en GitHub. Si algo no coincide, vale el original en inglés.

Tarea: servir dos páginas que se enlazan entre sí.

yaml
# Recipe: two pages, each file of components/ at its own URL.
paths:
  components: ./components

Un archivo en components/ es una página, en la URL de su ruta: components/index.q responde a / y components/about.q responde a /about. Inicia el servidor con quantum start en la carpeta que tiene quantum.config.yaml.

xml
<q:component name="Home">
  <!-- components/index.q answers / -->
  <html>
  <head><title>Home</title></head>
  <body>
    <h1>Hello from Quantum</h1>
    <p>This page is components/index.q.</p>
    <a href="/about">About</a>
  </body>
  </html>
</q:component>
xml
<q:component name="About">
  <!-- components/about.q answers /about -->
  <html>
  <head><title>About</title></head>
  <body>
    <h1>About</h1>
    <p>A second page is a second file.</p>
    <a href="/">Home</a>
  </body>
  </html>
</q:component>

Una URL sin archivo responde 404:

xml
<q:test name="index.q answers /" page="/">
  <test:visit />
  <test:expect status="200" text="Hello from Quantum" />
</q:test>

<q:test name="about.q answers /about" page="/about">
  <test:visit />
  <test:expect text="A second page is a second file." />
</q:test>

<q:test name="a URL with no file is 404" page="/contact">
  <test:visit />
  <test:expect status="404" />
</q:test>
text
tests/pages.test.q
  PASS  index.q answers /
  PASS  about.q answers /about
  PASS  a URL with no file is 404
3 passed, 0 failed

Ver ROUTE-1.

Licencia MIT · Hecho con VitePress