New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

choo-dat-hypha

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

choo-dat-hypha

A Choo plugin for reading a content directory with Hypha

  • 0.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

choo-dat-hypha (experimental)

A Choo plugin for reading a content directory with Hypha

npm i choo-dat-hypha

Usage

Create a new Choo app and use the choo-dat-hypha plugin.

var choo = require('choo')
var app = choo()

app.use(require('choo-dat-hypha')())

if (!module.parent) app.mount('body')
else module.exports = app

Format some plain text files using smarkt fields.

title: Technopastoral
----
date: January 19, 2038
----
tags:
  - garden
  - engineering
----
text: To deprogram oneself necessitates keeping to very specific schedules, which are what Foucault, once again, described as techniques of the self, echoing Seneca. 

Organize them within a directory structure alongside media assets.

/content
  /about
    index.txt
  /blog
    /38-01-19-technopastoral
      index.txt
      header.jpg
  index.txt

Now your content gets loaded into your Choo app’s state, and a route is created for each of your pages!

Pattern

To easily access the data for each of your pages simply compare the state.href against your state.content object in a composable function.

// wrapper.js
var xtend = require('xtend')

module.exports = wrapper

function wrapper (view) {
  return function (state, emit) {
    var page = state.content[state.href || '/'] || { }
    return view(xtend(state, { page: page }), emit)
  }
}

Now simply wrap your views!

// view.js
var html = require('choo/html')
var wrapper = require('./wrapper')

module.exports = wrapper(view)

function view (state, emit) {
  return html`
    <body>
      The current page is ${state.page.title}
    </body>
  `
}

API

state

State is extended with these objects:

state.content = { }

state.site = {
  blueprints: { },
  config: { },
  info: { },
  loaded: false,
  p2p: false
}
state.events.CONTENT_LOAD

Emitting this event will reload state.content.

state.events.CONTENT_LOADED

Listen to this event for when content is loaded.

Todo

  • Read blueprints

FAQs

Package last updated on 06 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc