npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hexo-helper-partial-page

v1.0.1

Published

Hexo helper plugin for including and rendering partial content.

Downloads

2

Readme

hexo-helper-partial-page

node npm version npm downloads GitHub release MIT License

Hexo helper plugin for including and rendering partial content.

This plugin adds 2 helpers: partial_page and partial_content.

partial_page is useful when you want to write contents on separate files and render them using respective theme templates. partial_page synchronously reads a given file in source folder, renders the file as a single page using partial helper, and outputs rendered HTML directly at the helper tag position.

partial_content is essentially same with partial_page but this helper does not render a page with partial helper. partial_content synchronously reads a given file in source folder, renders the file with matching renderer plugin, and outputs rendered HTML directly at the helper tag position.

See Usage section for more details.

Installation

$ npm install hexo-helper-partial-page --save

Usage

For example, put a source file with front-matter in source/_partials folder like this:

file: source/_partials/part.md

---
layout: partial
---
# H1

Some text

1. First ordered list item
1. Another item

Put a simple layout file in your theme's layout folder like this:

file: layout/partial.ejs

<div class="part-wrapper">
  <div class="part-content">
    <%- page.content %>
  </div>
</div>

Then, add partial_page tag in your EJS template:

<%- partial_page('_partials/part.md') %>

Yields:

<div class="part-wrapper">
  <div class="part-content">
    <h1 id="H1"><a href="#H1" class="headerlink" title="H1"></a>H1</h1><p>Some text</p>
<ol>
<li>First ordered list item</li>
<li>Another item</li>
</ol>

  </div>
</div>

Meanwhile, if you add partial_content tag in your EJS template:

<%- partial_content('_partials/part.md') %>

Yields:

<h1 id="H1"><a href="#H1" class="headerlink" title="H1"></a>H1</h1><p>Some text</p>
<ol>
<li>First ordered list item</li>
<li>Another item</li>
</ol>

Make sure to use <%- partial_page() %> and not <%= partial_page() %> to prevent EJS from escaping the generated string.

Local Variables & Fragment Caching

partial_page accepts 2nd and 3rd parameters same with partial helper.

You can define local variables by passing the 2nd parameter:

<%- partial_page('_partials/part.md', {title: 'Hello World'}) %>

You can enable fragment caching with the 3rd parameter:

<%- partial_page('_partials/part.md', {}, {cache: true}) %>

Configurations

partial_page can parse and render any files saved in the source folder. At the same time, you can put files in source/_partials/ folder, or source/deep/depth/folder/_partials/ folder for example.

Source files saved in the _partials folder are almost same with other source files except they will be removed from the route list and not generate particular HTML files.

You can change the name of _partials folder which has this feature adding partial_dir to _config.yml.

partial_dir: _partials

License

MIT