Comments (7)
Ok, now we have preProcessPosts(posts) and postProcessPosts(posts) hooks implemented. It looks in both theme/functions and antwar.config.js for functions. At this time there is still no plugin support, but the hooks system is prepared for it.
We just need to figure out how we want to define plugins. The nicest would be just an array om plugin names, but that will require some webpack alias magic to avoid doing require(unknownPluginName).
Second thing we need to do is to implement similar hooks for things inside the processing of each post, like url, date or even content. But I'll create a separate task for that.
from antwar.
From antwar.config.js
point of view the interface explained at #11 is likely enough. You just provide an object of objects (plugin name -> configuration). Plugin name maps to NPM by default but we could support paths just like in case of themes right now to make it more versatile.
A plugin itself could look something like this (index.js):
module.exports = {
preProcess: function(...) {},
process: function(...) {}, // needed???
postProcess: function(...) {},
}
This would be enough. We can add more hooks if/when needed.
from antwar.
Skipping process()
, at least for now. Otherwise that looks good.
If we assume plugins are installed in the site folder I suppose we can require("plugin/"+pluginName)
and have an alias: {'plugins': cwd + '/node_modules'}
from antwar.
Didn't get the require("plugin/"+pluginName)
strategy to work. We have to think of some other way. One alternative is that the config file just gives an array of plugin objects. That would mean they are required from within the config file and we don't have to care if they are npm modules, local things or just something that's declared directly in the config file.
Something like:
plugins: [
require('a-plugin-from-npm'),
{preProcessPosts: function(posts){…}},
require('./local-plugin.js')
]
Not sure that would work?
from antwar.
Yeah, I can see your point. Isn't that analogous to how functions
work now? Given that I can't see why this would fail.
from antwar.
I only see a possible issue with doing require's from there. But I'll try it.
from antwar.
As far as I can see preProcess/postProcess works now, even with require
. I set up a demo plugin to try this out, https://github.com/antwarjs/prevnext-plugin .
While at it I simplified the plugin contract a little bit (no need for extra functions
key). I think this might have been your original intention given the example above.
from antwar.
Related Issues (20)
- Cannot read property 'children' of undefined HOT 1
- Allow partial references to Markdown HOT 1
- Live examples? HOT 1
- ETIMEDOUT getting started HOT 2
- Site descriptions render unprocessed markdown HOT 3
- Site does not shrink to smaller screen sizes
- How to specify devtool for built JavaScript? HOT 2
- Reflect Content Structure in Routing Structure HOT 7
- Relative Links in Development vs. Production HOT 5
- Support Index Page Processing HOT 8
- Missing Title in Head
- Is there a roadmap about the antwar ? HOT 4
- Roadmap HOT 3
- Push redirects to a webpack plugin HOT 1
- React 16 HOT 2
- Antwar Interactive ID Resolving Bug HOT 1
- Use template-literal instead of EJS HOT 2
- Shared vendor bundle HOT 1
- Set title and description via rendered page
- Generated paths (js, and interactives) are not using the "publicPath" webpack config HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from antwar.