diff --git a/assets/js/common.ts b/assets/js/common.ts index f82fed1..9b8b45a 100644 --- a/assets/js/common.ts +++ b/assets/js/common.ts @@ -15,18 +15,6 @@ export function config (api, polling): confdata { return { apiurl: api.path, pollurl: pu, itemid: urlparams.get('id') } } -const appdata = { - $delimiters: ['{|', '|}'], - conf: {} as confdata, - data: {}, - output: '', - save, - poll, - mounted(name: string) { - console.log('app mounted: ', name) - } -} - export const pvapp = { run(conf: confdata) { appdata.conf = conf @@ -37,6 +25,18 @@ export const pvapp = { } } +const appdata = { + $delimiters: ['{|', '|}'], + conf: {} as confdata, + output: '', + poll, + mounted(name: string) { + console.log('app mounted: ', name) + }, + Data +} + + // components function Data() { @@ -46,7 +46,7 @@ function Data() { } } -// appdata method definitions +// appdata and component method definitions function save() { let value = '' diff --git a/exampleSite/content/app/test1.md b/exampleSite/content/app/test1.md index 54bd6ff..66b485a 100644 --- a/exampleSite/content/app/test1.md +++ b/exampleSite/content/app/test1.md @@ -5,7 +5,7 @@ img: pageid: test1 domains: [App] topics: [Examples] -date: 2023-03-01 +date: 2023-03-02 author: helmutm draft: false weight: 10 @@ -14,12 +14,17 @@ jsModule: main.ts cyberscopes example site - use petite-vue in Hugo-generated sites. -{{< pv/input-textline name="firstname" attrs="autofocus" >}} -{{< pv/input-textline name="lastname" >}} -{{< pv/button >}} +{{< pv/fieldset >}} -{{< pv/display expr="`${data.firstname} ${data.lastname}`.trim() || '???'" >}} + {{< pv/input-textline name="firstname" attrs="autofocus" >}} + {{< pv/input-textline name="lastname" >}} + {{< pv/button >}} -{{< pv/display name="email" >}} + {{< pv/display expr="`${data.firstname} ${data.lastname}`.trim() || '???'" >}} + + {{< pv/display name="email" >}} + +{{< /pv/fieldset >}} {{< pv/debug >}} + diff --git a/layouts/shortcodes/pv/debug.html b/layouts/shortcodes/pv/debug.html index 730fe7b..15cf08c 100644 --- a/layouts/shortcodes/pv/debug.html +++ b/layouts/shortcodes/pv/debug.html @@ -1,8 +1,11 @@
+ +
id = {| conf.itemid |}
-
+

 
+
diff --git a/layouts/shortcodes/pv/display.html b/layouts/shortcodes/pv/display.html index d0d59a2..dd79b96 100644 --- a/layouts/shortcodes/pv/display.html +++ b/layouts/shortcodes/pv/display.html @@ -1,6 +1,6 @@ {{- $name := .Get "name" | default "textline" -}} {{- $expr := .Get "expr" | default (printf "data.%s" $name) -}} {{- $default := .Get "default" | default "" -}} -
+

 
diff --git a/layouts/shortcodes/pv/explore.html b/layouts/shortcodes/pv/explore.html index 2782d14..5ae2263 100644 --- a/layouts/shortcodes/pv/explore.html +++ b/layouts/shortcodes/pv/explore.html @@ -1,19 +1,19 @@ -
+
-
-
-

-
+
+

+  
-
-

-
+
+

+  
-
-
id = {| conf.itemid |}
-
+
+
id = {| conf.itemid |}
+
+
diff --git a/layouts/shortcodes/pv/fieldset.html b/layouts/shortcodes/pv/fieldset.html new file mode 100644 index 0000000..0c9db41 --- /dev/null +++ b/layouts/shortcodes/pv/fieldset.html @@ -0,0 +1,3 @@ +
+ {{ .Inner }} +
diff --git a/layouts/shortcodes/pv/input-textline.html b/layouts/shortcodes/pv/input-textline.html index a14c5ce..104ad25 100644 --- a/layouts/shortcodes/pv/input-textline.html +++ b/layouts/shortcodes/pv/input-textline.html @@ -3,7 +3,7 @@ {{- $default := .Get "default" | default "" -}} {{- $attrs := .Get "attrs" | default "" -}} {{- $onchange := .Get "onchange" | default "" -}} -
+