Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sanity Exhibition Nansen
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
uib-ub
Spesialsamlingene
Utstillinger
Sanity Exhibition Nansen
Commits
90306769
Commit
90306769
authored
3 years ago
by
Tarje.Lavik
Browse files
Options
Downloads
Patches
Plain Diff
WIP, add toc to side
parent
17eeb1f5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
web/components/TableOfContent.js
+24
-6
24 additions, 6 deletions
web/components/TableOfContent.js
web/pages/[...slug].js
+6
-3
6 additions, 3 deletions
web/pages/[...slug].js
with
30 additions
and
9 deletions
web/components/TableOfContent.js
+
24
−
6
View file @
90306769
...
...
@@ -18,8 +18,6 @@ export default function TableOfContent(props) {
}
})
console
.
log
(
'
Headings
'
,
headings
)
const
getNestedHeadings
=
(
headingElements
)
=>
{
const
nestedHeadings
=
[]
...
...
@@ -42,15 +40,35 @@ export default function TableOfContent(props) {
const
list
=
getNestedHeadings
(
headings
)
return
(
<
List
color
=
"
gray.500
"
listStyleType
=
"
disc
"
>
<
List
className
=
"
toc
"
color
=
"
gray.500
"
listStyleType
=
"
disc
"
>
{
list
.
map
((
heading
)
=>
(
<
ListItem
key
=
{
heading
.
id
}
>
<
Link
href
=
{
`#
${
heading
.
id
}
`
}
>
{
heading
.
text
}
<
/Link
>
<
Link
href
=
{
`#
${
heading
.
id
}
`
}
sx
=
{{
'
.toc:hover &
'
:
{
display
:
'
block
'
,
},
}}
display
=
"
none
"
>
{
heading
.
text
}
<
/Link
>
{
heading
.
items
.
length
>
0
&&
(
<
List
listStyleType
=
"
circle
"
>
<
List
className
=
"
toc
"
listStyleType
=
"
circle
"
>
{
heading
.
items
.
map
((
child
)
=>
(
<
ListItem
key
=
{
child
.
id
}
>
<
Link
href
=
{
`#
${
child
.
id
}
`
}
>
{
child
.
text
}
<
/Link
>
<
Link
href
=
{
`#
${
child
.
id
}
`
}
sx
=
{{
'
.toc:hover &
'
:
{
display
:
'
block
'
,
},
}}
display
=
"
none
"
>
{
child
.
text
}
<
/Link
>
<
/ListItem
>
))}
<
/List
>
...
...
This diff is collapsed.
Click to expand it.
web/pages/[...slug].js
+
6
−
3
View file @
90306769
import
{
getRoute
,
getRoutes
}
from
'
../lib/api
'
import
{
Container
,
Text
}
from
'
@chakra-ui/react
'
import
{
Box
,
Container
,
Text
}
from
'
@chakra-ui/react
'
import
Date
from
'
../components/Date
'
import
Layout
from
'
../components/Layout
'
import
Sections
from
'
../components/Sections/Sections
'
...
...
@@ -14,12 +14,15 @@ export default function Page({ data, preview }) {
return
(
<
Layout
preview
=
{
preview
}
site
=
{
data
.
siteSettings
}
>
<
Container
maxWidth
=
"
4xl
"
centerContent
>
<
TableOfContent
blocks
=
{
body
}
/
>
{
/* A Page */
}
{
content
&&
<
Sections
sections
=
{
content
}
/>
}
{
/* If LinguisticDocument the content is in the body field */
}
{
body
&&
(
<
Box
position
=
"
fixed
"
left
=
"
10
"
top
=
"
50vh
"
>
<
TableOfContent
blocks
=
{
body
}
/
>
<
/Box
>
)}
{
body
&&
<
PortableTextBlock
blocks
=
{
body
}
/>
}
<
Text
mt
=
"
5
"
color
=
"
gray.500
"
fontSize
=
"
sm
"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment