Permalink
Browse files

improve postcss api support

  • Loading branch information...
1 parent e80d721 commit 378227fd5fad80dd605b34bc830459b19e02f0a5 @igoradamenko committed Jan 7, 2017
Showing with 66 additions and 16 deletions.
  1. +25 −2 dev/docs/download.pug
  2. +16 −0 dev/docs/index.pug
  3. +13 −2 docs/download.html
  4. +2 −0 docs/index.html
  5. +10 −12 index.js
View
@@ -22,7 +22,30 @@ include _mixins.pug
a(href="https://github.com/igoradamenko/awsm.css/archive/master.zip") download tarball of the project
| .
- section
+ section#postcss
+ h2 PostCSS API
+
+ p
+ | If you install
+ = ' '
+ a(
+ href="https://www.npmjs.com/package/awsm.css",
+ title="awsm.css in npm registry",
+ target="_blank"
+ ) npm package
+ | , you can use library as PostCSS plugin:
+
+ -
+ var code = 'const postcss = require(\'postcss\');\n' +
+ 'const awsm = require(\'awsm.css\');\n' +
+ '\n' +
+ 'postcss([awsm()]).process(\'a {color: red}\').then(result => {\n' +
+ ' console.log(result.css); // awsm.css prepends your CSS \n' +
+ '});'
+
+ +code-block= code
+
+ section#license
h2 License
p
@@ -35,7 +58,7 @@ include _mixins.pug
| The MIT License places almost no restrictions on what you can do with this lib.
| You are free to use it in commercial projects as long as the copyright is left intact.
- section
+ section#credits
h2 Credits
p
View
@@ -50,6 +50,22 @@ include _mixins.pug
+code-block <link href="https://fonts.googleapis.com/css?family=PT+Sans|PT+Serif:400,400i,700,700i&subset=cyrillic" rel="stylesheet">
+ p
+ | It also available as the
+ = ' '
+ a(
+ href="https://www.npmjs.com/package/awsm.css",
+ title="awsm.css in npm registry",
+ target="_blank"
+ ) npm package
+ | , which supports
+ = ' '
+ a(
+ href="download.html#postcss",
+ title="Example of usage as PostCSS plugin"
+ ) PostCSS API
+ | .
+
section
h2 Why?
View
@@ -31,7 +31,18 @@
</p>
<p>You also can <a href="https://github.com/igoradamenko/awsm.css/archive/master.zip">download tarball of the project</a>.
</p>
- <section>
+ <section id="postcss">
+ <h2>PostCSS API</h2>
+ <p>If you install <a href="https://www.npmjs.com/package/awsm.css" title="awsm.css in npm registry" target="_blank">npm package</a>, you can use library as PostCSS plugin:
+ </p>
+ <pre><code>const postcss = require('postcss');
+const awsm = require('awsm.css');
+
+postcss([awsm()]).process('a {color: red}').then(result =&gt; {
+ console.log(result.css); // awsm.css prepends your CSS
+});</code></pre>
+ </section>
+ <section id="license">
<h2>License</h2>
<p>aswm.css licensed under <a href="http://en.wikipedia.org/wiki/MIT_License">the MIT</a>.
</p>
@@ -40,7 +51,7 @@
You are free to use it in commercial projects as long as the copyright is left intact.
</p>
</section>
- <section>
+ <section id="credits">
<h2>Credits</h2>
<p>Thanks to <a href="https://www.instagram.com/xnmlsx/" title="@xnmlsx in Instagram" target="_blank">Anastasia Medvedeva</a> for photo & video used in examples.
</p>
View
@@ -39,6 +39,8 @@
<p>And if you want to get beautiful fonts, add “<a href="https://www.google.com/fonts/specimen/PT+Serif" title="PT Serif in Google Fonts" target="_blank">PT Serif</a>” and “<a href="https://www.google.com/fonts/specimen/PT+Sans" title="PT Sans in Google Fonts" target="_blank">PT Sans</a>” from Google Fonts:
</p>
<pre><code>&lt;link href="https://fonts.googleapis.com/css?family=PT+Sans|PT+Serif:400,400i,700,700i&amp;subset=cyrillic" rel="stylesheet"&gt;</code></pre>
+ <p>It also available as the <a href="https://www.npmjs.com/package/awsm.css" title="awsm.css in npm registry" target="_blank">npm package</a>, which supports <a href="download.html#postcss" title="Example of usage as PostCSS plugin">PostCSS API</a>.
+ </p>
</section>
<section>
<h2>Why?</h2>
View
@@ -2,17 +2,15 @@ var fs = require('fs');
var path = require('path');
var postcss = require('postcss');
-module.exports = {
- postcss: postcss.plugin('postcss-awsm-css', function () {
- return function(css) {
- return new Promise(function(resolve) {
- var filepath = path.join(__dirname, 'dist', 'awsm.min.css');
- var filecontent = fs.readFileSync(filepath, 'utf8');
+module.exports = postcss.plugin('postcss-awsm-css', function () {
+ return function(css) {
+ return new Promise(function(resolve) {
+ var filepath = path.join(__dirname, 'dist', 'awsm.min.css');
+ var filecontent = fs.readFileSync(filepath, 'utf8');
- css.prepend(filecontent);
+ css.prepend(filecontent);
- resolve();
- })
- };
- })
-};
+ resolve();
+ })
+ };
+});

0 comments on commit 378227f

Please sign in to comment.