mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-21 13:06:58 +02:00
fix(v2): make proper path to pages in TS (#2334)
This commit is contained in:
parent
590de95234
commit
68a5cd5df1
4 changed files with 33 additions and 1 deletions
|
@ -0,0 +1,22 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import Head from '@docusaurus/Head';
|
||||||
|
|
||||||
|
export default class Home extends React.Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Head>
|
||||||
|
<title>Hello</title>
|
||||||
|
</Head>
|
||||||
|
<div>TypeScript...</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,6 +33,10 @@ describe('docusaurus-plugin-content-pages', () => {
|
||||||
permalink: '/',
|
permalink: '/',
|
||||||
source: path.join('@site', pluginPath, 'index.js'),
|
source: path.join('@site', pluginPath, 'index.js'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
permalink: '/typescript',
|
||||||
|
source: path.join('@site', pluginPath, 'typescript.tsx'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
permalink: '/hello/world',
|
permalink: '/hello/world',
|
||||||
source: path.join('@site', pluginPath, 'hello', 'world.js'),
|
source: path.join('@site', pluginPath, 'hello', 'world.js'),
|
||||||
|
|
|
@ -61,7 +61,7 @@ export function objectWithKeySorted(obj: Object) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const indexRE = /(^|.*\/)index\.(md|js|jsx|ts|tsx)$/i;
|
const indexRE = /(^|.*\/)index\.(md|js|jsx|ts|tsx)$/i;
|
||||||
const extRE = /\.(md|js)$/;
|
const extRE = /\.(md|js|tsx)$/;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert filepath to url path.
|
* Convert filepath to url path.
|
||||||
|
|
|
@ -41,6 +41,12 @@ Once you save the file, the development server will automatically reload the cha
|
||||||
|
|
||||||
Each page doesn't come with any styling. You will need to import the `Layout` component from `@theme/Layout` and wrap your contents within that component if you want the navbar and/or footer to appear.
|
Each page doesn't come with any styling. You will need to import the `Layout` component from `@theme/Layout` and wrap your contents within that component if you want the navbar and/or footer to appear.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
You can also create a page in TypeScript, in which case the its file name should use the `.tsx` extension, eg. `hello.tsx`.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## Routing
|
## Routing
|
||||||
|
|
||||||
If you are familiar with other static site generators like Jekyll and Next, this routing approach will feel familiar to you. Any JavaScript file you create under `/src/pages/` directory will be automatically converted to a website page, following the `/src/pages/` directory hierarchy. For example:
|
If you are familiar with other static site generators like Jekyll and Next, this routing approach will feel familiar to you. Any JavaScript file you create under `/src/pages/` directory will be automatically converted to a website page, following the `/src/pages/` directory hierarchy. For example:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue