Skip to content

Commit 906fad5

Browse files
Update README.md
1 parent e401ce1 commit 906fad5

File tree

1 file changed

+64
-41
lines changed

1 file changed

+64
-41
lines changed

README.md

Lines changed: 64 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,77 +43,57 @@ Example:
4343

4444
This will set up your project with the chosen theme and ensure **fast loading speeds** via CDN resources.
4545

46-
### 3. Add Components
46+
### 3. Serve Your Site for Development
4747

48-
To add pre-built, **pagespeed-optimized components** (such as a navigation bar or footer), navigate to your project directory:
48+
First, navigate to your project directory:
4949

5050
```bash
5151
cd ./projects/my-awesome-site
5252
```
5353

54-
Then run the following command to list all available MiniTemplate-Components that utilize **daisyUI**-Comnponents as HTML base. See [here](https://daisyui.com/components/button/):
54+
Then, to start the development server and preview your project, run:
5555

5656
```bash
57-
./run_add.sh
57+
./run_serve.sh
5858
```
5959

60-
You can choose between adding a template, a component or default components like sidebar, header, footer and navigation.
60+
You can now visit your site at [http://localhost:8000](http://localhost:8000) to view the served index.html.
6161

62-
```bash
63-
./run_add.sh [defaults|component|template]
64-
```
62+
### 4. Add a Component
6563

66-
Example:
64+
To customize your site, you can add components. Let’s add a button component to your project:
6765

68-
Add a Button to your project (button.html):
69-
```bash
70-
./run_add.sh button
71-
```
72-
Add a the default template file (template_default.html):
7366
```bash
74-
./run_add.sh template_default.html
75-
```
76-
Adds a set of default components like header, footer, sidebar and default template:
77-
```bash
78-
./run_add.sh defaults
67+
./scripts/run_add.sh button
7968
```
8069

81-
### 4. Generate the Site
70+
This command will generate a new `button.html` file in your project’s components folder. Now, you can use this component inside your template.
8271

83-
After adding components, generate the static HTML files using:
72+
### 5. Insert the Component in the Template
8473

85-
```bash
86-
./run_generate.sh
87-
```
74+
Open the `template_default.html` file located in your project’s templates folder. To include the newly added button component, find a suitable place within the template and add the following placeholder:
8875

89-
This will create or update the `index.html` file, with all components integrated.
76+
```html
77+
{{button}}
78+
```
9079

91-
### 5. Print the Site Structure
80+
### 6. Print the Updated Template
9281

93-
For a quick overview of your site structure, use the print command:
82+
You can print the updated template structure to verify your changes:
9483

9584
```bash
96-
./print.sh
85+
./scripts/print.sh
9786
```
9887

99-
### 6. Test Your Setup
88+
### 7. Re-generate the Site
10089

101-
To ensure everything is functioning properly, run the test scripts:
90+
After adding the component and updating the template, you need to re-create the index.html file to reflect your changes:
10291

10392
```bash
104-
bash run_tests.sh
105-
```
106-
107-
#### Example Output
108-
109-
```
110-
✔ Test passed: run_create_project.sh ran successfully.
111-
✔ Component 'navbar' added to 'my-awesome-site'.
112-
✔ Template generation test passed: 'index.html' created with the selected theme.
113-
✔ All tests passed successfully.
93+
./scripts/run_generate.sh
11494
```
11595

116-
Run these tests to validate that all components, templates, and scripts are working as intended.
96+
This will regenerate the `index.html` file with the newly integrated button component.
11797

11898
## Example Pre-Created Project Structure
11999

@@ -182,6 +162,49 @@ To further optimize your MiniTemplate project for production, you can follow the
182162

183163
By using PurgeCSS and enabling Tailwind JIT mode directly from the CDN, you can significantly reduce your CSS file size and boost your site's performance without needing any additional tools or setups.
184164

165+
## Testing Your Site
166+
167+
MiniTemplate provides built-in test scripts to verify the integrity and functionality of your site. Running the following command will initiate the test suite:
168+
169+
```bash
170+
bash run_tests.sh
171+
```
172+
173+
#### Example Output
174+
175+
```
176+
✔ Test passed: run_create_project.sh ran successfully.
177+
✔ Component 'navbar' added to 'my-awesome-site'.
178+
✔ Template generation test passed: 'index.html' created with the selected theme.
179+
✔ All tests passed successfully.
180+
```
181+
182+
## Component Structure
183+
184+
MiniTemplate’s components are modular, with **auto-generated IDs**, **scoped CSS**, and **collision-free JavaScript**. Here’s an example of how a component is structured, showcasing the best practices for performance and maintainability:
185+
186+
```html
187+
<div id="button_default" class="btn" aria-label="Button Component">
188+
Click Me
189+
<script>
190+
// Optional state management
191+
(() => {
192+
let clicked = false;
193+
document.getElementById('button_default').addEventListener('click', () => {
194+
clicked = !clicked;
195+
console.log('Button clicked:', clicked);
196+
});
197+
})();
198+
</script>
199+
</div>
200+
```
201+
202+
### Benefits:
203+
- **Auto-generated IDs** prevent conflicts.
204+
- **Scoped CSS** ensures that styles don't leak into other components.
205+
- **Collision-free JavaScript** using an Immediately Invoked Function Expression (IIFE) for encapsulation.
206+
- **Embedded Script** for optional state management, adding flexibility.
207+
185208
## Contribute
186209

187210
We welcome contributions from the community! If you’d like to contribute, please check the [CONTRIBUTING.md](./CONTRIBUTING.md) file for details on how to get started.

0 commit comments

Comments
 (0)