A first page, and a second
Task: serve two pages that link to each other.
yaml
# Recipe: two pages, each file of components/ at its own URL.
paths:
components: ./componentsA file in components/ is a page, at the URL of its path: components/index.q answers / and components/about.q answers /about. Start the server with quantum start in the folder that has 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>A URL with no file answers 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 failedSee ROUTE-1.