Skip to content

Conversation

@alex-page
Copy link
Member

@alex-page alex-page commented Sep 1, 2022

This PR

  • Adds a build time script to generate the .cache/site.json file making sure the navigation and search do not need to be updated when creating new pages
  • Replaces components.json and foundations.json with .cache/site.json
  • Uses one file for the site data so that there is one readFile script needed to access it
  • Uses one file for the site data so it can be cached effectively when read
  • Local dev: Make the .cache/site.json file regenerate on changes to markdown files
  • Fixes json file typescript issues

Future work

  • Production: Do not read and store .cache/site.json in client side memory when generating the navigation
  • Production: Do not read and store .cache/site.json in client side memory when generating the components page categories

Comment on lines +1 to +8
import path from 'path';
import chokidar from 'chokidar';

import genSiteJson from './gen-site-json.mjs';

const mdPath = path.join(process.cwd(), 'content');

chokidar.watch(mdPath).on('change', async () => await genSiteJson());
Copy link
Member Author

@alex-page alex-page Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be replaced with chokidar-cli. The downside is I would need a file that runs genSiteJson() which would look like...

import genSiteJson from './gen-site-json.mjs';
genSiteJson();

So for now I just made a single file, happy to iterate on this later.

Copy link
Member

@chloerice chloerice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 🎉 👏🏽

@alex-page alex-page merged commit ddfacd8 into main Sep 2, 2022
@alex-page alex-page deleted the rm-components-foundations-json branch September 2, 2022 01:03
@github-actions github-actions bot mentioned this pull request Sep 2, 2022
alex-page pushed a commit that referenced this pull request Sep 2, 2022
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.


# Releases
## @shopify/[email protected]

### Minor Changes

-   [#6890](#6890) [`267e1a9bd`](267e1a9) Thanks [@alex-page](https://github.com/alex-page)! - Add deprecated scss API to stylelint-polaris and use regex tests in the config

## @shopify/[email protected]

### Patch Changes

-   [#6840](#6840) [`90f325460`](90f3254) Thanks [@AndrewMusgrave](https://github.com/AndrewMusgrave)! - Removed additional reflows from IndexTable

## [email protected]

### Minor Changes

-   [#7074](#7074) [`ddfacd855`](ddfacd8) Thanks [@alex-page](https://github.com/alex-page)! - Replace data/\*.json files with build time .cache/site.json


-   [#7082](#7082) [`8ebb9fc3c`](8ebb9fc) Thanks [@selenehinkley](https://github.com/selenehinkley)! - Large edit of /contributing


-   [#7087](#7087) [`43ea7e5d5`](43ea7e5) Thanks [@alex-page](https://github.com/alex-page)! - Add automation to generate .cache/nav.json

### Patch Changes

-   [#7037](#7037) [`7dafdee00`](7dafdee) Thanks [@alex-page](https://github.com/alex-page)! - Move header logic to the API and out of next.config.js


-   [#7075](#7075) [`5933fc547`](5933fc5) Thanks [@alex-page](https://github.com/alex-page)! - Run gen-assets on build of website

-   Updated dependencies \[[`90f325460`](90f3254)]:
    -   @shopify/[email protected]

## [email protected]

### Patch Changes

-   Updated dependencies \[[`90f325460`](90f3254)]:
    -   @shopify/[email protected]

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants