data | ||
scripts | ||
.DS_Store | ||
index.html | ||
LICENSE | ||
README.md | ||
style.css |
Dynamic Content Delivery
A static website that returns appropriate content to the website user based on the provided ID.
Which files am I allowed to edit?
- template section of index.html
- all files in
data
directory:
How to use
Firstly, create template for your webpage. Go to index.html and edit code only between these lines:
<!-- TEMPLATE BEGINS -->
<!-- TEMPLATE ENDS -->
This is the template section of the HTML file.
Example:
<!-- TEMPLATE BEGINS -->
<p id="name">Hi!</p>
<!-- TEMPLATE ENDS -->
Then, prepare your API:
-
Clone this repository.
-
Edit [data/data-source.json] file:
- provide your data in
DATA
constant like this:
const DATA = { "id1": { "#name": { "textContent": "John", "style": { "color": "red" } } }, "id2": { "#name": { "textContent": "Anna", "style": { "color": "blue" } } }, ... }
- edit your [data/config.json]:
- provide your API host in
API_HOST
constant. - provide your API port in
PORT
constant.
- provide your API host in
Warning! Do not change the structure of the
DATA
object. It must be an object with keys being IDs and values, which are objects with CSS selectors as keys and objects with DOM properties as values. Make sure that your API is running on the same port as the one provided inPORT
constant. - provide your data in
-
Deploy your API:
- Install Node.js and npm.
- Run
npm install
in the root directory of the API. - Run
npm start
in the root directory of the API.
Custom styles
This website supports custom CSS. Just edit this file.
If provided style doesn't work, try adding !important
to the end of CSS rule.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Authors
- @sadorowo - original author