-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path[webform_id].tsx
More file actions
48 lines (44 loc) · 1.33 KB
/
[webform_id].tsx
File metadata and controls
48 lines (44 loc) · 1.33 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
import * as React from 'react';
import { resolveWebformContent, Webform } from 'nextjs-drupal-webform';
import { drupal } from '../../lib/drupal';
import { GetStaticPathsContext } from 'next/types';
import { GetStaticPathsResult } from 'next';
import { Layout } from '../../components/layout';
import { getMenus } from '../../lib/get-menus';
import { PageHeader } from '../../components/page-header';
export default function WebformSlug({ menus, webform, id }) {
return (
<Layout title={webform.title} menus={menus}>
<PageHeader heading={webform.title} />
<div className="container px-6 pb-10 mx-auto">
<Webform id={id} data={webform} />
</div>
</Layout>
);
}
export async function getStaticPaths(
context: GetStaticPathsContext,
): Promise<GetStaticPathsResult> {
const entities = await drupal.getResourceCollectionFromContext('webform--webform', context);
const paths = entities.map((entity) => {
return { params: { webform_id: entity.drupal_internal__id }}
});
return {
paths: [...paths],
fallback: false,
};
}
export async function getStaticProps(context) {
const webform = await resolveWebformContent(
context.params.webform_id,
drupal,
);
return {
props: {
webform,
id: context.params.webform_id,
menus: await getMenus(),
},
revalidate: 60,
};
}