Defining Common Content
Common content is exclusive to a particular directory. To define common content, follow the steps below:
1. Create an HTML file
Create an HTML file where you can store the common content:
/common/demo.html <li>Common content</li>
2. Add an element with an exclusive identifier
Include an element with an exclusive identifier and leave it empty in your website pages:
/directory-name/demo.html <body>
<aside id="common-content"></aside>
</body>
3. Update the propose.json file
Take the identifier of the element and the targeted directory path, then place it into the propose.json file:
/propose.json {
"common": { "#common-content": "/directory-name" }
}
Note
- You can create multiple common content proposals.
- Every possible page must have the element with the identifier proposed as a common content element.
Alert
Don't use the target attribute with the <a href=""> tag unless you want to navigate the visitor outside of this website.
How It Works
Common content helps to maintain the website and prevent writing the same content multiple times. Common content executes only when the window directory and proposal directory match. Once the common directory executes, the ProposeJS engine observes the directory. If the previous directory and recent directory are the same, then common content will not execute because it is common for this directory. If the directory path changes, whether forward or backward, ProposeJS common content will execute. The ProposeJS engine will expect common content for every individual directory if you declare common content in propose.json. This is why you need to make proposals for common content for every possible directory.
Common content is ideal for sidebars or content that needs to change depending on different directories.