-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.11ty.js
More file actions
36 lines (31 loc) · 928 Bytes
/
index.11ty.js
File metadata and controls
36 lines (31 loc) · 928 Bytes
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
import * as sass from "sass";
import path from "path";
import fs from "node:fs/promises";
export default class {
async data() {
const sourcePath = path.join(
import.meta.dirname,
"..",
"scss/main.scss",
);
return {
permalink: "/assets/css/main.css",
eleventyExcludeFromCollections: true,
entryFile: sourcePath,
};
}
async compileSass(file) {
return sass.compile(file).css.toString();
}
async render({ entryFile }) {
try {
// Read the tokens.css
const tokensPath = path.join(import.meta.dirname, "tokens.css");
const tokensCss = await fs.readFile(tokensPath, "utf-8");
const sassCss = await this.compileSass(entryFile);
return tokensCss + "\n" + sassCss;
} catch (error) {
throw error;
}
}
}