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:
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 parse from '../lib/markdown';
|
||||||
import DRD from '../components/DRD';
|
import DRD from '../components/DRD';
|
||||||
|
|
||||||
export const getStaticProps: GetStaticProps = async (context) => {
|
export const getStaticProps = async (context) => {
|
||||||
const contentDir = path.join(process.cwd(), '/content');
|
const indexFile = path.join(process.cwd(), '/content/index.md');
|
||||||
const datasets = await fs.readdir(contentDir);
|
const readme = await fs.readFile(indexFile, 'utf8');
|
||||||
const datasetReadme = path.join(
|
|
||||||
process.cwd(),
|
|
||||||
'/content/' + datasets[0] + '/README.md'
|
|
||||||
);
|
|
||||||
const readme = await fs.readFile(datasetReadme, 'utf8');
|
|
||||||
let { mdxSource, frontMatter } = await parse(readme, '.mdx');
|
let { mdxSource, frontMatter } = await parse(readme, '.mdx');
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
22270
package-lock.json
generated
22270
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user