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

Support for expressive layouts with page.md #944

Merged
merged 3 commits into from
Jan 28, 2020

Conversation

crphang
Copy link
Contributor

@crphang crphang commented Nov 24, 2019

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] New feature

Resolves #631

Currently this is a WIP but the Proof of Concept generally working. The idea is for user to define a main page structure to allow users to define wrapper content around their main content.

For instance:

Code:
image

Result:
image

Definitely a lot more work to be done:

  • Because page need to be pre-processed (prior to parser), we have yet to process frontmatter which is required to pass in layout information. Figure out a way to process/wrap page after parser.
  • I currently hacked into Parser to make this work. Refactor some part of parser to take in data instead of file.
  • Layouts are currently not refreshed during hot reloading.

@yamgent
Copy link
Member

yamgent commented Nov 25, 2019

No comments so far for the current features that the prototype has, looking forward to the final implementation. 👍

Btw, if there are a lot of refactoring to be done, and those refactoring might also benefit other features (not necessary just for expressive layout), you might want to consider handling the refactoring in separate PRs, so that this PR doesn't get too big.

@crphang
Copy link
Contributor Author

crphang commented Dec 21, 2019

Keeping things super simple for now to ensure that this PR does not go out of hand:

  • Fix problem with parsing and undoing refactor
  • User Guide update
  • Update test

Important functional and non-functional requirements that this PR takes care of:

  1. Allowing user to define any layout style and embed main body content - Core Feature
  2. Backward compatibility of existing users if they upgrade.

Many more work to be done but will be separated to different PRs. A non-exhaustive list include:

  1. Refactoring layouts logic from insertion of header, footer, ...
  2. Removing inference of layouts from frontmatter. Currently the code takes frontmatter as source of truth instead of the Page property. This needs to be updated but it is not that simple.
  3. Expressive Layouts Validation. If users change the keyword of expressive layout from MAIN_CONTENT_BODY to something else, pages will not work. We should have validation (for templates created by developers) and soft failure (for user input changes) to skip expressive layouts if user make wrong changes.

@crphang crphang changed the title [WIP] Support for expressive layouts with page.md Support for expressive layouts with page.md Dec 22, 2019
@yamgent yamgent self-requested a review December 23, 2019 01:33
@crphang crphang changed the title Support for expressive layouts with page.md WIP: Support for expressive layouts with page.md Dec 23, 2019
@crphang crphang changed the title WIP: Support for expressive layouts with page.md Support for expressive layouts with page.md Dec 25, 2019
@yamgent yamgent self-requested a review December 27, 2019 06:49
@yamgent
Copy link
Member

yamgent commented Dec 28, 2019

Just to let you know that I will take a look at this soon!

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

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

Appreciate your patience. I left some comments, but I feel that the comment with the '⭐⭐' as the first line is probably the most important thing that you might want to address first.

docs/userGuide/syntax/pageLayouts.mbdf Outdated Show resolved Hide resolved
test/functional/test_sites Outdated Show resolved Hide resolved
src/Page.js Outdated Show resolved Hide resolved
src/Page.js Show resolved Hide resolved
src/Page.js Show resolved Hide resolved
…into user defined expressive layouts template
@crphang crphang force-pushed the refactor-layouts branch 3 times, most recently from 09c4350 to 61d4bfc Compare January 13, 2020 12:24
@crphang
Copy link
Contributor Author

crphang commented Jan 15, 2020

Ready for review

docs/userGuide/syntax/pageLayouts.mbdf Outdated Show resolved Hide resolved
docs/userGuide/syntax/pageLayouts.mbdf Outdated Show resolved Hide resolved
@yamgent yamgent added this to the v2.9.2 milestone Jan 24, 2020
@yamgent yamgent merged commit bec1916 into MarkBind:master Jan 28, 2020
@yamgent yamgent mentioned this pull request Jan 28, 2020
{{ mainContentBody }}
</box>

which injects the actual page content in every page. This allows you to build layouts in different ways.
Copy link
Contributor

Choose a reason for hiding this comment

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

Reads better this way?

The page.md file of a layout should come with the reserved variable {{ MAIN_CONTENT_BODY }} which injects the actual page content in every page. This allows you to build layouts in different ways.

Alternatively, can be written this way (i.e., avoid breaking sentences across boxes):

The page.md file of a layout should come with the following reserved variable which injects the actual page content in every page.

{{ MAIN_CONTENT_BODY }}

This allows you to build layouts in different ways.

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.

Layouts: give a way to insert default content at top/bottom of the page body
3 participants