1
0

Fixing netlify

This commit is contained in:
Zef Hemel 2024-01-20 22:53:51 +01:00
parent 9734c0f14c
commit 4133cabd52
11 changed files with 60 additions and 17 deletions

View File

@ -8,9 +8,11 @@ indexPage: index
`; `;
export const INDEX_TEMPLATE = export const INDEX_TEMPLATE =
`Hello! And welcome to your brand new SilverBullet space! `This is the index page of your fresh SilverBullet space. It is the default page that is loaded when you open a space.
For your convenience we're including an on-boarding live template below. Enjoy!
\`\`\`template \`\`\`template
page: "[[!silverbullet.md/Getting Started]]" page: "[[!localhost:3001/Getting Started]]"
\`\`\` \`\`\`
`; `;

View File

@ -57,6 +57,11 @@ export class HttpSpacePrimitives implements SpacePrimitives {
if ( if (
errorMessage.includes("fetch") || errorMessage.includes("load failed") errorMessage.includes("fetch") || errorMessage.includes("load failed")
) { ) {
console.error(
"Got error fetching, throwing offline",
url,
e.errorMessage,
);
throw new Error("Offline"); throw new Error("Offline");
} }
throw e; throw e;

View File

@ -1,9 +1,8 @@
import { SETTINGS_TEMPLATE } from "./PAGE_TEMPLATES.ts"; import { INDEX_TEMPLATE, SETTINGS_TEMPLATE } from "./PAGE_TEMPLATES.ts";
import { YAML } from "./deps.ts"; import { YAML } from "./deps.ts";
import { SpacePrimitives } from "./spaces/space_primitives.ts"; import { SpacePrimitives } from "./spaces/space_primitives.ts";
import { expandPropertyNames } from "$sb/lib/json.ts"; import { expandPropertyNames } from "$sb/lib/json.ts";
import type { BuiltinSettings } from "../web/types.ts"; import type { BuiltinSettings } from "../web/types.ts";
import { INDEX_TEMPLATE } from "./PAGE_TEMPLATES.ts";
/** /**
* Runs a function safely by catching any errors and logging them to the console. * Runs a function safely by catching any errors and logging them to the console.

View File

@ -0,0 +1,16 @@
export default async function handleMarkdown(
request: Request,
ctx: any,
): Promise<Response> {
const resp = await ctx.next(request);
if (resp.status === 404) {
return new Response("", {
status: 200,
headers: { "Content-Type": "text/markdown" },
});
} else {
return resp;
}
}
export const config = { path: "/*.md" };

View File

@ -49,6 +49,8 @@ export async function importLibraryCommand(_def: any, uri?: string) {
// Write to local space // Write to local space
await space.writePage(pageName, new TextDecoder().decode(buf)); await space.writePage(pageName, new TextDecoder().decode(buf));
await editor.flashNotification(`Imported ${pageName}`);
} }
await editor.reloadSettingsAndCommands(); await editor.reloadSettingsAndCommands();
await editor.flashNotification("Import complete!"); await editor.flashNotification("Import complete!");

View File

@ -39,7 +39,6 @@ cat website/_headers | sed "s/12345/$LAST_MODIFIED_TIMESTAMP/g" > website_build/
echo "Generating file listing" echo "Generating file listing"
deno run -A scripts/generate_fs_list.ts > website_build/index.json deno run -A scripts/generate_fs_list.ts > website_build/index.json
echo > website_build/empty.md
#echo "Bundling..." #echo "Bundling..."
deno task bundle deno task bundle

View File

@ -136,6 +136,11 @@ export class MarkdownWidget extends WidgetType {
} }
private attachListeners(div: HTMLElement, buttons?: CodeWidgetButton[]) { private attachListeners(div: HTMLElement, buttons?: CodeWidgetButton[]) {
div.addEventListener("mousedown", (e) => {
// CodeMirror overrides mousedown on parent elements to implement its own selection highlighting.
// That's nice, but not for markdown widgets, so let's not propagate the event to CodeMirror here.
e.stopPropagation();
});
// Override wiki links with local navigate (faster) // Override wiki links with local navigate (faster)
div.querySelectorAll("a[data-ref]").forEach((el_) => { div.querySelectorAll("a[data-ref]").forEach((el_) => {
const el = el_ as HTMLElement; const el = el_ as HTMLElement;

View File

@ -42,7 +42,7 @@ export class CommandHook extends EventEmitter<CommandHookEvents>
throttledBuildAllCommands = throttle(() => { throttledBuildAllCommands = throttle(() => {
this.buildAllCommands().catch(console.error); this.buildAllCommands().catch(console.error);
}, 1000); }, 200);
async buildAllCommands() { async buildAllCommands() {
this.editorCommands.clear(); this.editorCommands.clear();

View File

@ -410,6 +410,10 @@
.sb-markdown-widget { .sb-markdown-widget {
margin: 0 0 -4ch 0; margin: 0 0 -4ch 0;
::selection {
background-color: var(--editor-selection-background-color) !important;
}
} }
.sb-markdown-top-widget h1, .sb-markdown-top-widget h1,

View File

@ -1,21 +1,27 @@
Welcome to SilverBullet. Since youre starting fresh, you may want to kick off by importing the [[Library/Core]] [[Libraries|library]] of templates and pages. You can do so easily with the button below. Just push it — you know you want to! # Hello there!
Welcome to the wondrous world of SilverBullet. A world that once you discover and appreciate, youll never want to leave.
{[Library: Import|Import Core Library]("!silverbullet.md/Library/Core/")} _One of us!_
Did that? Lets proceed. Out of the box SilverBullet is fairly minimal in terms of functionality. To give you a good “first run” experience, we recommend you start by importing the [[Library/Core]] library into your space. This will give you a couple of useful pages, slash commands, page templates and widgets such as [[Table of Contents]] and [[Linked Mentions]] to start of with. If you have no idea what those are — dont worry about it. Just keep going, youll get the hang of things.
## Getting started Just push this button: {[Library: Import|Import Core Library]("!silverbullet.md/Library/Core/")}
The best way to get a good feel for what SilverBullet is to immediately start playing with it. Here are some things for you to try:
You know you want to.
Just do it.
# Next steps
Now that you have some basics stuff in place, its time to start playing a bit.
* Click on the page picker (book icon) icon at the top right, or hit `Cmd-k` (Mac) or `Ctrl-k` (Linux and Windows) to open the [[Page Picker]]. * Click on the page picker (book icon) icon at the top right, or hit `Cmd-k` (Mac) or `Ctrl-k` (Linux and Windows) to open the [[Page Picker]].
* Type the name of a non-existent page to create it. * Type the name of a non-existent page to create it.
* You _can_ create pages in folders (if youre into that type of thing) simply by putting slashes (`/`) in the name (even on Windows), e.g. `My Folder/My Page`. Dont worry about that folder existing, well automatically create it if it doesnt. * Folders are implicitly created by putting slashes (`/`) in the name (even on Windows), e.g. `My Folder/My Page`. Dont worry about folders existing, well automatically create them if they dont.
* Click on the terminal icon (top right), or hit `Cmd-/` (Mac) or `Ctrl-/` (Linux and Windows), or tap the screen with 3 fingers at the same time (on mobile) to open the [[Command Palette]]. The {[Stats: Show]} one is a safe one to try. * Click on the terminal icon (top right), or hit `Cmd-/` (Mac) or `Ctrl-/` (Linux and Windows), or tap the screen with 3 fingers at the same time (on mobile) to open the [[Command Palette]]. From here you can run various useful and perhaps less useful [[Commands]]. The {[Stats: Show]} one is a safe one to try.
* Click on the “T” icon (top right), or hit `Cmd-Shift-t` (Mac) or `Ctrl-Shift-t` (Linux and Windows) to open the [[Template Picker]] and see what templates you have installed (which should be a few after importing the Core library) * Click on the “T” icon (top right), or hit `Cmd-Shift-t` (Mac) or `Ctrl-Shift-t` (Linux and Windows) to open the [[Template Picker]] and see what templates you have installed (which should be a few after importing the Core library)
* Select some text and hit `Alt-m` to ==highlight== it, or `Cmd-b` (Mac) or `Ctrl-b` (Windows/Linux) to make it **bold**, or `Cmd-i` (Mac) or `Ctrl-i` (Windows/Linux) to make it _italic_. * Select some text and hit `Alt-m` to ==highlight== it, or `Cmd-b` (Mac) or `Ctrl-b` (Windows/Linux) to make it **bold**, or `Cmd-i` (Mac) or `Ctrl-i` (Windows/Linux) to make it _italic_.
* Click a link somewhere on this page to navigate there. When you link to a new page it will initially show up in red (to indicate it does not yet exist), but once you click it — you will create the page automatically (only for real when you actually enter some text). * Click a link somewhere on this page to navigate there. When you link to a new page it will initially show up in red (to indicate it does not yet exist), but once you click it — you will create the page automatically (only for real when you actually enter some text).
* Start typing `[[` somewhere to insert your own page link (with completion). * Start typing `[[` somewhere to insert your own page link (with completion).
* [ ] Tap this box 👈 to mark this task as done.
* Start typing `:party` to trigger the emoji picker 🎉 * Start typing `:party` to trigger the emoji picker 🎉
* Type `/` somewhere in the text to invoke a **slash command**. * Type `/` somewhere in the text to invoke a **slash command**.
* If this is matching your personality type, you can click this button {[Editor: Toggle Vim Mode]} to toggle Vim mode. If you cannot figure out how to exit it, just click that button again. _Phew!_ * If this is matching your personality type, you can click this button {[Editor: Toggle Vim Mode]} to toggle Vim mode. If you cannot figure out how to exit it, just click that button again. _Phew!_
@ -35,11 +41,17 @@ page select name order by name limit 10
``` ```
## What next? ## What next?
If you are a visual learner, you may [enjoy this introduction video on Youtube](https://youtu.be/VemS-cqAD5k). If you are a visual learner, you may [enjoy this introduction video on Youtube](https://www.youtube.com/watch?v=BbNbZgOwB-Y).
Beyond that, you can find more information about SilverBullet on its official website. You have two ways to access it: Beyond that, you can find more information about SilverBullet on its official website. You have two ways to access it:
1. Through its [regular website link](https://silverbullet.md/) 1. Through its [regular website link](https://silverbullet.md/)
2. Directly without leaving SilverBullet, through [[Federation]], just click on this: [[SilverBullet]] (note that all of these will be read-only, for obvious reasons) 2. Directly without leaving SilverBullet, through [[Federation]], just click on this: [[SilverBullet]] (note that all of these will be read-only, for obvious reasons)
To keep up with the latest and greatest going-ons in SilverBullet land, keep an eye on the [[CHANGELOG]]. To keep up with the latest and greatest goings-on in SilverBullet land, keep an eye on the [[CHANGELOG]].
Got any more questions? Join our [community](https://community.silverbullet.md/).
Feel a bit more ready in this endeavor? If so, feel to remove the [[Live Templates|live template]] that renders this on-boarding description. Youre on your own now.
You got this.

View File

@ -1,3 +1,2 @@
# /.fs /index.json 200
/.client/* /_client/:splat 200! /.client/* /_client/:splat 200!
/* /_client/index.html 200 /* /_client/index.html 200