Browse Source
Fixes wrong breadcrumb for 404 page (#4074)
* Fixes wrong breadcrumb for 404 page
* Change Home as default layout
* Add layout Learn to the pages inside learn
main
harish-sethuraman
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with
41 additions and
1 deletions
-
beta/plugins/md-layout-loader.js
-
beta/src/components/Layout/useRouteMeta.tsx
-
beta/src/pages/learn/add-react-to-a-website.md
-
beta/src/pages/learn/adding-interactivity.md
-
beta/src/pages/learn/choosing-the-state-structure.md
-
beta/src/pages/learn/conditional-rendering.md
-
beta/src/pages/learn/describing-the-ui.md
-
beta/src/pages/learn/editor-setup.md
-
beta/src/pages/learn/escape-hatches.md
-
beta/src/pages/learn/extracting-state-logic-into-a-reducer.md
-
beta/src/pages/learn/importing-and-exporting-components.md
-
beta/src/pages/learn/index.md
-
beta/src/pages/learn/installation.md
-
beta/src/pages/learn/javascript-in-jsx-with-curly-braces.md
-
beta/src/pages/learn/keeping-components-pure.md
-
beta/src/pages/learn/managing-state.md
-
beta/src/pages/learn/manipulating-the-dom-with-refs.md
-
beta/src/pages/learn/passing-data-deeply-with-context.md
-
beta/src/pages/learn/passing-props-to-a-component.md
-
beta/src/pages/learn/preserving-and-resetting-state.md
-
beta/src/pages/learn/queueing-a-series-of-state-updates.md
-
beta/src/pages/learn/react-developer-tools.md
-
beta/src/pages/learn/reacting-to-input-with-state.md
-
beta/src/pages/learn/referencing-values-with-refs.md
-
beta/src/pages/learn/render-and-commit.md
-
beta/src/pages/learn/rendering-lists.md
-
beta/src/pages/learn/responding-to-events.md
-
beta/src/pages/learn/scaling-up-with-reducer-and-context.md
-
beta/src/pages/learn/sharing-state-between-components.md
-
beta/src/pages/learn/start-a-new-react-project.md
-
beta/src/pages/learn/state-a-components-memory.md
-
beta/src/pages/learn/state-as-a-snapshot.md
-
beta/src/pages/learn/thinking-in-react.md
-
beta/src/pages/learn/updating-arrays-in-state.md
-
beta/src/pages/learn/updating-objects-in-state.md
-
beta/src/pages/learn/writing-markup-with-jsx.md
-
beta/src/pages/learn/your-first-component.md
|
|
@ -15,7 +15,7 @@ const fm = require('gray-matter'); |
|
|
|
module.exports = async function (src) { |
|
|
|
const callback = this.async(); |
|
|
|
const {content, data} = fm(src); |
|
|
|
const layout = data.layout || 'Learn'; |
|
|
|
const layout = data.layout || 'Home'; |
|
|
|
const code = |
|
|
|
`import withLayout from 'components/Layout/Layout${layout}';
|
|
|
|
|
|
|
|
|
|
@ -56,6 +56,11 @@ export function useRouteMeta(rootRoute?: RouteItem) { |
|
|
|
const routeTree = rootRoute || sidebarContext; |
|
|
|
const router = useRouter(); |
|
|
|
const cleanedPath = router.pathname; |
|
|
|
if (cleanedPath === '/404') { |
|
|
|
return { |
|
|
|
breadcrumbs: [], |
|
|
|
}; |
|
|
|
} |
|
|
|
const breadcrumbs = getBreadcrumbs(cleanedPath, routeTree); |
|
|
|
return { |
|
|
|
...getRouteMeta(cleanedPath, routeTree), |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Add React to a Website |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Adding Interactivity |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Choosing the State Structure |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Conditional Rendering |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Describing the UI |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Editor Setup |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Escape Hatches |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
This chapter is incomplete and is still being written! |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Extracting State Logic into a Reducer |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Importing and Exporting Components |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Quick Start |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Installation |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: JavaScript in JSX with Curly Braces |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Keeping Components Pure |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Managing State |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: 'Manipulating the DOM with Refs' |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Passing Data Deeply with Context |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Passing Props to a Component |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Preserving and Resetting State |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Queueing a Series of State Updates |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: React Developer Tools |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Reacting to Input with State |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: 'Referencing Values with Refs' |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Render and Commit |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Rendering Lists |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Responding to Events |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Scaling Up with Reducer and Context |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Sharing State Between Components |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Start a New React Project |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: "State: A Component's Memory" |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: State as a Snapshot |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Thinking in React |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Updating Arrays in State |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Updating Objects in State |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Writing Markup with JSX |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
--- |
|
|
|
title: Your First Component |
|
|
|
layout: Learn |
|
|
|
--- |
|
|
|
|
|
|
|
<Intro> |
|
|
|