Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying a custom page initializer (App) #11

Closed
fs-c opened this issue Mar 6, 2021 · 1 comment
Closed

Allow specifying a custom page initializer (App) #11

fs-c opened this issue Mar 6, 2021 · 1 comment

Comments

@fs-c
Copy link
Contributor

fs-c commented Mar 6, 2021

Since _document.js is already a thing, why not take more inspiration from Next.js?

The default App would be something like

const App = ({ Component, props }) => (
    <Component {...props} />
);

export default App;

where props is the result of the getProps function that a page can optionally export.

Custom Apps would allow for things like

// _app.js
import Header  from 'header'
import Footer 'footer'

const App = ({ Component, props: { headerProps, footerProps, ...pageProps } }) => (
    <Header {...headerProps} />

    <Component {...pageProps} />

    <Footer {...footerProps} />
);

// some/page.js
const Page = ({ posts }) => {
    // ...
};

export const getProps = async () => {
    return { headerProps: { isLanding: false }, footerProps: { dense: true }, posts: [ /* ... */ ] }
};

This is the only feature I can think of that's stopping me from using dhow right now, and I'm willing to take a stab at implementing it. Will probably submit a PR either later today or tomorrow.

@fs-c
Copy link
Contributor Author

fs-c commented Mar 6, 2021

Nevermind, I am so used to working with React and Next.js that I forgot that there is basically no difference between _document.js and _app.js in the given context.

Closing.

@fs-c fs-c closed this as completed Mar 6, 2021
@fs-c fs-c mentioned this issue Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant