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

feat: build toc and dashboard in hugo #1122

Merged
merged 14 commits into from
Sep 2, 2020
Merged

feat: build toc and dashboard in hugo #1122

merged 14 commits into from
Sep 2, 2020

Conversation

olizilla
Copy link
Collaborator

@olizilla olizilla commented Aug 28, 2020

Avoid building the ToC and the dashboard on the client side by parse data from dom and building the toc from data.

Generates a toc.json file in the hugo data dir, which is then used by the toc partial and the dashboard-spec shortcode.

example toc.json

[
  {
    "id": "intro",
    "number": "1",
    "tagName": "H1",
    "text": "Introduction",
    "page": true,
    "dashboardWeight": "0.2",
    "dashboardAudit": "n/a",
    "dashboardAuditURL": "",
    "dashboardAuditDate": "",
    "dashboardState": "reliable",
    "children": [
      {
        "id": "intro__spec-status",
        "number": "1.1",
        "tagName": "H2",
        "text": "Spec Status",
        "page": false,
        "dashboardWeight": "0.2",
        "dashboardAudit": "n/a",
        "dashboardAuditURL": "",
        "dashboardAuditDate": "",
        "dashboardState": "reliable",
        "children": [

TODO

  • ensure livereload picks up edits.
  • add watch mode for dom parser
  • tidy up
  • build dashboard from data

fixes #1125

License: MIT
Signed-off-by: Oli Evans [email protected]

...parse data from dom. build toc from data.

an experiment in not building the toc client side. instead we build the site without a toc, parse the dom, build the data model, write the toc model to json in the hugo data dir, which then lets us build the toc from data. gross, but it means the toc isnt built in the client, which is worth it, as it explodes on mobile.

License: MIT
Signed-off-by: Oli Evans <[email protected]>
License: MIT
Signed-off-by: Oli Evans <[email protected]>
@olizilla olizilla requested a review from hugomrdias August 31, 2020 09:32
@olizilla
Copy link
Collaborator Author

@hugomrdias local testing shows we can have hugo render to disk in dev mode, parse the generated dom, write the toc model as JSON to the hugo data dir, and have hugo pick up the change, and rebuild the ToC 🎉

Next up i'm going to move the spec dashboard back to hugo but this time built from the toc model.

Would be great to get your eyes on it in the mean time to double check this is not too outrageous.

License: MIT
Signed-off-by: Oli Evans <[email protected]>
@hugomrdias hugomrdias linked an issue Sep 1, 2020 that may be closed by this pull request
use the data in toc.json to build out the dashboard, rather than doing it client side.

License: MIT
Signed-off-by: Oli Evans <[email protected]>
@hugomrdias
Copy link
Contributor

LGTM can you make it work with the diagrams watcher ? we should use only one watcher.
maybe rename diagrams.js to pipelines and pack everything into a single watcher.

License: MIT
Signed-off-by: Oli Evans <[email protected]>
License: MIT
Signed-off-by: Oli Evans <[email protected]>
License: MIT
Signed-off-by: Oli Evans <[email protected]>
@hugomrdias
Copy link
Contributor

hidden toc sections are only actually hidden at runtime with js, can we build the toc already hidden at build time ?

@olizilla olizilla changed the base branch from beta to master September 1, 2020 11:01
@olizilla olizilla changed the title wip: build toc from data. feat: build toc and dashboard in hugo Sep 1, 2020
@olizilla olizilla marked this pull request as ready for review September 1, 2020 11:02
@olizilla
Copy link
Collaborator Author

olizilla commented Sep 1, 2020

hidden toc sections are only actually hidden at runtime with js, can we build the toc already hidden at build time ?

Done!

GTM can you make it work with the diagrams watcher ? we should use only one watcher. maybe rename diagrams.js to pipelines and pack everything into a single watcher.

Will do in separate PR

Copy link
Contributor

@hugomrdias hugomrdias left a comment

Choose a reason for hiding this comment

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

the build is not minifying the output html

@olizilla
Copy link
Collaborator Author

olizilla commented Sep 2, 2020

@hugomrdias the npm run script build is minifying the html output with the --minify flag to hugo, there is no change there. I've compared the output and the only diffs are the inclusion of the ToC & Dashboard, and the cache busting values on all images.

The dev build probably doesn't minify the output, but I dont see a problem there.

@hugomrdias
Copy link
Contributor

I know but some the preview url doesnt load the minified html

hugomrdias
hugomrdias previously approved these changes Sep 2, 2020
- add watch.js to configure chokidar.
- pass watcher to each tool via an exported `configureWatcher` method.
- allow tools to be run as scripts or required as modules


License: MIT
Signed-off-by: Oli Evans <[email protected]>
@olizilla olizilla merged commit eb7bd35 into master Sep 2, 2020
@olizilla olizilla deleted the tic-toc branch September 2, 2020 15:29
hugomrdias added a commit that referenced this pull request Sep 7, 2020
* master: (27 commits)
  fix(content): filecoin VM interface update (#1056)
  fix(content): chainsync section update (#1123)
  fix(content): libraries section update (#1115)
  fix: show hugo errors on build
  docs: tidy up the readme, add toc. (#1141)
  fix: reword stacked drg missing link text"
  fix: fix broken refs and change warns to errors (#1139)
  fix: import meter css (#1140)
  feat: build toc and dashboard in hugo (#1122)
  feat: show wip and reliable in progress bar (#1137)
  content: fix typo plus remove definition of weight (#1138)
  fix: css for label style and dashboard link (#1136)
  feat: add symbol embeds and listing (#1126)
  v1.0.1
  feat(tooling): release scripts
  v1.0.0
  chore: update readme and package.json
  fix: update dns link
  fix: fix broken links
  fix(content): FIL VM System Actors Update (#1061)
  ...
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.

Issues building ToC and Dashboard on the client
2 participants