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
Copy file name to clipboardExpand all lines: README.md
+72-9Lines changed: 72 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -169,30 +169,93 @@ const head = new HeadBuilder({
169
169
170
170
### With Templated Title
171
171
172
-
Set a title template once and dynamically update titles on different pages:
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
173
174
174
```typescript
175
175
import { HeadBuilder } from'@devsantara/head';
176
176
177
-
// Shared head
177
+
// Create a builder and set title template with default
178
+
// The template stays active for all future addTitle() calls
178
179
const sharedHead =newHeadBuilder().addTitle({
179
-
template: '%s | My Awesome site', //<- Set title template
180
-
default: 'Home',
180
+
template: '%s | My Awesome site', //Store template (%s is the placeholder)
181
+
default: 'Home',// Initial title using template
181
182
});
182
-
183
-
// Home page
184
-
const homeHead =sharedHead;
185
183
// Output: <title>Home | My Awesome site</title>
186
184
187
-
// Posts page
185
+
// Update title for Posts page
186
+
// Pass a string, builder applies the saved template automatically
0 commit comments