Start fetchdata kql
This commit is contained in:
parent
3ed204123a
commit
90c998fa41
13 changed files with 109 additions and 34 deletions
BIN
public/content/home/acy-1.jpg
Normal file
BIN
public/content/home/acy-1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 534 KiB |
5
public/content/home/acy-1.jpg.txt
Normal file
5
public/content/home/acy-1.jpg.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
Uuid: qHw8nu1sgsbs0G6q
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Template: blocks/image
|
||||||
|
|
@ -2,4 +2,20 @@ Title: Home
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
Testimages: - file://4xs4UNZhQf3jLvsG
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Testtext: test
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Testblocks: [{"content":{"location":"kirby","image":["file://qHw8nu1sgsbs0G6q"],"src":"","alt":"","caption":"","link":"","ratio":"","crop":"false"},"id":"9f5c767f-0b50-471c-85de-5c3d18fb596a","isHidden":false,"type":"image"}]
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Testimage: - file://4xs4UNZhQf3jLvsG
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
Uuid: 6yh1yt2Sk45Y2sOl
|
Uuid: 6yh1yt2Sk45Y2sOl
|
||||||
BIN
public/content/home/signal-2024-07-01-214357.jpg
Normal file
BIN
public/content/home/signal-2024-07-01-214357.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 379 KiB |
1
public/content/home/signal-2024-07-01-214357.jpg.txt
Normal file
1
public/content/home/signal-2024-07-01-214357.jpg.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Uuid: 4xs4UNZhQf3jLvsG
|
||||||
7
public/site/blueprints/pages/home.yml
Normal file
7
public/site/blueprints/pages/home.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
fields:
|
||||||
|
testImages:
|
||||||
|
type: files
|
||||||
|
testText:
|
||||||
|
type: text
|
||||||
|
testBlocks:
|
||||||
|
type: blocks
|
||||||
8
public/site/snippets/footer.php
Normal file
8
public/site/snippets/footer.php
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<script>
|
||||||
|
const kirbyData = {
|
||||||
|
pageUri: '<?= $page->uri() ?>',
|
||||||
|
pageTemplate: '<?= $page->template() ?>',
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -7,3 +7,4 @@
|
||||||
<script type="module" src="http://localhost:5173/@vite/client" defer></script>
|
<script type="module" src="http://localhost:5173/@vite/client" defer></script>
|
||||||
<script type="module" src="http://localhost:5173/src/main.js" defer></script>
|
<script type="module" src="http://localhost:5173/src/main.js" defer></script>
|
||||||
</head>
|
</head>
|
||||||
|
<body>
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
<?php snippet('header') ?>
|
<?php snippet('header') ?>
|
||||||
<body>
|
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
</body>
|
<?php snippet('footer') ?>
|
||||||
48
src/App.vue
48
src/App.vue
|
|
@ -1,35 +1,23 @@
|
||||||
<script>
|
<script setup>
|
||||||
fetchData();
|
import Home from "./views/Home.vue";
|
||||||
|
import { useApiStore } from "./stores/api";
|
||||||
|
|
||||||
function fetchData() {
|
const templates = {
|
||||||
const api = "/api/query";
|
home: {
|
||||||
|
component: Home,
|
||||||
|
query: {
|
||||||
|
title: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const username = import.meta.env.VITE_USERNAME;
|
const api = useApiStore();
|
||||||
const password = "Ap&216991";
|
const pageTemplate = kirbyData.pageTemplate;
|
||||||
|
const pageUri = kirbyData.pageUri;
|
||||||
|
|
||||||
const token = btoa(`${username}:${password}`);
|
api.fetchData();
|
||||||
|
|
||||||
const headers = {
|
|
||||||
Authorization: `Basic ${token}`,
|
|
||||||
};
|
|
||||||
|
|
||||||
const request = {
|
|
||||||
method: "post",
|
|
||||||
body: JSON.stringify({
|
|
||||||
query: "site.title",
|
|
||||||
}),
|
|
||||||
headers,
|
|
||||||
};
|
|
||||||
|
|
||||||
fetch(api, request)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((response) => {
|
|
||||||
console.log(response);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>test</template>
|
<template>
|
||||||
|
<component :is="templates[pageTemplate].component" />
|
||||||
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,5 @@ import { createPinia } from "pinia";
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
|
|
||||||
app.use(pinia).mount("#app");
|
app.use(pinia);
|
||||||
|
app.mount("#app");
|
||||||
|
|
|
||||||
46
src/stores/api.js
Normal file
46
src/stores/api.js
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
import { defineStore } from "pinia";
|
||||||
|
|
||||||
|
export const useApiStore = defineStore("counter", () => {
|
||||||
|
function fetchData() {
|
||||||
|
const api = "/api/query";
|
||||||
|
|
||||||
|
const username = import.meta.env.VITE_USERNAME;
|
||||||
|
const password = import.meta.env.VITE_PASSWORD;
|
||||||
|
|
||||||
|
const token = btoa(`${username}:${password}`);
|
||||||
|
|
||||||
|
const headers = {
|
||||||
|
Authorization: `Basic ${token}`,
|
||||||
|
};
|
||||||
|
|
||||||
|
const request = {
|
||||||
|
method: "post",
|
||||||
|
body: JSON.stringify({
|
||||||
|
query: `page('home')`,
|
||||||
|
select: {
|
||||||
|
testImages: {
|
||||||
|
query: "page.testImages.toFiles",
|
||||||
|
select: {
|
||||||
|
url: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
blocks: {
|
||||||
|
query: "page.testBlocks.toBlocks",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
headers,
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch(api, request)
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((response) => {
|
||||||
|
console.log(response);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return { fetchData };
|
||||||
|
});
|
||||||
3
src/views/Home.vue
Normal file
3
src/views/Home.vue
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<script setup></script>
|
||||||
|
<template></template>
|
||||||
|
<style scoped></style>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue