@shgysk8zer0/11ty-netlify 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
  <!-- markdownlint-disable -->
7
7
  ## [Unreleased]
8
8
 
9
+ ## [v1.0.4] - 2023-06-01
10
+
11
+ ### Fixed
12
+ - Add missing CommonJS version of `markdown-it` & `highlight.js` config
13
+
14
+ ## [v1.0.3] - 2023-06-01
15
+
16
+ ### Added
17
+ - Add util functions for PostCSS & Rollup
18
+ - Add `markddown-it` & `highlight.js` config for 11ty
19
+
20
+ ### Fixed
21
+ - Update GitHub Release Action with necessary permissions
22
+
9
23
  ## [v1.0.2] - 2023-05-21
10
24
 
11
25
  ### Fixed
package/markdown.cjs ADDED
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var MarkdownIt = require('markdown-it');
4
+ var hljs = require('highlight.js');
5
+
6
+ /* eslint-env node */
7
+
8
+
9
+ const markdownIt = new MarkdownIt({
10
+ html: true,
11
+ linkify: false,
12
+ breaks: true,
13
+ langPrefix: 'language-',
14
+ highlight: function(str, language) {
15
+ if (typeof str === 'string' && typeof hljs.getLanguage(language) !== 'undefined') {
16
+ try {
17
+ return `<pre class="hljs ${this.langPrefix}${language}"><code>${hljs.highlight(str, { language, ignoreIllegals: true }).value}</code></pre>`;
18
+ } catch(e) {
19
+ console.error(e);
20
+ return `<pre class="hljs"><code>${this.utils.escapeHtml(str)}</code></pre>`;
21
+ }
22
+ } else {
23
+ return `<pre class="hljs"><code>${this.utils.escapeHtml(str)}</code></pre>`;
24
+ }
25
+ }
26
+ });
27
+
28
+ exports.markdownIt = markdownIt;
package/markdown.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-env node */
3
+
4
+ import MarkdownIt from 'markdown-it';
5
+ import hljs from 'highlight.js';
6
+
7
+ export const markdownIt = new MarkdownIt({
8
+ html: true,
9
+ linkify: false,
10
+ breaks: true,
11
+ langPrefix: 'language-',
12
+ highlight: function(str, language) {
13
+ if (typeof str === 'string' && typeof hljs.getLanguage(language) !== 'undefined') {
14
+ try {
15
+ return `<pre class="hljs ${this.langPrefix}${language}"><code>${hljs.highlight(str, { language, ignoreIllegals: true }).value}</code></pre>`;
16
+ } catch(e) {
17
+ console.error(e);
18
+ return `<pre class="hljs"><code>${this.utils.escapeHtml(str)}</code></pre>`;
19
+ }
20
+ } else {
21
+ return `<pre class="hljs"><code>${this.utils.escapeHtml(str)}</code></pre>`;
22
+ }
23
+ }
24
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgysk8zer0/11ty-netlify",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "engines": {
5
5
  "node": ">=18.13.0"
6
6
  },
@@ -19,6 +19,7 @@
19
19
  "scripts": {
20
20
  "test": "npm run lint && npm run build",
21
21
  "preversion": "npm test",
22
+ "prepare": "npm run build:markdown",
22
23
  "create:lock": "npm i --package-lock-only",
23
24
  "version:bump": "npm run version:bump:patch",
24
25
  "version:bump:patch": "npm version --no-git-tag-version patch",
@@ -33,6 +34,7 @@
33
34
  "build": "npm run build:icons && npm run build:css && npm run build:js",
34
35
  "build:css": "if [ -f 'postcss.config.js' ]; then postcss ${npm_package_config_dir_css}index.css -o ${npm_package_config_dir_css}index.min.css; fi",
35
36
  "build:js": "if [ -f 'rollup.config.js' ]; then rollup --config; fi",
37
+ "build:markdown": "rollup -c markdown.config.js",
36
38
  "build:icons": "if [ -f ${npm_package_config_icons} ]; then $(svg-sprite-generate -c ${npm_package_config_icons} -o 'img/icons.svg'); fi"
37
39
  },
38
40
  "repository": {
@@ -54,14 +56,16 @@
54
56
  "@11ty/eleventy": "^2.0.1",
55
57
  "@rollup/plugin-terser": "^0.4.1",
56
58
  "@shgysk8zer0/11ty-filters": "^0.0.2",
59
+ "@shgysk8zer0/importmap": "^1.0.2",
57
60
  "@shgysk8zer0/rollup-import": "^1.0.0",
58
61
  "cssnano": "^6.0.0",
59
62
  "cssnano-preset-default": "^6.0.0",
60
63
  "eslint": "^8.0.1",
61
- "eslint-plugin-async-await": "0.0.0",
62
64
  "eslint-plugin-frontmatter": "^0.0.8",
65
+ "highlight.js": "^11.8.0",
63
66
  "htmlhint": "^1.1.4",
64
67
  "js-yaml": "^4.1.0",
68
+ "markdown-it": "^13.0.1",
65
69
  "netlify-cli": "^15.0.0",
66
70
  "postcss": "^8.4.7",
67
71
  "postcss-cli": "^10.0.0",
@@ -73,11 +77,9 @@
73
77
  "postcss-preset-env": "^8.0.0",
74
78
  "postcss-url": "^10.1.3",
75
79
  "rollup": "^3.2.2",
76
- "rollup-plugin-url-resolve": "^0.2.0",
77
80
  "stylelint": "^15.0.0",
78
81
  "stylelint-config-recommended": "^12.0.0",
79
82
  "stylelint-config-standard": "^33.0.0",
80
- "svg-sprite-generator": "0.0.7",
81
- "svgo": "^3.0.0"
83
+ "svg-sprite-generator": "0.0.7"
82
84
  }
83
85
  }
@@ -0,0 +1,15 @@
1
+ /* eslint-env node */
2
+ import pcImport from 'postcss-import';
3
+ import pcURL from 'postcss-url';
4
+ import pcImportURL from 'postcss-import-url';
5
+ import pcEnv from 'postcss-preset-env';
6
+ import pcDiscardComments from 'postcss-discard-comments';
7
+ import pcCustomProperties from 'postcss-custom-properties';
8
+ import pcMediaMinMax from 'postcss-media-minmax';
9
+ import CSSNano from 'cssnano';
10
+ import postcssNesting from 'postcss-nesting';
11
+
12
+ export const plugins = [
13
+ pcImport, pcURL,pcImportURL, pcEnv, pcDiscardComments, pcCustomProperties,
14
+ pcMediaMinMax, CSSNano, postcssNesting,
15
+ ];
@@ -0,0 +1,6 @@
1
+ import { plugins } from './plugins.js';
2
+
3
+ export const getConfig = ({ inline = false }) => ({
4
+ map: { inline },
5
+ plugins,
6
+ });
@@ -0,0 +1,8 @@
1
+ import terser from '@rollup/plugin-terser';
2
+ import { rollupImport } from '@shgysk8zer0/rollup-import';
3
+ import { importmap } from '@shgysk8zer0/importmap';
4
+
5
+ export const plugins = [
6
+ rollupImport(importmap),
7
+ terser(),
8
+ ];
@@ -0,0 +1,65 @@
1
+ import { extname } from 'node:path';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { plugins as PLUGINS } from './plugins.js';
4
+
5
+ export const ONWARN = warning => {
6
+ if (warning.code === 'MISSING_GLOBAL_NAME') {
7
+ throw new Error(warning.message);
8
+ } else if (warning.code !== 'CIRCULAR_DEPENDENCY') {
9
+ console.warn(`(!) ${warning.message}`);
10
+ }
11
+ };
12
+
13
+ export const EXTERNAL = ['node:fs', 'node:fs/promises', 'node:crypto', 'node:path'];
14
+ export const GLOBALS = {};
15
+ export const DEFAULT_EXT = '.min.js';
16
+ export const ESLINT_CONFIG = '.eslintrc.json';
17
+ export const EXTS = {
18
+ '.cjs': ['cjs', 'commonjs'],
19
+ '.mjs': ['es', 'esm', 'module'],
20
+ '.min.js': ['iife'],
21
+ };
22
+
23
+ export function getExtension(format) {
24
+ const found = Object.entries(EXTS).find(([, formats]) => formats.includes(format));
25
+ return found[0];
26
+ }
27
+
28
+ export function getFormat(ext) {
29
+ if (ext in EXTS) {
30
+ return EXTS[ext][0];
31
+ }
32
+ }
33
+
34
+ export async function getConfig(input, {
35
+ format = 'iife',
36
+ sourcemap = true,
37
+ external = EXTERNAL,
38
+ plugins = PLUGINS,
39
+ onwarn = ONWARN,
40
+ eslintConfig = ESLINT_CONFIG,
41
+ } = {}) {
42
+ const ext = getExtension(format);
43
+ const { globals = {}} = typeof eslintConfig === 'string'
44
+ ? await getESLintConfig(eslintConfig)
45
+ : {};
46
+
47
+ return {
48
+ input, external, onwarn, plugins,
49
+ output: {
50
+ file: input.replace(extname(input), ext),
51
+ format, sourcemap, globals,
52
+ },
53
+ };
54
+ }
55
+
56
+ export async function getESLintConfig(path = ESLINT_CONFIG) {
57
+ try {
58
+ const config = await readFile(path, { encoding: 'utf8' });
59
+
60
+ return JSON.parse(config);
61
+ } catch(err) {
62
+ console.error(err);
63
+ return GLOBALS;
64
+ }
65
+ }