mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-17 00:24:43 -04:00
feat: fetch frontend config in server side rendering
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
312d1adf6f
commit
24f1b2a361
41 changed files with 270 additions and 220 deletions
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { FrontendConfig } from '../../../api/config/types'
|
||||
import { frontendConfigContext } from './context'
|
||||
import { Optional } from '@mrdrogdrog/optional'
|
||||
import { useContext } from 'react'
|
||||
|
||||
/**
|
||||
* Retrieves the current frontend config from the next react context.
|
||||
*/
|
||||
export const useFrontendConfig = (): FrontendConfig => {
|
||||
return Optional.ofNullable(useContext(frontendConfigContext)).orElseThrow(
|
||||
() => new Error('No frontend config context found. Did you forget to use the provider component?')
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue