Skip to content

Reduce layout shifts caused by LocalNav for devices with width 960px - 1280px #4897

@sapphi-red

Description

@sapphi-red

Is your feature request related to a problem? Please describe.

layoutshifts.webm

Layout shifts happens for devices with width 960px - 1280px. This is caused by the LocalNav injected on client side.

Describe the solution you'd like

I'm not sure. I took a look but didn't find an easy way to solve this.

This empty class is set on SSR because


hasLocalNav is always false on SSR.
const hasLocalNav = computed(() => {
return headers.value.length > 0
})

This is true for most pages on client render because it is set here.
headers.value = getHeaders(frontmatter.value.outline ?? theme.value.outline)

But this function checks the rendered document. I don't know a way to achieve this on SSR.
Maybe adding isSSR || here, assuming most pages has headers?
v-if="!isHome && (hasLocalNav || hasSidebar || y >= navHeight)"

Describe alternatives you've considered

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    themeRelated to the theme

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions