Pages and data
In the SOURCE toolkit, every page is a TSX file that reads its content from JSON. What several pages share, the menus or the projects, is written once in a data file, and the build prints it into every page that shows it. Run npm run dev while you edit, and npm run build when you are done: SOURCE toolkit.
How to access
SOURCE/src
| Where | What it holds |
|---|---|
pages/<name>.tsx | One file per page: studio.tsx builds studio.html |
data/site.json | What every page shares: the menus, the logo, the footer |
data/projects.json, data/posts.json | The portfolio and the blog, one record per project or post |
data/pages/<name>.json | The content of one page: its texts, pictures, buttons |
partials/ | The parts the pages are made of, each printing the markup its component needs |
Changing a text in the data
A page's own content is in data/pages/, in lists by kind and, in each list, in the order the page shows it. The Studio page's first text is the label of its founder's section:
json
{
"texts": [
"From the founder",
"I'm Gabriel. I spent six years in large practices…",Save, and the dev server reloads the page with the new text. The page's TSX says which entry goes where: at(texts, 0, 'text') is the first one.
Writing a text straight into the page
Some texts are written in the TSX itself, such as a page's title. Change them there, or replace a value read from the data with your own words:
tsx
<section class="mt-header">
<MastheadBanner title="About us" rule />
</section>Changing the menu on every page
The burger menu is menu.items in data/site.json: each item a title, an href, the image it shows when hovered and its children. Change it once, build, and all the pages carry the change. The build numbers the items and their pictures itself.
json
{
"title": "Blog",
"href": "journal.html",Adding a project
▶️ Step 1.
Add its record to data/projects.json, in the place it should take among the others: its slug, title, href (project-<slug>.html), category, year, location, description and picture. Copying the record of the project before it is the shortest way.
▶️ Step 2.
Copy that project's page file, such as pages/project-casa-notte.tsx to pages/project-casa-lumen.tsx, and point it at the new record:
tsx
const PROJECT = project('casa-lumen')Give it a content file of its own in data/pages/ when its texts and pictures differ, and change the import at its top to read it.
The build then puts the project in every archive, with the counts and the filters, in the sliders that list projects, and in the footer of the project before it. The burger menu lists only the projects in data/site.json: add it there too if it belongs in the menu.
Removing a page
Delete its file in src/pages/, and its item in data/site.json if the menu has one. Every link to it then prints # until you point it somewhere else. The build does not delete the old page from the HTML folder: delete it there by hand. Some pages build on another: the second and third pages of an archive read the first, so delete them together.
What a page may not hold
A page may not carry a style attribute or a <script> with its code inside: the build stops and names the page:
Error: [velum-html] studio.html prints a style attribute: a look is a class, a computed value a data attribute (build/values.ts)A look goes into a class in the Sass (Sass), and a script into a file of its own, such as js/custom.js.
Next: Sass.