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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

After Static! #370

Merged
merged 29 commits into from
Nov 1, 2021
Merged

After Static! #370

merged 29 commits into from
Nov 1, 2021

Conversation

nimaa77
Copy link
Collaborator

@nimaa77 nimaa77 commented Jul 10, 2020

Description

Add SSG to after.js

How to use

in static_export.js file we export two functions.

render is an async function and it will return the html you want to save in html file. after.js has a renderStatic function that will take care about loading the data from static file instead of calling getInitialProps after exporting.

routes is an async function and should return all the pages that you want to statically generate them.

for full documentation and advanced configuration visit: https://razzlejs.org/docs/static-export

// ./src/static_export.js

import { renderStatic } from '@jaredpalmer/after';
import appRoutes from './routes';

const assets = require(process.env.RAZZLE_ASSETS_MANIFEST);
const chunks = require(process.env.RAZZLE_CHUNKS_MANIFEST);

export const render = async (req, res) => {
  const { html, data } = await renderStatic({
    req,
    res,
    routes: appRoutes,
    assets,
    chunks,
  });
  res.json({ html, data });
};

export const routes = () => {
  return ['/', '/about'];
};

build your app by running the build command:

yarn build

and for static export run the export command:

yarn export

you can see the result of this process at build/public directory.

Breaking Changes

nothing. 馃帀

@nimaa77 nimaa77 changed the title [examples]: add with-prerender example After Static! Jul 11, 2020
@nimaa77 nimaa77 mentioned this pull request Jul 11, 2020
67 tasks
@stale
Copy link

stale bot commented Aug 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 22, 2020
@stale stale bot closed this Aug 29, 2020
@nimaa77 nimaa77 reopened this Oct 8, 2020
@stale stale bot removed the wontfix label Oct 8, 2020
@stale
Copy link

stale bot commented Nov 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 21, 2020
@stale stale bot closed this Dec 19, 2020
@nimaa77 nimaa77 reopened this Oct 31, 2021
@nimaa77 nimaa77 removed the wontfix label Oct 31, 2021
@github-actions
Copy link

github-actions bot commented Nov 1, 2021

size-limit report 馃摝

Path Size
dist/after.cjs.production.min.js 17.37 KB (0%)
dist/esm/After.esm.js, dist/esm/Document.esm.js, dist/esm/NotFoundComponent.esm.js, dist/esm/asyncComponent.esm.js, dist/esm/ensureReady.esm.js, dist/esm/getAssets.esm.js, dist/esm/index.esm.js, dist/esm/loadInitialProps.esm.js, dist/esm/loadStaticProps.esm.js, dist/esm/render.esm.js, dist/esm/renderApp.esm.js, dist/esm/renderStatic.esm.js, dist/esm/serializeData.esm.js, dist/esm/utils.esm.js 16.61 KB (0%)

@nimaa77 nimaa77 merged commit 556dd2b into master Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant