File tree Expand file tree Collapse file tree 5 files changed +46
-24
lines changed
Expand file tree Collapse file tree 5 files changed +46
-24
lines changed Original file line number Diff line number Diff line change 44 <title >OpenSCAD Files</title >
55 {% w3_theme_css theme %}
66 <script >
7- console .log ({{ page | dump | safe }});
7+ const searchParams = new URLSearchParams (window .location .search );
8+
9+ if (searchParams .has (" dump" , " true" )) {
10+ console .log ({{ page | dump | safe }});
11+ }
812 </script >
913 </head >
1014 <body >
Original file line number Diff line number Diff line change 44 <meta charset =" UTF-8" />
55 <title >{{ stlFile }} </title >
66 {% threejs_importmap %}
7- <script >
8- window .STL_URL = new URL (" {{ stlFile }}" , window .location .href )
9- console .log ({{ url }})
10- </script >
7+ <script >window .STL_URL = new URL (" {{ stlFile }}" , window .location .href ); </script >
118 {% w3_theme_css theme %}
129 <style >
1310 body {
Original file line number Diff line number Diff line change @@ -20,9 +20,22 @@ export function addShortcodes(eleventyConfig: EleventyConfig) {
2020 * @link https://www.w3.org/StyleSheets/Core/preview
2121 */
2222 registerShortcode ( "w3_theme_css" , ( userTheme : ModelViewerTheme ) => {
23- const $theme = useNonEmptyOrDefault ( userTheme , DEFAULT_PLUGIN_THEME ) ;
24- const url = `https://www.w3.org/StyleSheets/Core/${ $theme } ` ;
25- return `<link rel="stylesheet" href="${ url } ">` ;
23+ const theme = useNonEmptyOrDefault ( userTheme , DEFAULT_PLUGIN_THEME ) ;
24+ const url = `https://www.w3.org/StyleSheets/Core/${ theme } ` ;
25+ const w3cThemeCssLinkTag = `<link id="__eleventy_scad_theme" rel="stylesheet" href="${ url } ">` ;
26+ const themeOverrideScriptTag = `<script>
27+ document.addEventListener('DOMContentLoaded', function (evt) {
28+ console.log("content loaded");
29+ const searchParams = new URLSearchParams(window.location.search);
30+ if (searchParams.has("theme")) {
31+ const themeOverride = searchParams.get("theme");
32+ console.log("has theme override", { themeOverride });
33+ const link = document.getElementById("__eleventy_scad_theme");
34+ link.href = link.href.replace("${ theme } ", themeOverride);
35+ }
36+ }, false);
37+ </script>` ;
38+ return [ w3cThemeCssLinkTag , themeOverrideScriptTag ] . join ( "\n" ) ;
2639 } ) ;
2740
2841 /**
Original file line number Diff line number Diff line change @@ -27,17 +27,28 @@ export function addScadCollectionVirtualTemplate(
2727 ) ;
2828
2929 const DEFAULT_COLLECTION_TEMPLATE = "index.njk" ;
30- eleventyConfig . addTemplate (
31- DEFAULT_COLLECTION_TEMPLATE ,
32- `<ul>
33- {% for item in collections.scad %}
34- <li><a href="{{ item.data.page.url | url }}">{{ item.data.title }}</a></li>
35- {% endfor %}
36- </ul>` ,
37- {
38- layout : DEFAULT_COLLECTION_LAYOUT ,
39- theme : pageTheme ,
40- } ,
41- ) ;
30+ const tableHTML = `<!-- added by addScadCollectionVirtualTemplate -->
31+ <table>
32+ <thead>
33+ <tr>
34+ <th>Title</th>
35+ <th>Location</th>
36+ </tr>
37+ </thead>
38+ <tbody>
39+ {% for item in collections.scad %}
40+ <tr>
41+ <td>
42+ <a href="{{ item.data.page.url | url }}">{{ item.data.title }}</a>
43+ </td>
44+ <td>{{ item.data.page.url }}</td>
45+ </tr>
46+ {% endfor %}
47+ </tbody>
48+ </table>` ;
49+ eleventyConfig . addTemplate ( DEFAULT_COLLECTION_TEMPLATE , tableHTML , {
50+ layout : DEFAULT_COLLECTION_LAYOUT ,
51+ theme : pageTheme ,
52+ } ) ;
4253 log ( `(virtual) added "%o"` , DEFAULT_COLLECTION_TEMPLATE ) ;
4354}
Original file line number Diff line number Diff line change @@ -153,11 +153,8 @@ export function EleventyPluginOpenSCAD(
153153 }
154154
155155 if ( ! data . page . url ) {
156- // _log(
157- // `${red("issue:")} ${reset(data.stlFile)} ${gray(`from ${inputPath}`)}`,
158- // );
159156 throw new Error (
160- `${ inputPath } must have "parmalink:true" in the frontmatter` ,
157+ `${ inputPath } must have "parmalink:true" set in the frontmatter` ,
161158 ) ;
162159 // return inputContent;
163160 }
You can’t perform that action at this time.
0 commit comments