From 42b2b0fcefbd947c4645d2a5a649449a3f8afbb6 Mon Sep 17 00:00:00 2001 From: Lukas Bestle Date: Sat, 9 Nov 2024 20:58:37 +0100 Subject: [PATCH] Modernize syntax --- .../0_sections/reference-extension.txt | 18 +++++++-------- .../0_first-panel-section/cookbook-recipe.txt | 23 ++++++++----------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/content/docs/2_reference/7_plugins/1_extensions/0_sections/reference-extension.txt b/content/docs/2_reference/7_plugins/1_extensions/0_sections/reference-extension.txt index e23f9431dc..f9d1318685 100644 --- a/content/docs/2_reference/7_plugins/1_extensions/0_sections/reference-extension.txt +++ b/content/docs/2_reference/7_plugins/1_extensions/0_sections/reference-extension.txt @@ -242,11 +242,10 @@ panel.plugin('yourname/modified', { text: null } }, - created: function() { - this.load().then(response => { - this.label = response.label; - this.text = response.text; - }); + created: async function() { + const response = await this.load(); + this.label = response.label; + this.text = response.text; } } } @@ -269,11 +268,10 @@ panel.plugin('yourname/modified', { text: null } }, - created: function() { - this.load().then(response => { - this.label = response.label; - this.text = response.text; - }); + created: async function() { + const response = await this.load(); + this.label = response.label; + this.text = response.text; }, template: `
diff --git a/content/docs/3_cookbook/0_panel/0_first-panel-section/cookbook-recipe.txt b/content/docs/3_cookbook/0_panel/0_first-panel-section/cookbook-recipe.txt index f51a83adc0..319300202e 100644 --- a/content/docs/3_cookbook/0_panel/0_first-panel-section/cookbook-recipe.txt +++ b/content/docs/3_cookbook/0_panel/0_first-panel-section/cookbook-recipe.txt @@ -238,12 +238,11 @@ export default { ] } }, - created() { - this.load().then(response => { - this.label = response.label; - this.layout = response.layout; - this.links = response.links; - }); + async created() { + const response = await this.load(); + this.label = response.label; + this.layout = response.layout; + this.links = response.links; } }; @@ -261,12 +260,11 @@ export default { links: [] } }, - created() { - this.load().then(response => { - this.label = response.label; - this.layout = response.layout; - this.links = response.links; - }); + async created() { + const response = await this.load(); + this.label = response.label; + this.layout = response.layout; + this.links = response.links; } }; @@ -363,4 +361,3 @@ linksection/ This is a very basic example that should still have given you an understanding of how the different parts play together and enable you to set up your first custom sections for your clients. The data to fill this section can come in fact come from anywhere, you can provide it through a route, a database or whatever you see fit. And you probably don't just want to display stuff, but add actions to each item etc. We'll cover that in future recipes. You don't have to use the components Kirby provides, either, but can come up with your own markup and design. The possibilities are pretty much endless. -