Finish steps 1-3 on the home page to learn about creating pages and navigation links.
4. Edit Page Content
To edit content on a page, go to its file in the pages folder. If you're following along with the demo, this is an "About Me" page with the wrong title. Let's change that.
To edit the title of this page:
Open the about-me file created in step 1.
Find the first <Heading> component in the file. It will have the words Template Page inside the <Heading> tags.
Replace the words Template Page with About Me.
Once you save your work, the page title will change to "About Me"!
More Details
You can verify the page's corresponding file name by looking at its URL. For example, to edit a page with a /about-me URL, edit the about-me.js file.
If you have trouble finding a component on a page, search for it using ctrl/cmd + f.
5. Add New Content
A Paste component must be imported at the top of a file to be used in that file (and show up on that page). Go to the Paste Docsfor a full list of components you can add.
To practice, let's add in a <Separator> component
To add a component to the "About Me" page:
Find the import statements at the top of the about-me.js file.
Add the new component's import statement below the existing ones. For the <Separator> component, this statement is import { Separator } from '@twilio-paste/core/separator';
Add the component itself into the code. For the <Separator> component, make a new line after the closing tag of the Heading component you edited in step 3 (looks like </Heading>). Then copy the following code and paste it into the new line: <Separator orientation="horizontal" verticalSpacing="space50" />
Once you save your work, a thin, horizontal separator line will appear beneath your heading!
More Details
You can adjust components by changing their properties, also called props. In the Separator component, verticalSpacing is a prop. Adjust it to "space100" instead of "space50" to see what happens. More about Separator
Be careful when adding content from one page to another. You must have import statements for every component used on a page. When copying and pasting patterns, include the imports.
6. Connect Pages Internally
Connect different pages in this kit to each other by using the <PrototypeAnchor> component to create links.
To practice, let's add a link to this page that leads back to the "Home" page.
To add a link in the "About Me" page for the "Home" page:
Create a new line under the closing tag of the <Heading> component in the about-me.js file.
Add the <PrototypeAnchor> component by copying the following code and pasting it into the new line:<PrototypeAnchor></PrototypeAnchor>
Add the text of the link to the inside of the <PrototypeAnchor> component tags. For a link that says "Go to Home", the component should now read: <PrototypeAnchor>Go to Home</PrototypeAnchor>
Add a reference for the page the link leads to. The home page has the reference "/". Specify the reference by adding href="/" inside of the opening <PrototypeAnchor> component tag. It should now read: <PrototypeAnchor href="/">Go to Home</PrototypeAnchor>
Save your work and click on the link to check that it works!
More Details
References to internal pages (pages in this kit) match the file structure of the pages folder. For example:
"/about-me" refers to the page made by the about-me.js file. You can link to it by using href="/about-me".
For nested pages, include the name of the parent folder before the name of the child page. For example: href="/phone-numbers/active-numbers" would refer to a page made by a active-numbers.js file inside of a phone-numbers folder (all this inside the pages folder).
To link to an external page, include the string showExternal inside of the opening <PrototypeAnchor> component tag, and refer to the full URL of the page you're linking to. The component for an external link to the Paste Docs looks like: <PrototypeAnchor showExternal href="https://paste.twilio.design/">The Paste Docs</PrototypeAnchor>
Make sure that an import statement exists for the <PrototypeAnchor> component before using it. This component is specific to the prototyping kit, so its import statement will look a little different. Use this code snippet if there is no import statement for the <PrototypeAnchor> component in your file:import { PrototypeAnchor } from '../components/site/PrototypeAnchor';. Note: this import statement will need to be adjusted for nested "child" pages to include another "../" at the beginning of the string following from.
7. Check Out Patterns
Reusable patterns are created from putting many components together for a specific use.