-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathContextPage.njs
More file actions
64 lines (54 loc) · 1.47 KB
/
ContextPage.njs
File metadata and controls
64 lines (54 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import Nullstack from 'nullstack'
class ContextPage extends Nullstack {
eventTriggered = false;
prepare({ page }) {
page.title = 'Nullstack Tests'
page.image = '/image.jpg'
page.description = 'Nullstack tests page that tests the context page'
page.locale = 'pt-BR'
page.robots = 'index, follow'
page.schema = {
'@type': 'WebSite',
'@id': '#website',
name: 'Nullstack',
url: 'https://nullstack.app',
}
page.changes = 'weekly'
page.priority = 1
}
hydrate({ page }) {
window.addEventListener(page.event, () => {
this.eventTriggered = true
})
}
static async raiseStatus({ response, status }) {
response.status(401)
return status
}
async requestStatus({ status }) {
await this.raiseStatus({ status })
}
updateHead({ page }) {
page.title = 'Nullstack Tests Updated'
page.image = '/image-updated.jpg'
page.description = 'Nullstack tests page that tests the context page updated'
page.locale = 'en-US'
}
render({ page }) {
return (
<div>
<div data-event-triggered={this.eventTriggered} />
<div data-page={!!page} />
<div data-changes={page.changes} />
<div data-priority={page.priority} />
<button onclick={this.requestStatus} data-request-status>
401
</button>
<button onclick={this.updateHead} data-update-head>
title
</button>
</div>
)
}
}
export default ContextPage