Basic example part 2 (#806)
* [basic-example][m] - initial commit * [basic-example][m] - fix fetching of actual data * [basic-example][m] - remove everything related to multiple pages * [basic-example][sm] fix rendering issue * [basic-example][m] - remove middleware * [basic-example][m] - multiple datasets * [basic-example][m] - multiple datasetst
This commit is contained in:
parent
ad209c8f21
commit
41e7f8ad8d
8
examples/basic-example/content/index.md
Normal file
8
examples/basic-example/content/index.md
Normal file
@ -0,0 +1,8 @@
|
||||
# My Dataset
|
||||
|
||||
Built with PortalJS
|
||||
|
||||
## Table
|
||||
|
||||
<Table url="data_1.csv" />
|
||||
|
||||
42
examples/basic-example/pages/[...path].tsx
Normal file
42
examples/basic-example/pages/[...path].tsx
Normal file
@ -0,0 +1,42 @@
|
||||
import { GetStaticProps } from 'next';
|
||||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
import parse from '../lib/markdown';
|
||||
import DRD from '../components/DRD';
|
||||
|
||||
export const getServerSideProps = async (context) => {
|
||||
const indexFile = path.join(process.cwd(), '/content/' + context.params.path.join('/') + '/index.md');
|
||||
const readme = await fs.readFile(indexFile, 'utf8');
|
||||
let { mdxSource, frontMatter } = await parse(readme, '.mdx');
|
||||
return {
|
||||
props: {
|
||||
mdxSource,
|
||||
frontMatter,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default function DatasetPage({ mdxSource, frontMatter }) {
|
||||
return (
|
||||
<div className="prose mx-auto">
|
||||
<header>
|
||||
<div className="mb-6">
|
||||
<>
|
||||
<h1>{frontMatter.title}</h1>
|
||||
{frontMatter.author && (
|
||||
<div className="-mt-6">
|
||||
<p className="opacity-60 pl-1">{frontMatter.author}</p>
|
||||
</div>
|
||||
)}
|
||||
{frontMatter.description && (
|
||||
<p className="description">{frontMatter.description}</p>
|
||||
)}
|
||||
</>
|
||||
</div>
|
||||
</header>
|
||||
<main>
|
||||
<DRD source={mdxSource} />
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -4,14 +4,9 @@ import path from 'path';
|
||||
import parse from '../lib/markdown';
|
||||
import DRD from '../components/DRD';
|
||||
|
||||
export const getStaticProps: GetStaticProps = async (context) => {
|
||||
const contentDir = path.join(process.cwd(), '/content');
|
||||
const datasets = await fs.readdir(contentDir);
|
||||
const datasetReadme = path.join(
|
||||
process.cwd(),
|
||||
'/content/' + datasets[0] + '/README.md'
|
||||
);
|
||||
const readme = await fs.readFile(datasetReadme, 'utf8');
|
||||
export const getStaticProps = async (context) => {
|
||||
const indexFile = path.join(process.cwd(), '/content/index.md');
|
||||
const readme = await fs.readFile(indexFile, 'utf8');
|
||||
let { mdxSource, frontMatter } = await parse(readme, '.mdx');
|
||||
return {
|
||||
props: {
|
||||
|
||||
22270
package-lock.json
generated
22270
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user