Changes
Dieser Commit ist enthalten in:
Ursprung
17d46c3964
Commit
e65a70aa40
@ -3,11 +3,12 @@ import {ArrowLeftSolid} from "flowbite-svelte-icons";
|
||||
import {Button, Card, Input, Label, Navbar, NavBrand, NavHamburger, NavUl, Spinner} from "flowbite-svelte";
|
||||
import {pageRepo} from "../repo/repo.js";
|
||||
import {mapToMap, nameRegex} from "../util.ts";
|
||||
import Editor from "./edit/Editor.svelte";
|
||||
import TypeAheadSearch from "../components/TypeAheadSearch.svelte";
|
||||
import {branches} from "../stores/stores.ts";
|
||||
import Editor from "./edit/Editor.svelte";
|
||||
|
||||
$: pagesFuture = $pageRepo.listPages(selectedBranch);
|
||||
|
||||
let pagesFuture = $pageRepo.listPages();
|
||||
let selected: number | null = null;
|
||||
|
||||
let selectedBranch: string = "master";
|
||||
@ -54,6 +55,16 @@ async function deleteBranch() {
|
||||
}
|
||||
}
|
||||
|
||||
async function createFile() {
|
||||
let name = prompt("File name:", "pages/en/[Name]")
|
||||
if (name) {
|
||||
await $pageRepo.createFile(`${name}.md`, selectedBranch)
|
||||
const w = selectedBranch
|
||||
selectedBranch = "###!"
|
||||
selectedBranch = w
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<div class="flex flex-col h-screen overflow-scroll">
|
||||
<Navbar let:hidden let:toggle>
|
||||
@ -73,8 +84,9 @@ async function deleteBranch() {
|
||||
<div class="border-b border-b-gray-600 pb-2 flex justify-between">
|
||||
<TypeAheadSearch items={availableBranches} bind:selected={selectedBranch} bind:searchValue />
|
||||
<div>
|
||||
<Button on:click={deleteBranch} color="ghost">Delete Branch</Button>
|
||||
<Button on:click={createBranch}>Create Branch</Button>
|
||||
<Button on:click={createFile} color="alternative">Create File</Button>
|
||||
<Button on:click={deleteBranch} color="ghost">Delete Branch</Button>
|
||||
</div>
|
||||
</div>
|
||||
{@const pagesMap = mapToMap(pages)}
|
||||
|
@ -10,7 +10,7 @@ export class PageRepo {
|
||||
public async listPages(branch: string = "master"): Promise<PageList> {
|
||||
return await fetchWithToken(this.token, `/page?branch=${branch}`)
|
||||
.then(value => value.json())
|
||||
.then(value => PageListSchema.parse(value))
|
||||
.then(value => PageListSchema.parse(value).map(value1 => ({...value1, path: value1.path.replace("src/content/", "")})))
|
||||
}
|
||||
|
||||
public async getPage(id: number, branch: string = "master"): Promise<Page> {
|
||||
@ -41,4 +41,8 @@ export class PageRepo {
|
||||
public async deleteBranch(branch: string): Promise<void> {
|
||||
await fetchWithToken(this.token, `/page/branch`, {method: "DELETE", body: JSON.stringify({branch})})
|
||||
}
|
||||
|
||||
public async createFile(path: string, branch: string = "master"): Promise<void> {
|
||||
await fetchWithToken(this.token, `/page?branch=${branch}`, {method: "POST", body: JSON.stringify({path})})
|
||||
}
|
||||
}
|
@ -24,4 +24,9 @@ export const PageSchema = z.object({
|
||||
id: z.number().positive()
|
||||
})
|
||||
|
||||
export type Page = z.infer<typeof PageSchema>;
|
||||
export type Page = z.infer<typeof PageSchema>;
|
||||
|
||||
export type Pages = {
|
||||
dirs: {[key: string]: Pages},
|
||||
files: {[key: string]: ListPage}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
---
|
||||
title: [Enter Title]
|
||||
description: [Enter Description]
|
||||
slug: [Enter Slug]
|
||||
---
|
||||
|
||||
# src/content/pages/en/about.md
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren