eleventy-plugin-uncharted 0.7.0 → 0.7.2

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/css/uncharted.css CHANGED
@@ -128,15 +128,15 @@
128
128
 
129
129
  .chart-legend-item {
130
130
  display: flex;
131
- align-items: center;
131
+ align-items: baseline;
132
132
  gap: 0.5rem;
133
133
  background: transparent;
134
134
  }
135
135
 
136
136
  .chart-legend-item::before {
137
137
  content: '';
138
- width: 0.75rem;
139
- height: 0.75rem;
138
+ width: 1cap;
139
+ height: 1cap;
140
140
  border-radius: 2px;
141
141
  background-color: var(--color);
142
142
  flex-shrink: 0;
@@ -11,7 +11,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
11
  * Uncharted - Eleventy CSS Charts Plugin
12
12
  * @param {Object} eleventyConfig - Eleventy configuration object
13
13
  * @param {Object} [options] - Plugin options
14
- * @param {string} [options.dataDir] - Data directory path (defaults to _data)
14
+ * @param {string} [options.dataDir] - @deprecated Data directory path (now auto-detected from Eleventy's dir.data)
15
15
  * @param {boolean} [options.animate] - Enable animations globally (individual charts can override)
16
16
  * @param {string} [options.cssPath] - Output path for stylesheet (default: '/css/uncharted.css')
17
17
  * @param {boolean} [options.injectCss] - Automatically copy and inject CSS (default: true)
@@ -20,7 +20,33 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
20
20
  * @param {boolean|string} [options.downloadData] - Enable download links globally (individual charts can override)
21
21
  */
22
22
  export default function(eleventyConfig, options = {}) {
23
- const dataDir = options.dataDir || '_data';
23
+ // Directory config from Eleventy (populated by eleventy.directories event)
24
+ let eleventyDirs = null;
25
+
26
+ // Listen for Eleventy's directory configuration
27
+ eleventyConfig.on('eleventy.directories', (dirs) => {
28
+ eleventyDirs = dirs;
29
+ });
30
+
31
+ // Warn if deprecated dataDir option is used
32
+ if (options.dataDir) {
33
+ console.warn('[uncharted] "dataDir" option is deprecated; the plugin now auto-detects from Eleventy\'s dir.data config');
34
+ }
35
+
36
+ // Helper to resolve data directory
37
+ function getDataDir() {
38
+ // Plugin option takes precedence if explicitly set (deprecated)
39
+ if (options.dataDir) {
40
+ return path.resolve(process.cwd(), options.dataDir);
41
+ }
42
+ // Use Eleventy's directory configuration (already includes full path)
43
+ if (eleventyDirs?.data) {
44
+ return path.resolve(process.cwd(), eleventyDirs.data);
45
+ }
46
+ // Fallback to default
47
+ return path.resolve(process.cwd(), '_data');
48
+ }
49
+
24
50
  const globalAnimate = options.animate ?? false;
25
51
  const cssPath = options.cssPath || '/css/uncharted.css';
26
52
  const injectCss = options.injectCss ?? true;
@@ -67,17 +93,19 @@ export default function(eleventyConfig, options = {}) {
67
93
  });
68
94
  }
69
95
 
70
- // CSV data passthrough for download links
96
+ // CSV data passthrough for download links (set up after directories are known)
71
97
  if (dataPassthrough) {
72
- const resolvedDataDir = path.resolve(process.cwd(), dataDir);
73
- eleventyConfig.addPassthroughCopy({
74
- [resolvedDataDir]: dataPath.replace(/^\//, '').replace(/\/$/, '')
98
+ eleventyConfig.on('eleventy.directories', () => {
99
+ const resolvedDataDir = getDataDir();
100
+ eleventyConfig.addPassthroughCopy({
101
+ [resolvedDataDir]: dataPath.replace(/^\//, '').replace(/\/$/, '')
102
+ });
75
103
  });
76
104
  }
77
105
 
78
106
  eleventyConfig.addShortcode('chart', function(chartId) {
79
- // Resolve data directory relative to the current working directory
80
- const resolvedDataDir = path.resolve(process.cwd(), dataDir);
107
+ // Get resolved data directory (from Eleventy config or plugin options)
108
+ const resolvedDataDir = getDataDir();
81
109
 
82
110
  // Look up chart config from page data or global data
83
111
  // In Eleventy 3.x, data is available directly on `this` context
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleventy-plugin-uncharted",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "An Eleventy plugin that renders CSS-based charts from CSV data using shortcodes",
5
5
  "main": "eleventy.config.js",
6
6
  "type": "module",