You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -140,6 +167,95 @@ const head = new HeadBuilder({
140
167
];
141
168
```
142
169
170
+
### With Templated Title
171
+
172
+
Set a title template with a default value, then pass page-specific titles as strings. The builder automatically applies the saved template to subsequent title updates:
173
+
174
+
```typescript
175
+
import { HeadBuilder } from'@devsantara/head';
176
+
177
+
// Create a builder and set title template with default
178
+
// The template stays active for all future addTitle() calls
179
+
const sharedHead =newHeadBuilder().addTitle({
180
+
template: '%s | My Awesome site', // Store template (%s is the placeholder)
181
+
default: 'Home', // Initial title using template
182
+
});
183
+
// Output: <title>Home | My Awesome site</title>
184
+
185
+
// Update title for Posts page
186
+
// Pass a string, builder applies the saved template automatically
|`addTitle(title: string \| TitleOptions)`| Adds a `<title>` element with optional templating |
344
+
|`addMeta(attributes: HeadAttributeTypeMap['meta'])`| Adds a `<meta>` element with custom attributes|
345
+
|`addLink(href: string \| URL, attributes?)`| Adds a `<link>` element with a URL and custom attributes|
346
+
|`addScript(srcOrCode: string \| URL \| { code: string }, attributes?)`| Adds a `<script>` element (external file with string/URL or inline with `{ code: string }`)|
347
+
|`addStyle(css: string, attributes?)`| Adds a `<style>` element with inline CSS |
0 commit comments