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

site.json: Add configuration options to specify head, footer, site-nav for specific pages #389

Closed
yamgent opened this issue Jul 30, 2018 · 7 comments · Fixed by #439
Closed

Comments

@yamgent
Copy link
Member

yamgent commented Jul 30, 2018

Tell us about your environment

  • MarkBind Version: 1.10.0

As mentioned in se-edu/learningresources#62 (comment):

Also feels kind of obtuse to be adding head: head.md to every document as in se-edu/learningresources@90f6492 , can it be set in the site.json?

Reconsider the design for head: head.md to be more simple for the user to use. Perhaps some additional configuration settings in site.json?

Currently, footer and site-nav has the same design issue.

@damithc
Copy link
Contributor

damithc commented Jul 30, 2018

Some options:

  • Introduce a _markbind/defaults folder. If it contains any of these files, apply them to all pages containing a frontmatter: default-navigation. md, default-head.md, default-footer.md, default-styles.css, default-scripts.js
  • In site.json, allow specifing head, footer, etc. to the whole site, or to a glob.

@pyokagan
Copy link

To add: there's also {{ navbar | safe }} on every single document as well: https://github.com/se-edu/learningresources/search?q=%7B%7Bnavbar+%7C+safe%7D%7D&unscoped_q=%7B%7Bnavbar+%7C+safe%7D%7D

In the case of {{ navbar | safe }}, the issue is that there is no way to define content that should appear at the start of every document (i.e. just below <body>). (and, to make it more generic: a way to make content appear just before the closing </body> as well.)

@pyokagan
Copy link

To add: there's also {{ navbar | safe }} on every single document as well:

And <div class="website-content"> as well, so a feature to allow content to appear after <body> and before </body> would definitely be appreciated.

@yamgent
Copy link
Member Author

yamgent commented Jul 30, 2018

And <div class="website-content"> as well, so a feature to allow content to appear after <body> and before </body> would definitely be appreciated.

Perhaps we can follow something like Jekyll's layout system, where the user has complete freedom in specifying how the <body> is structured:

_markbind/defaults/body.md

{{ navbar | safe }}
<div class="website-content">
  <markbind-content /> <!-- reserved MarkBind HTML tag so MarkBind know where to insert the website content -->
</div>

@jamos-tay
Copy link
Contributor

Some options:

  • Introduce a _markbind/defaults folder. If it contains any of these files, apply them to all pages containing a frontmatter: default-navigation. md, default-head.md, default-footer.md, default-styles.css, default-scripts.js
  • In site.json, allow specifing head, footer, etc. to the whole site, or to a glob.

Reviving this issue as in came up during discussion.

How about a _markbind/templates folder that contains multiple subfolders with template files:

_markbind/templates/default/
navigation.md, head.md, footer.md, styles.css, scripts.js

_markbind/templates/templateA/
navigation.md, head.md, footer.md, styles.css, scripts.js

_markbind/templates/templateB/
navigation.md, head.md, footer.md, styles.css, scripts.js

Users can then specify which template to use within the site.json:

{
  "glob": "A/*.md",
  "template": "templateA"
}
,
{
  "glob": "B/*.md",
  "template": "templateB"
}
,
{
  "glob": "C/*.md" // No template, apply default
}

The files in the corresponding template folder will be applied to all files in the glob.

We can also have a default template which will be applied to all pages, unless a different template is specified. This folder can be generated on init with all files empty from the start, so it's more convenient for the user.

@yamgent
Copy link
Member Author

yamgent commented Sep 19, 2018

That certainty sounds feasible. Of course, if the individual .md files manually specify the head: etc in the frontmatter, they take utmost priority over the template.

Also was thinking whether we might want to consider allowing the user to specify a template: in the frontmatter as well. Can't see the benefits atm though.

@jamos-tay
Copy link
Contributor

That certainty sounds feasible. Of course, if the individual .md files manually specify the head: etc in the frontmatter, they take utmost priority over the template.

Also was thinking whether we might want to consider allowing the user to specify a template: in the frontmatter as well. Can't see the benefits atm though.

Yes I think that's a good idea. We could have cases where the user wants to apply a template to all files in a glob except one, he can then set template: default or something just for that file instead of messing around with weird file matching patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants