mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 17:25:16 -04:00
fix: Move content into to frontend directory
Doing this BEFORE the merge prevents a lot of merge conflicts. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
4e18ce38f3
commit
762a0a850e
1051 changed files with 0 additions and 35 deletions
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { useContext, useMemo } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
import { baseUrlContext } from '../../components/common/base-url/base-url-context-provider'
|
||||
|
||||
export enum ORIGIN {
|
||||
EDITOR,
|
||||
RENDERER,
|
||||
CURRENT_PAGE
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the base urls for the editor and the renderer.
|
||||
*/
|
||||
export const useBaseUrl = (origin = ORIGIN.CURRENT_PAGE): string => {
|
||||
const baseUrls = useContext(baseUrlContext)
|
||||
if (!baseUrls) {
|
||||
throw new Error('No base url context received. Did you forget to use the provider component?')
|
||||
}
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
return useMemo(() => {
|
||||
return (router.route === '/render' && origin === ORIGIN.CURRENT_PAGE) || origin === ORIGIN.RENDERER
|
||||
? baseUrls.renderer
|
||||
: baseUrls.editor
|
||||
}, [origin, baseUrls.renderer, baseUrls.editor, router.route])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue