aboutsummaryrefslogtreecommitdiffstats
path: root/src/css.11ty.js
blob: 3a5b9df69593c079f378912dad1f447b3453c485 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require('fs')
const path = require('path')
const postcss = require('postcss')

module.exports = class {
  async data() {
    return {
      inputs: [
        'index.css',
        'prism.css'
      ],

      pagination: {
        data: 'inputs',
        alias: 'inputfiles',
        size: 1
      },

      permalink: ({ inputfiles }) => `/${inputfiles}`,

      eleventyExcludeFromCollections: true
    }
  };

  async render({ inputfiles}) {
    const inputfile = path.join(__dirname, inputfiles);
    return await postcss([
      require('postcss-import'),
      require('autoprefixer'),
    ])
      .process(await fs.readFileSync(inputfile), {
        from: inputfile
      })
      .then(result => result.css)
  };
}