Skip to content

Commit

Permalink
fix: update store import
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 20, 2020
1 parent 1bca067 commit a5b017b
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 15 deletions.
4 changes: 1 addition & 3 deletions examples/nextjs/pages/[doctype].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FC } from 'react';
import { GetStaticProps, GetStaticPaths } from 'next';
import { DocType, defDocType } from '@component-controls/core';
import { DocumentHomePage } from '@component-controls/app';
import { Layout } from '@component-controls/nextjs-plugin';
import { Layout, store } from '@component-controls/nextjs-plugin';

interface PageListProps {
type: DocType;
Expand All @@ -18,13 +18,11 @@ const DocHomeTemplate: FC<PageListProps> = ({ type = defDocType, docId }) => {
};

export const getStaticPaths: GetStaticPaths = async () => {
const { store } = require('@component-controls/nextjs-plugin/store');
const paths: string[] = store.getHomePaths();
return { paths, fallback: false };
};

export const getStaticProps: GetStaticProps = async ({ params }) => {
const { store } = require('@component-controls/nextjs-plugin/store');
const { doctype: basepath } = params as { doctype: string };
const { type = null, docId = null } = store.getHomePage(`/${basepath}`) || {};
return { props: { docId, type } };
Expand Down
4 changes: 1 addition & 3 deletions examples/nextjs/pages/[doctype]/[...docid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FC } from 'react';
import { GetStaticProps, GetStaticPaths } from 'next';
import { DocPage } from '@component-controls/app';
import { DocType } from '@component-controls/core';
import { Layout } from '@component-controls/nextjs-plugin';
import { Layout, store } from '@component-controls/nextjs-plugin';

interface DocPageProps {
docId?: string;
Expand All @@ -29,13 +29,11 @@ const DocPageTemplate: FC<DocPageProps> = ({
export default DocPageTemplate;

export const getStaticPaths: GetStaticPaths = async () => {
const { store } = require('@component-controls/nextjs-plugin/store');
const paths: string[] = store.getDocPaths();
return { paths, fallback: false };
};

export const getStaticProps: GetStaticProps = async ({ params }) => {
const { store } = require('@component-controls/nextjs-plugin/store');
const { doctype, docid } = params as { doctype: string; docid: string[] };
const {
type = null,
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const HomePage: FC<PageListProps> = ({ type = defDocType, docId }) => {
};

export const getStaticProps: GetStaticProps = async () => {
const { store } = require('@component-controls/nextjs-plugin/store');
const { store } = require('@component-controls/nextjs-plugin');
const { docId = null, type = null } = store.getIndexPage() || {};
return { props: { docId, type } };
};
Expand Down
4 changes: 1 addition & 3 deletions examples/starter/pages/[doctype].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FC } from 'react';
import { GetStaticProps, GetStaticPaths } from 'next';
import { DocType, defDocType } from '@component-controls/core';
import { DocumentHomePage } from '@component-controls/app';
import { Layout } from '@component-controls/nextjs-plugin';
import { Layout, store } from '@component-controls/nextjs-plugin';

interface PageListProps {
type: DocType;
Expand All @@ -18,13 +18,11 @@ const DocHomeTemplate: FC<PageListProps> = ({ type = defDocType, docId }) => {
};

export const getStaticPaths: GetStaticPaths = async () => {
const { store } = require('@component-controls/nextjs-plugin/store');
const paths: string[] = store.getHomePaths();
return { paths, fallback: false };
};

export const getStaticProps: GetStaticProps = async ({ params }) => {
const { store } = require('@component-controls/nextjs-plugin/store');
const { doctype: basepath } = params as { doctype: string };
const { type = null, docId = null } = store.getHomePage(`/${basepath}`) || {};
return { props: { docId, type } };
Expand Down
4 changes: 1 addition & 3 deletions examples/starter/pages/[doctype]/[...docid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FC } from 'react';
import { GetStaticProps, GetStaticPaths } from 'next';
import { DocPage } from '@component-controls/app';
import { DocType } from '@component-controls/core';
import { Layout } from '@component-controls/nextjs-plugin';
import { Layout, store } from '@component-controls/nextjs-plugin';

interface DocPageProps {
docId?: string;
Expand All @@ -29,13 +29,11 @@ const DocPageTemplate: FC<DocPageProps> = ({
export default DocPageTemplate;

export const getStaticPaths: GetStaticPaths = async () => {
const { store } = require('@component-controls/nextjs-plugin/store');
const paths: string[] = store ? store.getDocPaths() : [];
return { paths, fallback: false };
};

export const getStaticProps: GetStaticProps = async ({ params }) => {
const { store } = require('@component-controls/nextjs-plugin/store');
const { doctype, docid } = params as { doctype: string; docid: string[] };
const {
type = null,
Expand Down
2 changes: 1 addition & 1 deletion examples/starter/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const HomePage: FC<PageListProps> = ({ type = defDocType, docId }) => {
};

export const getStaticProps: GetStaticProps = async () => {
const { store } = require('@component-controls/nextjs-plugin/store');
const { store } = require('@component-controls/nextjs-plugin');
const { docId = null, type = null } = store.getIndexPage() || {};
return { props: { docId, type } };
};
Expand Down
1 change: 1 addition & 0 deletions integrations/nextjs-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './components/Layout';
export * from './store';
3 changes: 2 additions & 1 deletion integrations/nextjs-plugin/src/store.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const store = null;
import { StoryStore, Store } from '@component-controls/store';
export const store: StoryStore = new Store();

0 comments on commit a5b017b

Please sign in to comment.