Skip to content

Support for expressive layouts with page.md#944

Merged
yamgent merged 3 commits into
MarkBind:masterfrom
crphang:refactor-layouts
Jan 28, 2020
Merged

Support for expressive layouts with page.md#944
yamgent merged 3 commits into
MarkBind:masterfrom
crphang:refactor-layouts

Conversation

@crphang

@crphang crphang commented Nov 24, 2019

Copy link
Copy Markdown
Contributor

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

yamgent commented Nov 25, 2019

Copy link
Copy Markdown
Member

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

crphang commented Dec 21, 2019

Copy link
Copy Markdown
Contributor Author

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
Comment thread test/functional/test_site_convert/expected/contents/topic1.html Outdated
@crphang crphang changed the title Support for expressive layouts with page.md WIP: Support for expressive layouts with page.md Dec 23, 2019
Comment thread test/functional/test_site_templates/test_default/expected/index.html Outdated
@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

yamgent commented Dec 28, 2019

Copy link
Copy Markdown
Member

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

@yamgent yamgent left a comment

Copy link
Copy Markdown
Member

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.

Comment thread docs/userGuide/syntax/pageLayouts.mbdf Outdated
Comment thread test/functional/test_sites Outdated
Comment thread test/functional/test_site_expressive_layout/_markbind/layouts/default/page.md Outdated
Comment thread test/functional/test_site_expressive_layout/index.md
Comment thread src/Page.js Outdated
Comment thread src/Page.js
Comment thread src/Page.js
…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

crphang commented Jan 15, 2020

Copy link
Copy Markdown
Contributor Author

Ready for review

Comment thread docs/userGuide/syntax/pageLayouts.mbdf
Comment thread docs/userGuide/syntax/pageLayouts.mbdf Outdated
Comment thread docs/userGuide/syntax/pageLayouts.mbdf Outdated
@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
Copy Markdown
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