Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
f58b74df
Commit
f58b74df
authored
3 years ago
by
Kevin Wang
Browse files
Options
Download
Email Patches
Plain Diff
chore: use getStaticGenerationFunctions
parent
2c5b8e4b
Branches unavailable
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
website/pages/api-docs/[[...page]].jsx
+21
-33
website/pages/api-docs/[[...page]].jsx
website/pages/docs/[[...page]].jsx
+21
-32
website/pages/docs/[[...page]].jsx
website/pages/intro/[[...page]].jsx
+21
-33
website/pages/intro/[[...page]].jsx
with
63 additions
and
98 deletions
+63
-98
website/pages/api-docs/[[...page]].jsx
+
21
-
33
View file @
f58b74df
import
{
productName
,
productSlug
}
from
'
data/metadata
'
import
DocsPage
from
'
@hashicorp/react-docs-page
'
import
{
generateStaticPaths
,
generateStaticProps
,
}
from
'
@hashicorp/react-docs-page/server
'
import
{
getStaticGenerationFunctions
}
from
'
@hashicorp/react-docs-page/server
'
const
NAV_DATA_FILE
=
'
data/api-docs-nav-data.json
'
const
CONTENT_DIR
=
'
content/api-docs
'
...
...
@@ -15,37 +12,28 @@ export default function DocsLayout(props) {
product
=
{
{
name
:
productName
,
slug
:
productSlug
}
}
baseRoute
=
{
basePath
}
staticProps
=
{
props
}
showVersionSelect
=
{
true
}
showVersionSelect
=
{
process
.
env
.
ENABLE_VERSIONED_DOCS
===
'
true
'
}
/>
)
}
export
async
function
getStaticPaths
()
{
return
{
fallback
:
'
blocking
'
,
paths
:
await
generateStaticPaths
({
navDataFile
:
NAV_DATA_FILE
,
localContentDir
:
CONTENT_DIR
,
product
:
{
name
:
productName
,
slug
:
productSlug
},
basePath
:
basePath
,
}),
}
}
export
async
function
getStaticProps
({
params
})
{
try
{
return
{
revalidate
:
10
,
props
:
await
generateStaticProps
({
params
,
navDataFile
:
NAV_DATA_FILE
,
localContentDir
:
CONTENT_DIR
,
product
:
{
name
:
productName
,
slug
:
productSlug
},
const
{
getStaticPaths
,
getStaticProps
}
=
getStaticGenerationFunctions
(
process
.
env
.
ENABLE_VERSIONED_DOCS
===
'
true
'
?
{
strategy
:
'
remote
'
,
basePath
:
basePath
,
}),
}
}
catch
(
err
)
{
console
.
warn
(
err
)
return
{
notFound
:
true
}
}
}
fallback
:
'
blocking
'
,
revalidate
:
360
,
// 1 hour
product
:
productSlug
,
}
:
{
strategy
:
'
fs
'
,
basePath
:
basePath
,
localContentDir
:
CONTENT_DIR
,
navDataFile
:
NAV_DATA_FILE
,
product
:
productSlug
,
revalidate
:
false
,
}
)
export
{
getStaticPaths
,
getStaticProps
}
This diff is collapsed.
Click to expand it.
website/pages/docs/[[...page]].jsx
+
21
-
32
View file @
f58b74df
import
{
productName
,
productSlug
}
from
'
data/metadata
'
import
DocsPage
from
'
@hashicorp/react-docs-page
'
import
{
generateStaticPaths
,
generateStaticProps
,
}
from
'
@hashicorp/react-docs-page/server
'
import
{
getStaticGenerationFunctions
}
from
'
@hashicorp/react-docs-page/server
'
import
Placement
from
'
components/placement-table
'
const
NAV_DATA_FILE
=
'
data/docs-nav-data.json
'
...
...
@@ -18,36 +15,28 @@ export default function DocsLayout(props) {
baseRoute
=
{
basePath
}
staticProps
=
{
props
}
additionalComponents
=
{
additionalComponents
}
showVersionSelect
=
{
true
}
showVersionSelect
=
{
process
.
env
.
ENABLE_VERSIONED_DOCS
===
'
true
'
}
/>
)
}
export
async
function
getStaticPaths
()
{
return
{
fallback
:
'
blocking
'
,
paths
:
await
generateStaticPaths
({
navDataFile
:
NAV_DATA_FILE
,
localContentDir
:
CONTENT_DIR
,
product
:
{
name
:
productName
,
slug
:
productSlug
},
basePath
:
basePath
,
}),
}
}
export
async
function
getStaticProps
({
params
})
{
try
{
return
{
revalidate
:
10
,
props
:
await
generateStaticProps
({
params
,
navDataFile
:
NAV_DATA_FILE
,
localContentDir
:
CONTENT_DIR
,
product
:
{
name
:
productName
,
slug
:
productSlug
},
const
{
getStaticPaths
,
getStaticProps
}
=
getStaticGenerationFunctions
(
process
.
env
.
ENABLE_VERSIONED_DOCS
===
'
true
'
?
{
strategy
:
'
remote
'
,
basePath
:
basePath
,
}),
}
}
catch
(
err
)
{
console
.
warn
(
err
)
return
{
notFound
:
true
}
}
}
fallback
:
'
blocking
'
,
revalidate
:
360
,
// 1 hour
product
:
productSlug
,
}
:
{
strategy
:
'
fs
'
,
basePath
:
basePath
,
localContentDir
:
CONTENT_DIR
,
navDataFile
:
NAV_DATA_FILE
,
product
:
productSlug
,
revalidate
:
false
,
}
)
export
{
getStaticPaths
,
getStaticProps
}
This diff is collapsed.
Click to expand it.
website/pages/intro/[[...page]].jsx
+
21
-
33
View file @
f58b74df
import
{
productName
,
productSlug
}
from
'
data/metadata
'
import
DocsPage
from
'
@hashicorp/react-docs-page
'
import
{
generateStaticPaths
,
generateStaticProps
,
}
from
'
@hashicorp/react-docs-page/server
'
import
{
getStaticGenerationFunctions
}
from
'
@hashicorp/react-docs-page/server
'
const
NAV_DATA_FILE
=
'
data/intro-nav-data.json
'
const
CONTENT_DIR
=
'
content/intro
'
...
...
@@ -15,37 +12,28 @@ export default function DocsLayout(props) {
product
=
{
{
name
:
productName
,
slug
:
productSlug
}
}
baseRoute
=
{
basePath
}
staticProps
=
{
props
}
showVersionSelect
=
{
true
}
showVersionSelect
=
{
process
.
env
.
ENABLE_VERSIONED_DOCS
===
'
true
'
}
/>
)
}
export
async
function
getStaticPaths
()
{
return
{
fallback
:
'
blocking
'
,
paths
:
await
generateStaticPaths
({
navDataFile
:
NAV_DATA_FILE
,
localContentDir
:
CONTENT_DIR
,
product
:
{
name
:
productName
,
slug
:
productSlug
},
basePath
:
basePath
,
}),
}
}
export
async
function
getStaticProps
({
params
})
{
try
{
return
{
revalidate
:
10
,
props
:
await
generateStaticProps
({
params
,
navDataFile
:
NAV_DATA_FILE
,
localContentDir
:
CONTENT_DIR
,
product
:
{
name
:
productName
,
slug
:
productSlug
},
const
{
getStaticPaths
,
getStaticProps
}
=
getStaticGenerationFunctions
(
process
.
env
.
ENABLE_VERSIONED_DOCS
===
'
true
'
?
{
strategy
:
'
remote
'
,
basePath
:
basePath
,
}),
}
}
catch
(
err
)
{
console
.
warn
(
err
)
return
{
notFound
:
true
}
}
}
fallback
:
'
blocking
'
,
revalidate
:
360
,
// 1 hour
product
:
productSlug
,
}
:
{
strategy
:
'
fs
'
,
basePath
:
basePath
,
localContentDir
:
CONTENT_DIR
,
navDataFile
:
NAV_DATA_FILE
,
product
:
productSlug
,
revalidate
:
false
,
}
)
export
{
getStaticPaths
,
getStaticProps
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help