-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77e47fb
commit ea97ca0
Showing
20 changed files
with
340 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ dist | |
.rpt2_cache | ||
*.log | ||
public | ||
.next | ||
.next | ||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
const withStories = require('@component-controls/nextjs-plugin'); | ||
const withStories = require('@component-controls/nextjs-plugin/build'); | ||
|
||
module.exports = withStories({ configPath: '.config', distDir: 'dist' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { FC } from 'react'; | ||
import { GetStaticProps, GetStaticPaths } from 'next'; | ||
import { DocType, defDocType, Pages } from '@component-controls/core'; | ||
import { DocumentHomePage } from '@component-controls/app'; | ||
import { getDocs } from '@component-controls/loader'; | ||
import { Layout } from '@component-controls/nextjs-plugin'; | ||
|
||
interface PageListProps { | ||
type: DocType; | ||
docId?: string; | ||
} | ||
|
||
const DocHomeTemplate: FC<PageListProps> = ({ type = defDocType, docId }) => { | ||
return ( | ||
<Layout docId={docId} type={type}> | ||
<DocumentHomePage type={type} /> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export const getStaticPaths: GetStaticPaths = async () => { | ||
const paths: string[] = []; | ||
const store = require('@component-controls/webpack-compile/bundle'); | ||
const { pages } = store.buildConfig || {}; | ||
if (pages) { | ||
Object.keys(pages).forEach(type => { | ||
const page = pages[type as DocType]; | ||
//const docType = type as DocType; | ||
// const docs = getDocs(store.stores, docType); | ||
paths.push(`/${page.basePath}`); | ||
}); | ||
} | ||
return { paths, fallback: false }; | ||
}; | ||
|
||
export const getStaticProps: GetStaticProps = async ({ params }) => { | ||
const store = require('@component-controls/webpack-compile/bundle'); | ||
const { doctype: basepath } = params as { doctype: string }; | ||
|
||
const { pages } = store.buildConfig || {}; | ||
const doctype = Object.keys(pages).find(key => { | ||
return pages[key].basePath.replace(/\//g, '') === basepath; | ||
}) as DocType; | ||
const docs: Pages = getDocs(store.stores, doctype); | ||
const page = pages[doctype]; | ||
const docsPage = docs.find(doc => doc?.route === `/${page.basePath}`); | ||
return { props: { docId: docsPage?.title || null, type: doctype } }; | ||
}; | ||
|
||
export default DocHomeTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import NextApp from 'next/app'; | ||
import { CacheProvider } from '@emotion/core'; | ||
|
||
// Use only { cache } from 'emotion'. Don't use { css }. | ||
import { cache } from 'emotion'; | ||
|
||
export default class App extends NextApp { | ||
render() { | ||
const { Component, pageProps } = this.props; | ||
return ( | ||
<CacheProvider value={cache}> | ||
<Component {...pageProps} /> | ||
</CacheProvider> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import Document, { Head, Main, NextScript } from 'next/document'; | ||
import { extractCritical } from 'emotion-server'; | ||
|
||
export default class MyDocument extends Document { | ||
static async getInitialProps(ctx) { | ||
const initialProps = await Document.getInitialProps(ctx); | ||
const styles = extractCritical(initialProps.html); | ||
return { | ||
...initialProps, | ||
styles: ( | ||
<> | ||
{initialProps.styles} | ||
<style | ||
data-emotion-css={styles.ids.join(' ')} | ||
dangerouslySetInnerHTML={{ __html: styles.css }} | ||
/> | ||
</> | ||
), | ||
}; | ||
} | ||
|
||
render() { | ||
return ( | ||
<html> | ||
<Head /> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</html> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { FC } from 'react'; | ||
import { GetStaticProps } from 'next'; | ||
|
||
import { DocType, defDocType } from '@component-controls/core'; | ||
import { DocPage } from '@component-controls/app'; | ||
import { Layout } from '@component-controls/nextjs-plugin'; | ||
import { LoadingDocStore } from '@component-controls/instrument'; | ||
|
||
interface PageListProps { | ||
type: DocType; | ||
docId?: string; | ||
} | ||
|
||
const HomePage: FC<PageListProps> = ({ type = defDocType, docId }) => { | ||
return ( | ||
<Layout docId={docId} type={type}> | ||
<DocPage type={type} /> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export const getStaticProps: GetStaticProps = async () => { | ||
const store = require('@component-controls/webpack-compile/bundle'); | ||
const homePage = store.stores.find( | ||
(s: LoadingDocStore) => s.doc?.route === '/', | ||
); | ||
return { props: { docId: homePage?.doc?.title, type: homePage?.doc?.type } }; | ||
}; | ||
|
||
export default HomePage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
integrations/gatsby-theme-stories/src/templates/CategoryList.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./dist/build'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { config } from '../../rollup-config'; | ||
|
||
export default config({ | ||
input: ['./src/index.ts'], | ||
input: ['./src/index.ts', './src/build.ts'], | ||
}); |
Oops, something went wrong.