mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00
Add YAML-metadata for notes and change the document title accordingly (#310)
* Added yaml-frontmatter extracting and error handling * add tests * changed document-title, so the editor can change the title to the title of the yaml metadata. closes #303 * extracted first line parsing in a core rule of markdown-it document title will now be determined like this: 1. yaml metadata title 2. opengraph title 3. first level one heading 4. 'Untitled' * added documentTitle e2e test Co-authored-by: Erik Michelson <github@erik.michelson.eu> Co-authored-by: Philip Molares <philip@mauricedoepke.de> Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: mrdrogdrog <mr.drogdrog@gmail.com>
This commit is contained in:
parent
07fed5c67e
commit
29709d2ba4
13 changed files with 499 additions and 20 deletions
|
@ -2,12 +2,16 @@ import React, { useEffect } from 'react'
|
|||
import { useSelector } from 'react-redux'
|
||||
import { ApplicationState } from '../../../redux'
|
||||
|
||||
export const DocumentTitle: React.FC = () => {
|
||||
export interface DocumentTitleProps {
|
||||
title?: string
|
||||
}
|
||||
|
||||
export const DocumentTitle: React.FC<DocumentTitleProps> = ({ title }) => {
|
||||
const branding = useSelector((state: ApplicationState) => state.backendConfig.branding)
|
||||
|
||||
useEffect(() => {
|
||||
document.title = `CodiMD ${branding.name ? ` @ ${branding.name}` : ''}`
|
||||
}, [branding])
|
||||
document.title = `${title ? title + ' - ' : ''}CodiMD ${branding.name ? ` @ ${branding.name}` : ''}`
|
||||
}, [branding, title])
|
||||
|
||||
return null
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue