Skip to content
New issue

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

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

Already on GitHub? # to your account

Generalize content processing with markdown as default #4

Closed
jrehwaldt opened this issue Jan 7, 2016 · 15 comments
Closed

Generalize content processing with markdown as default #4

jrehwaldt opened this issue Jan 7, 2016 · 15 comments

Comments

@jrehwaldt
Copy link
Contributor

An option to add a post-processor would be nice. Basically, there could be a stack of content processors (per extension/glob pattern) with markdown being one of them, but that defeats the goal of an 'intentionally non-pluggable' static site generator. This would enable easy additions, which are not easily covered using nunjucks filters, such as emojis (#6).


Update: Made this issue focus on the generalization and extract the smiley request into #6.

@nikku
Copy link
Owner

nikku commented Jan 7, 2016

Sounds good. Can yon create a PR on this?

@jrehwaldt
Copy link
Contributor Author

Going good here 😄 Existing tests are green.

@jrehwaldt
Copy link
Contributor Author

How do I merge my super duper change now... 23f98f7

@nikku
Copy link
Owner

nikku commented Jan 8, 2016

An option (no guarantees):

# gives you a-commit-hash
git commit ... 
git fetch upstream
git checkout master
git reset --hard upstream/master
# applies your change in a-commit-hash on new master (without history)
git cherry-pick a-commit-hash 

@jrehwaldt
Copy link
Contributor Author

Warum einfach, wenn's auch kompliziert geht...

@nikku
Copy link
Owner

nikku commented Jan 8, 2016

Git skillz, for da win, wa 😉

@jrehwaldt
Copy link
Contributor Author

I didn't see you mention rebase. Skill loss all the way 😸

@nikku
Copy link
Owner

nikku commented Jan 8, 2016

🍰

@jrehwaldt
Copy link
Contributor Author

+1

@nikku
Copy link
Owner

nikku commented Jan 8, 2016

@jrehwaldt
Copy link
Contributor Author

@jrehwaldt jrehwaldt changed the title Support for Smileys Generalize content processing with markdown as default Jan 8, 2016
@nikku
Copy link
Owner

nikku commented Jan 8, 2016

Pluggable content processors are beyond the scope of this project.

There are a lot alternative solutions out there that offer that functionality already, i.e metalsmith that are 100% pluggable.

kartoffeldruck should work out of the box and do only one thing right: Flexible content generation with a powerful templating language in the back (Nunjucks) and a great way to write posts (Frontmatter + Markdown).

@nikku
Copy link
Owner

nikku commented Jan 8, 2016

Smilies can still be a great feature, just because they make up a great addition for writing blog posts.

jrehwaldt pushed a commit to jrehwaldt/kartoffeldruck that referenced this issue Jan 8, 2016
…rked as default processor for *.md files (compat behaviour). Implements nikku#4.

Processors can be defined in the configuration as follows:
```
{
  contentProcessors: {
    '*.md': function(content, page) { return marked(content); },
    '*': function(content, page) { return emoji(content); },
  }
}
```

Object keys are globs matched against the page's id (i.e., including relative path) using minimatch with the options `{ nocase: true, matchBase: true }`. Processor order is preserved, such that multiple matching processors are applied in the order defined.

Also adds tests for non-markdown file processing and aggregation based off the example structure.

Finally, the method `Kartoffeldruck.isMarkdown` is removed from the +public+ API.
@jrehwaldt
Copy link
Contributor Author

I can see this won't come so I'll close it...

nikku pushed a commit that referenced this issue Nov 11, 2017
A content processor is a function(content, page) that
processes the content and returns the processed result.

Multiple processors can now be defined in the configuration
via the contentProcessors property. It may be an object or fn.

```
{
  contentProcessors: {
    '*.md': function(content, page) { return marked(content); },
    '*': function(content, page) { return emoji(content); },
  }
}
```

Page ids are matched against the pattern; processor order is
preserved, so that multiple processors are used in order.

```
{
  contentProcessors: function(page) {
    // return applicable processors, single processor or none
    return [] || fn;
  }
}
```

Content processing can also be disabled entirely by configuring
contentProcessors=false.

Content will simply be kept as is, if no processors are defined.

Closes #4

BREAKING CHANGE:

* the method `Kartoffeldruck.isMarkdown` is not needed anymore and
  removed from the +public+ API.
@nikku
Copy link
Owner

nikku commented Nov 11, 2017

Closed via f89d412.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants