From 82cc463ced00cc59ad828f3cbec587e58ce123b4 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Fri, 26 May 2023 10:09:53 +0200 Subject: [PATCH] update home documentation code examples Signed-off-by: Emma Indal --- docs/getting-started/homepage.md | 20 ++++++------- plugins/home/README.md | 48 ++++++++++++++------------------ 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/docs/getting-started/homepage.md b/docs/getting-started/homepage.md index 63a97ec54f..9c6f6380a1 100644 --- a/docs/getting-started/homepage.md +++ b/docs/getting-started/homepage.md @@ -40,10 +40,10 @@ Inside your `packages/app` directory, create a new file where our new homepage c ```tsx import React from 'react'; -export const HomePage = () => { +export const homePage = ( /* We will shortly compose a pretty homepage here. */ - return

Welcome to Backstage!

; -}; +

Welcome to Backstage!

+); ``` #### 3. Update router for the root `/` route @@ -161,13 +161,11 @@ import React from 'react'; import Grid from '@material-ui/core/Grid'; import { HomePageCompanyLogo } from '@backstage/plugin-home'; -export const HomePage = () => { - return ( - - - - +export const homePage = ( + + + - ); -}; + +); ``` diff --git a/plugins/home/README.md b/plugins/home/README.md index 42fbf73d18..8bb474aa4b 100644 --- a/plugins/home/README.md +++ b/plugins/home/README.md @@ -22,11 +22,9 @@ yarn add --cwd packages/app @backstage/plugin-home ```tsx import React from 'react'; -export const HomePage = () => { - return { - /* TODO: Compose a Home Page here */ - }; -}; +export const homePage = ( + /* TODO: Compose a Home Page here */ +); ``` 2. Add a route where the homepage will live, presumably `/`. @@ -35,11 +33,11 @@ export const HomePage = () => { ```tsx import { HomepageCompositionRoot } from '@backstage/plugin-home'; -import { HomePage } from './components/home/HomePage'; +import { homePage } from './components/home/HomePage'; // ... }> - + {homePage} ; // ... ``` @@ -72,15 +70,13 @@ import React from 'react'; import Grid from '@material-ui/core/Grid'; import { RandomJokeHomePageComponent } from '@backstage/plugin-home'; -export const HomePage = () => { - return ( - - - - +export const homePage = ( + + + - ); -}; + +); ``` Additionally, the App Integrator is provided an escape hatch in case the way the card is rendered does not fit their requirements. They may optionally pass the `Renderer`-prop, which will receive the `title`, `content` and optionally `actions`, `settings` and `contextProvider`, if they exist for the component. This allows the App Integrator to render the content in any way they want. @@ -102,18 +98,16 @@ import { HomePageSearchBar } from '@backstage/plugin-search'; import { HomePageCalendar } from '@backstage/plugin-gcalendar'; import { MicrosoftCalendarCard } from '@backstage/plugin-microsoft-calendar'; -export const HomePage = () => { - return ( - - // Insert the allowed widgets inside the grid - - - - - - - ); -}; +export const homePage = ( + + // Insert the allowed widgets inside the grid + + + + + + +); ``` ### Creating Customizable Components