README
@prpl/core
This module consists of four parts:
- Interpolation functions
- Library functions
- Client-side JavaScript files
- TypeScript types
Dependencies
@prpl/core
has one dependency: marked
, a markdown compiler. Reasons
for relying on it include:
- It is not practical to implement a markdown compiler within the PRPL library
- It is fair to assume that most users will author content in markdown given its ubiquity
marked
itself has zero dependencies and is actively maintained
In the future it may make sense to externalize this dependency, but given the above reasons it is included for now.
Interpolation functions
Core functions that take source code as input, interpolate content as needed and output files for consumption in the browser. All functions have types and explicit comments in the source files so function signatures are omitted here.
Function | Description |
---|---|
interpolate |
Entry point that recursively walks the source file system tree |
interpolateHTML |
Interpolates an HTML file found in interpolate |
interpolateList |
Interpolates a <prpl> tag of type list |
interpolatePage |
Interpolates a <prpl> tag of type page |
parsePRPLAttributes |
Parses attributes of a <prpl> tag |
parsePRPLMetadata |
Parses metadata at the top of each content file |
transformMarkdown |
Transforms markdown into HTML |
Library functions
A mix of extended builtin functions and PRPL-specific functions.
Function | Description |
---|---|
cache |
In-memory cache that supports user-defined partitions |
cwd |
Calculates current working directory relative to the calling file |
ensureDir |
Ensure a directory exists given an absolute path |
ensureFile |
Ensure a file exists given an absolute path |
exists |
Check whether an entity exists given an absolute path |
generateFileSystemTree |
Generates an object that represents a file system |
generateOrRetrieveFileSystemTree |
Retrieve a cached file system tree or generate and cache a new one |
log |
Console wrapper providing context and color |
readDirSafe |
Read only directories that have access permission |
Client-side JavaScript files
Unless the user opts-out via the options argument in interpolate
, this module
will include 3 small JavaScript files in the site to enable the PRPL pattern at runtime.
File | Description |
---|---|
prefetch |
Schedule prefetch requests for links found in the current page |
prefetchWorker |
Worker that executes prefetch requests off the main thread |
router |
Router that serves prefetched HTML or gracefully degrades to browser-native routing |
Types
TypeScript types that are used in all PRPL modules.
See PRPL types.