Pular para o conteúdo

Uma primeira página, e uma segunda ​

Tradução automática

Esta página foi traduzida automaticamente do inglês e ainda não foi revisada por um falante nativo; correções são bem-vindas no GitHub. Se algo não bater, vale o original em inglês. O código e os resultados são os mesmos do original, importados dos arquivos testados.

Tarefa: servir duas páginas com links uma para a outra.

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

Um arquivo em components/ é uma página, na URL do seu caminho: components/index.q responde em / e components/about.q responde em /about. Inicie o servidor com quantum start na pasta que tem o 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>

Uma URL sem arquivo 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

Veja ROUTE-1.

Licença MIT · Feito com VitePress