|
1 |
| -import { EleventyRenderPlugin } from "@11ty/eleventy"; |
2 |
| -import syntaxHighlightPlugin from "@11ty/eleventy-plugin-syntaxhighlight"; |
3 |
| -import scTable from "./src/_utils/scTable.js"; |
4 |
| -import scUri from "./src/_utils/scUri.js"; |
5 |
| -import sanitizeNumber from "./src/_utils/sanitizeNumber.js"; |
6 |
| -// const newGitHubIssueUrl = require("new-github-issue-url"); |
| 1 | +import {EleventyRenderPlugin} from '@11ty/eleventy'; |
| 2 | +import syntaxHighlightPlugin from '@11ty/eleventy-plugin-syntaxhighlight'; |
| 3 | +import scTable from './src/_utils/sc-table.js'; |
| 4 | +import scUri from './src/_utils/sc-uri.js'; |
| 5 | +import sanitizeNumber from './src/_utils/sanitize-number.js'; |
7 | 6 |
|
8 |
| -export default function (eleventyConfig) { |
9 |
| - eleventyConfig.addFilter("sc_uri", scUri); |
| 7 | +export default function eleventy(eleventyConfig) { |
| 8 | + eleventyConfig.addFilter('sc_uri', scUri); |
10 | 9 |
|
11 |
| - eleventyConfig.addFilter("newIssueUrl", (url) => { |
12 |
| - if (url.indexOf("gitlab")) { |
13 |
| - return; |
14 |
| - } |
15 |
| - }); |
| 10 | + eleventyConfig.addNunjucksAsyncShortcode('scTable', scTable); |
16 | 11 |
|
17 |
| - eleventyConfig.addNunjucksAsyncShortcode("sc_table", scTable); |
| 12 | + eleventyConfig.addLayoutAlias('report', 'report.njk'); |
18 | 13 |
|
19 |
| - eleventyConfig.addLayoutAlias("report", "report.njk"); |
| 14 | + eleventyConfig.addPlugin(EleventyRenderPlugin); |
| 15 | + eleventyConfig.addPlugin(syntaxHighlightPlugin); |
20 | 16 |
|
21 |
| - eleventyConfig.addPlugin(EleventyRenderPlugin); |
22 |
| - eleventyConfig.addPlugin(syntaxHighlightPlugin); |
| 17 | + eleventyConfig.addCollection('issues', collectionApi => |
| 18 | + collectionApi |
| 19 | + .getFilteredByGlob('src/report/issues/*.md') |
| 20 | + .filter( |
| 21 | + item => |
| 22 | + !(item.data.sc === undefined) && (item.data.sc.length > 0), |
| 23 | + ) |
| 24 | + .sort((a, b) => { |
| 25 | + const sortCriterionA = a.data.sc.sort()[0]; |
| 26 | + const sortCriterionB = b.data.sc.sort()[0]; |
23 | 27 |
|
24 |
| - eleventyConfig.addCollection("issues", function (collectionApi) { |
25 |
| - return collectionApi |
26 |
| - .getFilteredByGlob("src/issues/*.md") |
27 |
| - .filter( |
28 |
| - (item) => !(item.data.sc === "none") && !(item.data.sc === undefined) |
29 |
| - ) |
30 |
| - .sort((a, b) => { |
31 |
| - const numbA = sanitizeNumber(a.data.sc); |
32 |
| - const numbB = sanitizeNumber(b.data.sc); |
33 |
| - if (numbA < numbB) return -1; |
34 |
| - if (numbA > numbB) return 1; |
35 |
| - return 0; |
36 |
| - }); |
37 |
| - }); |
| 28 | + const numbA = sanitizeNumber(sortCriterionA); |
| 29 | + const numbB = sanitizeNumber(sortCriterionB); |
| 30 | + if (numbA < numbB) { |
| 31 | + return -1; |
| 32 | + } |
38 | 33 |
|
39 |
| - eleventyConfig.addCollection("tips", function (collectionApi) { |
40 |
| - return collectionApi |
41 |
| - .getFilteredByGlob("src/issues/*.md") |
42 |
| - .filter((item) => item.data.sc === "none"); |
43 |
| - }); |
| 34 | + if (numbA > numbB) { |
| 35 | + return 1; |
| 36 | + } |
44 | 37 |
|
45 |
| - eleventyConfig.addPassthroughCopy({ |
46 |
| - "src/admin/config.yml": "admin/config.yml", |
47 |
| - }); |
| 38 | + return 0; |
| 39 | + }), |
| 40 | + ); |
48 | 41 |
|
49 |
| - eleventyConfig.addPassthroughCopy({ |
50 |
| - "node_modules/decap-cms/dist/decap-cms.js": "lib/cms/decap-cms.js", |
51 |
| - "node_modules/decap-cms/dist/decap-cms.js.map": "lib/cms/decap-cms.js.map", |
52 |
| - "node_modules/prop-types/prop-types.min.js": "lib/cms/prop-types.min.js", |
53 |
| - "node_modules/react/umd/react.development.js": |
54 |
| - "lib/cms/react.development.js", |
55 |
| - "node_modules/react/umd/react.production.min.js": |
56 |
| - "lib/cms/react.production.min.js", |
57 |
| - }); |
| 42 | + eleventyConfig.addCollection('tips', collectionApi => |
| 43 | + collectionApi |
| 44 | + .getFilteredByGlob('src/report/issues/*.md') |
| 45 | + .filter(item => item.data.sc === undefined || item.data.sc.length === 0), |
| 46 | + ); |
58 | 47 |
|
59 |
| - return { |
60 |
| - dir: { |
61 |
| - input: "src", |
62 |
| - includes: "_includes", |
63 |
| - layouts: "_layouts", |
64 |
| - data: "_data", |
65 |
| - }, |
66 |
| - templateFormats: ["njk", "md", "css", "png", "jpg", "svg"], |
67 |
| - htmlTemplateEngine: "njk", |
68 |
| - markdownTemplateEngine: "njk", |
69 |
| - }; |
| 48 | + eleventyConfig.addPassthroughCopy({ |
| 49 | + 'src/admin/config.yml': 'admin/config.yml', |
| 50 | + }); |
| 51 | + |
| 52 | + eleventyConfig.addPassthroughCopy({ |
| 53 | + 'src/assets': 'assets', |
| 54 | + }); |
| 55 | + |
| 56 | + eleventyConfig.addPassthroughCopy({ |
| 57 | + 'node_modules/decap-cms/dist/decap-cms.js': 'lib/cms/decap-cms.js', |
| 58 | + 'node_modules/decap-cms/dist/decap-cms.js.map': |
| 59 | + 'lib/cms/decap-cms.js.map', |
| 60 | + 'node_modules/prop-types/prop-types.min.js': |
| 61 | + 'lib/cms/prop-types.min.js', |
| 62 | + 'node_modules/react/umd/react.development.js': |
| 63 | + 'lib/cms/react.development.js', |
| 64 | + 'node_modules/react/umd/react.production.min.js': |
| 65 | + 'lib/cms/react.production.min.js', |
| 66 | + }); |
| 67 | + |
| 68 | + return { |
| 69 | + dir: { |
| 70 | + input: 'src', |
| 71 | + includes: '_includes', |
| 72 | + layouts: '_layouts', |
| 73 | + data: '_data', |
| 74 | + }, |
| 75 | + templateFormats: ['njk', 'md', 'css', 'png', 'jpg', 'svg'], |
| 76 | + htmlTemplateEngine: 'njk', |
| 77 | + markdownTemplateEngine: 'njk', |
| 78 | + }; |
70 | 79 | }
|
0 commit comments