diff --git a/src/routes/about.lisp b/src/routes/about.lisp index 6ef2e24..5d73589 100644 --- a/src/routes/about.lisp +++ b/src/routes/about.lisp @@ -11,7 +11,7 @@ (pi:define-element page () (pi:h - (section :data-cmp "pages/about" + (section :data-scope "pages/about" (h1 "About") (a :href "/" :hx-boost "true" "top")))) diff --git a/src/routes/index.lisp b/src/routes/index.lisp index 10b0618..3986fa7 100644 --- a/src/routes/index.lisp +++ b/src/routes/index.lisp @@ -7,7 +7,7 @@ (pi:define-element page () (pi:h - (section :data-cmp "pages/index" + (section :data-scope "pages/index" (h1 "Hello, World!") (a :href "/about" :hx-boost "true" "About")))) diff --git a/src/styles/pages/about.css b/src/styles/pages/about.css index 7f045cd..22cf4df 100644 --- a/src/styles/pages/about.css +++ b/src/styles/pages/about.css @@ -1,4 +1,4 @@ -@scope ([data-cmp='pages/about']) { +@scope ([data-scope='pages/about']) { :scope { height: 100svh; background-color: thistle; diff --git a/src/styles/pages/index.css b/src/styles/pages/index.css index 904a4a7..6b49455 100644 --- a/src/styles/pages/index.css +++ b/src/styles/pages/index.css @@ -1,4 +1,4 @@ -@scope ([data-cmp='pages/index']) { +@scope ([data-scope='pages/index']) { :scope { height: 100svh; background-color: aliceblue; diff --git a/src/view/optimizer.lisp b/src/view/optimizer.lisp index c86df4e..4b6efc2 100644 --- a/src/view/optimizer.lisp +++ b/src/view/optimizer.lisp @@ -4,15 +4,15 @@ (:export #:collect-style-links)) (in-package #:hp/view/optimizer) -(defun detect-components (page-str) - (remove-duplicates (re:all-matches-as-strings "(?<=data-cmp=\")[^\"]*(?=\")" - page-str) +(defun detect-scopes (html-str) + (remove-duplicates (re:all-matches-as-strings "(?<=data-scope=\")[^\"]*(?=\")" + html-str) :test #'string=)) -(defun components->stylesheets (data-cmps) - (mapcar (lambda (cmp-name) - (concatenate 'string "/styles/" cmp-name ".css")) - data-cmps)) +(defun scopes->stylesheets (scopes) + (mapcar (lambda (scope) + (concatenate 'string "/styles/" scope ".css")) + scopes)) -(defun collect-style-links (page-str) - (components->stylesheets (detect-components page-str))) +(defun collect-style-links (html-str) + (scopes->stylesheets (detect-scopes html-str)))