generation and api
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
export let type: string = 'visited';
|
||||
|
||||
import Wikipedia from '~icons/mdi/wikipedia';
|
||||
|
||||
let newAdventure: Adventure = {
|
||||
id: NaN,
|
||||
type: type,
|
||||
@@ -49,6 +51,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function generateDesc() {
|
||||
let res = await fetch(`/api/generate/desc/?name=${newAdventure.name}`);
|
||||
let data = await res.json();
|
||||
if (data.extract) {
|
||||
newAdventure.description = data.extract;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
const form = event.target as HTMLFormElement;
|
||||
@@ -179,6 +189,9 @@
|
||||
bind:value={newAdventure.description}
|
||||
class="input input-bordered w-full max-w-xs mt-1 mb-2"
|
||||
/>
|
||||
<button class="btn btn-neutral ml-2" type="button" on:click={generateDesc}
|
||||
><Wikipedia class="inline-block -mt-1 mb-1 w-6 h-6" />Generate Description</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
|
||||
Reference in New Issue
Block a user