hexo-theme-doc icon indicating copy to clipboard operation
hexo-theme-doc copied to clipboard

Customizing page header

Open Amy-Lynn opened this issue 6 years ago • 2 comments

I'm new to Hexo and hexo-theme-doc, so there may be something I'm missing here.

I'm migrating a bunch of docs from a different markdown doc solution. I previously already had each page tagged with some metadata (including title). Rather than defining the page title twice (once as metadata and manually typing it out at the top of the page, I'd like the customize the page layout to automatically put the title in an <h1> tag (along with displaying some other metadata I have defined, like audience and description).

I think I really just want https://github.com/zalando-incubator/hexo-theme-doc/blob/master/layout/page.ejs#L6 to be

      <div id="page-content" class="doc-formatting">
        <h1><%- page.title%></h1>
        <hr/>
        <%- page.content %>
        <div id="react-support-footer-root"></div>
      </div>

Is there an existing way to do this?

Happy to submit a PR (defining a partial there that people could insert?), but wanted to confirm the approach.

Thanks!

Amy-Lynn avatar Dec 27 '18 19:12 Amy-Lynn

@Amy-Lynn Yep can definitely be done but it should be an opt-in to don't introduce a breaking-change. You can use an option that can be provided by the user in the configuration file.

Something like...

theme_config:
   auto_page_title: true # default to false

WDYT?

I will be happy to see a PR implementing it!

BTW I will just use a simple <h1> without <hr>.

rbarilani avatar Jan 01 '19 11:01 rbarilani

Or maybe we can use the project_partial functionality so a user as you will be able to introduce a custom template for the start of the page, in this way it will be more flexible.

See how the helper is used here in the layout.

rbarilani avatar Jan 01 '19 11:01 rbarilani