Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: If you want to create a plugin for Abell, what data and functions you would expect to be exported out of abell? #15

Closed
saurabhdaware opened this issue May 22, 2020 · 5 comments
Assignees
Labels
help wanted Extra attention is needed Idea A random idea before actually putting it out in code Need Feedback Need feedback on this issue question Further information is requested
Milestone

Comments

@saurabhdaware
Copy link
Member

This is how Abell works (as of v0.2.x)

  1. Get all the necessary data in programInfo variable (Reads the theme/[$slug]/index.abell, reads the abell.config.js, reads the directories in content/, prepares all the necessary variables)
    (Code: https://github.com/abelljs/abell/blob/master/src/content-generator.js#L89)
  2. build(programInfo) is called which loops through all .abell files and calls generateHTMLFile(path, programInfo) when it's a normal .abell file and generateContentFile(path, programInfo) when its [$slug]/index.abell.

Possible plugins

  • RSS Feed (Thanks @akash-joshi for the suggestion)
  • PWA (Way to create manifest.json, service workers, etc)
  • SiteMap Generator

I would love to know suggestions and feedback on how we can possibly make the plugin system.

@saurabhdaware saurabhdaware added Idea A random idea before actually putting it out in code Need Feedback Need feedback on this issue question Further information is requested labels May 22, 2020
@saurabhdaware
Copy link
Member Author

saurabhdaware commented May 22, 2020

So my first thought is to have plugins that look like this.
abell-rss-feed-plugin.js

function beforeBuild(programInfo) {
  // ... Nothing to do before build
}

function afterBuild(completeContent, programInfo) {
  const rssXML = getRssXMLFromContent(completeContent, programInfo);
  fs.writeFile('rss.xml', rssXML);
  return 
}

module.exports = {beforeBuild, afterBuild}

@saurabhdaware saurabhdaware added this to the v1.0.0 milestone May 22, 2020
@saurabhdaware saurabhdaware pinned this issue May 22, 2020
@saurabhdaware saurabhdaware added the help wanted Extra attention is needed label May 22, 2020
@saurabhdaware
Copy link
Member Author

Implemented this in some amount at feat-plugins-system branch

The first parameter in afterBuild, completeContent is not really needed since most of the information is there in programInfo and additional information can be read from the built files.

This was referenced Jun 7, 2020
@saurabhdaware
Copy link
Member Author

afterBuild and beforeBuild functions are added in v0.3.0, Here's an example plugin: https://github.com/saurabhdaware/abell-sitemap-plugin

@saurabhdaware saurabhdaware self-assigned this Jul 8, 2020
@saurabhdaware
Copy link
Member Author

Idea for source plugins:

function beforeBuild(programInfo, {createContent}) {
  const meta = {
    title: 'Blog from source'
  }

  const content = `# This is head
  ## This is subtitle
  nice
  `

  createContent(content, meta)

This will make it easy to build source plugin and will also help to handle data in standard way rather than relying on plugins to handle that.

@saurabhdaware saurabhdaware unpinned this issue Jul 18, 2020
@saurabhdaware
Copy link
Member Author

I think we have stable plugin system now. Any additional exports can be handled in separate issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed Idea A random idea before actually putting it out in code Need Feedback Need feedback on this issue question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant