defaults.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. import {
  2. compileSass,
  3. copy,
  4. generateFavicons,
  5. generateRouteAssets,
  6. generateSitemap,
  7. imageToWebP,
  8. optimiseSvg,
  9. renderTemplate,
  10. renderIndex,
  11. renderMarkdownToMeta,
  12. renderMarkdownWithTemplate,
  13. generateTaxonomy,
  14. } from "./actions/index.js"
  15. export const tasks = [
  16. [
  17. {
  18. key: "images",
  19. name: "Images",
  20. action: imageToWebP,
  21. jobConfig: {
  22. inputFiles: [{ pattern: "images/content/*.jpg" }],
  23. stripPaths: ["images/content/"],
  24. outputDir: "images/",
  25. outputFileExtension: ".webp",
  26. },
  27. actionConfig: {
  28. imageSizes: [
  29. "640w",
  30. "768w",
  31. "1024w",
  32. "1366w",
  33. "1600w",
  34. "1920w",
  35. "2560w",
  36. ],
  37. quality: 80,
  38. },
  39. },
  40. {
  41. key: "styles",
  42. name: "Styles",
  43. action: compileSass,
  44. jobConfig: {
  45. inputFiles: [{ pattern: "styles/**/*.scss", ignore: "**/_*.scss" }],
  46. stripPaths: ["styles/"],
  47. outputDir: "static/styles/",
  48. outputFileExtension: ".css",
  49. },
  50. actionConfig: {},
  51. },
  52. {
  53. key: "icons",
  54. name: "Icons",
  55. action: optimiseSvg,
  56. jobConfig: {
  57. inputFiles: [{ pattern: "images/icons/*.svg" }],
  58. stripPaths: ["images/"],
  59. outputDir: "static/",
  60. outputFileExtension: ".svg",
  61. },
  62. actionConfig: {},
  63. },
  64. {
  65. key: "static-files",
  66. name: "Static Files",
  67. action: copy,
  68. jobConfig: {
  69. inputFiles: [{ pattern: "static/*" }],
  70. stripPaths: ["static/"],
  71. },
  72. actionConfig: {},
  73. },
  74. {
  75. key: "favicons",
  76. name: "Favicons",
  77. action: generateFavicons,
  78. jobConfig: {
  79. inputFiles: [{ pattern: "images/favicon/*" }],
  80. stripPaths: ["images/favicon/"],
  81. outputDir: "static/meta/",
  82. },
  83. actionConfig: {},
  84. },
  85. {
  86. key: "routes",
  87. name: "Routes",
  88. action: generateRouteAssets,
  89. jobConfig: {
  90. inputFiles: [{ pattern: "gpx/**/*.gpx" }],
  91. stripPaths: ["gpx/"],
  92. outputDir: "routes/",
  93. outputFileExtension: ".gpx",
  94. },
  95. actionConfig: {
  96. imageSizes: [
  97. "640w",
  98. "768w",
  99. "1024w",
  100. "1366w",
  101. "1600w",
  102. "1920w",
  103. "2560w",
  104. ],
  105. quality: 80,
  106. },
  107. },
  108. ],
  109. {
  110. key: "blog-markdown",
  111. name: "Blog Markdown",
  112. action: renderMarkdownToMeta,
  113. jobConfig: {
  114. inputFiles: [{ pattern: "markdown/blog/*.md" }],
  115. stripPaths: ["markdown/"],
  116. outputFileExtension: ".html",
  117. },
  118. actionConfig: {},
  119. },
  120. {
  121. key: "markdown",
  122. name: "Markdown",
  123. action: renderMarkdownToMeta,
  124. jobConfig: {
  125. inputFiles: [{ pattern: "markdown/*.md" }],
  126. stripPaths: ["markdown/"],
  127. outputFileExtension: ".html",
  128. },
  129. actionConfig: {},
  130. },
  131. [
  132. {
  133. key: "author-taxonomy",
  134. name: "Author Taxonomy",
  135. action: generateTaxonomy,
  136. jobConfig: {
  137. stateSelectors: ["resources.blog-markdown"],
  138. expand: false,
  139. skipCache: true,
  140. },
  141. actionConfig: {
  142. indexOn: "author",
  143. orderBy: "date",
  144. properties: [
  145. "title", "href", "date", "modified", "author", "tags", "description",
  146. ],
  147. sortAscending: false,
  148. },
  149. },
  150. {
  151. key: "tag-taxonomy",
  152. name: "Tag Taxonomy",
  153. action: generateTaxonomy,
  154. jobConfig: {
  155. stateSelectors: ["resources.blog-markdown"],
  156. expand: false,
  157. skipCache: true,
  158. },
  159. actionConfig: {
  160. indexOn: "tags",
  161. orderBy: "date",
  162. properties: [
  163. "title", "href", "date", "modified", "author", "tags", "description",
  164. ],
  165. sortAscending: false,
  166. },
  167. },
  168. {
  169. key: "blog-latest",
  170. name: "Blog Latest",
  171. action: generateTaxonomy,
  172. jobConfig: {
  173. stateSelectors: ["resources.blog-markdown"],
  174. expand: false,
  175. skipCache: true,
  176. },
  177. actionConfig: {
  178. orderBy: "date",
  179. properties: [
  180. "title", "href", "date", "modified", "author", "tags", "description",
  181. ],
  182. sortAscending: false,
  183. },
  184. },
  185. {
  186. key: "includes",
  187. name: "Includes",
  188. action: renderTemplate,
  189. jobConfig: {
  190. inputFiles: [{ pattern: "includes/*.hbs" }],
  191. stripPaths: ["includes/"],
  192. outputFileExtension: ".html",
  193. },
  194. actionConfig: {},
  195. },
  196. ],
  197. [
  198. {
  199. key: "render-pages",
  200. name: "Render Pages",
  201. action: renderMarkdownWithTemplate,
  202. jobConfig: {
  203. inputFiles: [{ pattern: "markdown/*.md" }],
  204. stripPaths: ["markdown/"],
  205. outputFileExtension: ".html",
  206. },
  207. actionConfig: {
  208. templateDirs: ["templates/", "~/.rhedyn/templates/"],
  209. partialDirs: ["partials/", "~/.rhedyn/partials/"],
  210. defaultTemplate: "page",
  211. },
  212. },
  213. {
  214. key: "render-blog-pages",
  215. name: "Render Blog Pages",
  216. action: renderMarkdownWithTemplate,
  217. jobConfig: {
  218. inputFiles: [{ pattern: "markdown/blog/*.md" }],
  219. stripPaths: ["markdown/"],
  220. outputFileExtension: ".html",
  221. },
  222. actionConfig: {
  223. templateDirs: ["templates/", "~/.rhedyn/templates/"],
  224. partialDirs: ["partials/", "~/.rhedyn/partials/"],
  225. defaultTemplate: "article",
  226. },
  227. },
  228. {
  229. key: "render-author-indexes",
  230. name: "Render Author Indexes",
  231. action: renderIndex,
  232. jobConfig: {
  233. stateSelectors: ["resources.author-taxonomy.detail"],
  234. outputFileExtension: ".html",
  235. outputDir: "blog/by-author/",
  236. buildFilePath: true,
  237. itemsPerPage: 10,
  238. },
  239. actionConfig: {
  240. writeOut: true,
  241. templateDirs: ["templates/", "~/.rhedyn/templates/"],
  242. partialDirs: ["partials/", "~/.rhedyn/partials/"],
  243. },
  244. },
  245. {
  246. key: "render-tag-indexes",
  247. name: "Render Tag Indexes",
  248. action: renderIndex,
  249. jobConfig: {
  250. stateSelectors: ["resources.tag-taxonomy.detail"],
  251. outputFileExtension: ".html",
  252. outputDir: "blog/by-tag/",
  253. buildFilePath: true,
  254. itemsPerPage: 10,
  255. },
  256. actionConfig: {
  257. writeOut: true,
  258. templateDirs: ["templates/", "~/.rhedyn/templates/"],
  259. partialDirs: ["partials/", "~/.rhedyn/partials/"],
  260. },
  261. },
  262. {
  263. key: "render-blog-home",
  264. name: "Render Blog Home",
  265. action: renderIndex,
  266. jobConfig: {
  267. stateSelectors: ["resources.blog-latest.detail"],
  268. outputFileExtension: ".html",
  269. outputDir: "blog/",
  270. expand: false,
  271. outputFileName: "index",
  272. buildFilePath: true,
  273. itemsPerPage: 10,
  274. },
  275. actionConfig: {
  276. writeOut: true,
  277. templateDirs: ["templates/", "~/.rhedyn/templates/"],
  278. partialDirs: ["partials/", "~/.rhedyn/partials/"],
  279. title: "Blog",
  280. },
  281. },
  282. ],
  283. {
  284. key: "sitemap",
  285. name: "Sitemap",
  286. action: generateSitemap,
  287. jobConfig: {
  288. stateSelectors: [
  289. "resources.render-pages",
  290. "resources.render-blog-pages",
  291. "resources.render-author-indexes",
  292. "resources.render-tag-indexes",
  293. "resources.render-blog-home",
  294. ],
  295. expand: false,
  296. skipCache: true,
  297. },
  298. actionConfig: {
  299. outputFileName: "sitemap.xml",
  300. },
  301. },
  302. ]
  303. export const opts = {
  304. outDir: "dist/",
  305. runDir: process.cwd(),
  306. cacheDir: ".cache",
  307. include: {
  308. styles: [{ pattern: "~/.rhedyn/styles/*.scss" }],
  309. },
  310. clean: true,
  311. ignoreExisting: false,
  312. logLevel: "info",
  313. includeStateValues: true,
  314. itemsPerPage: 25,
  315. markdown: {
  316. allowHtml: false,
  317. },
  318. site: {
  319. name: "Website generated by Rhedyn",
  320. shortName: "Rhedyn test site",
  321. description: "A website generated from files using Rhedyn",
  322. author: "Craig Fletcher",
  323. url: "https://www.leakypixel.net",
  324. language: "en-GB",
  325. backgroundColor: "#22242c",
  326. themeColor: "#f00",
  327. },
  328. }
  329. const defaults = {
  330. opts,
  331. tasks,
  332. }
  333. export default defaults