Load a *.js for each page
[scpubgit/App-SCS.git] / lib / App / SCS / Plugin / Core / PagePlugin / PageData.pm
index eaa45d2..d84bc54 100644 (file)
@@ -36,6 +36,13 @@ sub filter_content_zoom {
                $_[0]->replace('');
            }
          }}
+       ->select('script[data-cur-page-js]')->${\sub {
+          if (-f $static_dir . "/page-js/" . $page->path . ".js") {
+              $_[0]->set_attribute(src => "/static/page-js/" . $page->path . ".js");
+          } else {
+              $_[0]->replace('');
+          }
+         }}
 }
 
 1;