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 = var app = app if !moduleparent appelse moduleexports = 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.jsvar xtend = moduleexports = wrapper { return { var page = statecontentstatehref || '/' || return }}
Now simply wrap your views!
// view.jsvar html = var wrapper = moduleexports = { return html` The current page is `}
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