-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.config.js
More file actions
68 lines (51 loc) · 1.83 KB
/
Copy patheleventy.config.js
File metadata and controls
68 lines (51 loc) · 1.83 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import logToConsole from 'eleventy-plugin-console-plus'
import EleventyVitePlugin from '@11ty/eleventy-plugin-vite'
import tailwindcss from '@tailwindcss/vite';
import touch from 'touch'
export default (eleventyConfig) => {
eleventyConfig.addPlugin(logToConsole, {});
eleventyConfig.addPlugin(EleventyVitePlugin, {
viteOptions: { plugins: [tailwindcss()] }
});
eleventyConfig.addPassthroughCopy({
"src/css/tailwind.css": "styles.css" ,
"src/images/": "./images/",
"src/admin/": "./admin/",
});
// eleventyConfig.addShortcode("URLEncode", function(templatePath) {
// console.log("btoa ",btoa(templatePath) )
// return btoa(templatePath)
// })
eleventyConfig.setServerOptions({
onRequest: {
"/reload/:b64String": function ({ url, pattern, patternGroups }) {
const b64String = atob(patternGroups.b64String) // decode the b64
const pageData = JSON.parse(b64String); // turn string into JSON
const dir = eleventyConfig.dir // get eleventy directories
// Assume the datafile is the same name as the template.
const dataFile = `./${dir.input}/${dir.data}${pageData.filePathStem}.js`
touch.sync(dataFile)
// console.log("template: ", template)
// get the template and 'touch' it
const template = pageData.inputPath
touch.sync(template)
// console.log("datafile: ", dataFile)
return "Nothing to see here"
},
}
});
eleventyConfig.addWatchTarget("./src/_data/posts.js/");
// "/reload": function ({ url, pattern, patternGroups }) {
// console.log(`just a reload on ${url}`)
// return "Nothing to see here"
// },
return {
dir: {
input: "src",
output: "dist",
includes: '_partials/',
layouts: '_partials/_layouts',
data: '_data'
},
};
};