API
You may be asking: "isn't this Neocities?" Yes, but this is also SvelteKit. With the power of prerendered routes with parameters, we've got ourselves a way to make an API. Keyword prerendered. Don't think about trying to break this as it's still just static files.
Posts
Currently only sorted by update date, unless otherwise stated.
Post format
As described in
PostData
.api/v1/posts/all.json
Returns all posts.
api/v1/posts/featured.json
Returns all of the featured posts. Sort is manually determined.
api/v1/posts/length/[tag].json
Returns the amount of posts for a given tag.
- #thing:
v1/posts/length/thing.json
- Everything:
v1/posts/length/all.json
api/v1/posts/page/[tag]/[page].json
Returns the posts for a given tag and page. A single page holds up to 15 posts.
- Page 1 of #thing:
v1/posts/page/thing/0.json
- Page 2 of #thing:
v1/posts/page/thing/1.json
- Page 1 of everything:
v1/posts/page/0.json
Image processing
Uses the
/sri/
folder in the project directory. Short for "source image", and fits nicely under the src folder.WarningIf SvelteKit isn't able to find an SRI image when crawling the website, it won't be saved!
/sri1/[img]
Gives an image from
/sri/
in the project directory, transforming them if needed.For example, if you had
test.png
in your /sri/
folder:/sri1/test.webp
would givetest.png
in the WebP format/sri1/test.200.png
would givetest.png
resized to a width of 200
/sri/[img]
Simply passes an image from
/sri/
, and nothing else. Note that some of these things in this folder are from /static/
.NoteIt's recommended to detect/sri/
withresolveSri()
and replace it with the according endpoint. For example, a Markdown image should automatically turn/sri/hi.png
into something like/sri1/hi.300.webp
.When doing so, make sure to give a way to download the original image. .webp is great on the web, but it's not widely supported in things like image editors due to the will of god.
Stylesheets
/style/[style].css
(WIP)
Gives a style from
/src/style/
in the project directory, transforming them and shit. A dumb workaround for vitejs/vite#2522./style/error.css
would givesrc/style/error.scss
Editor
/api/v1/open-in-editor
opens a file in vscode. internally it ensures the file exists and then opens it using
code --goto <path>
.originally i used sveltekit's internal api
/__open-in-editor
, but it doesn't error if a file doesn't exist, and also it's not the best to use an internal api :woozy:/api/v1/open-in-editor?file=package.json
: opens package.json in the root of the project
Attribution
/api/v1/packages.json
gives all installed packages with their license and author info. used for the credits.
Commits
/api/v1/commits/[range].json
returns commit history.
api/v1/commits/1692898781.json
: gets commits starting at 1692898781 seconds from the unix epoch to nowapi/v1/commits/1692898781-1692898911.json
: above but stops at 1692898911 seconds
Favicon
/api/v1/favicon/[domain].ico
gets the favicon of a given domain. if a favicon isnt found, then it will simply 404.
dabric.xyz.ico
:dummy.ico
:
uses duckduckgo's favicon api. i have no idea if duckduckgo intended for this api to be used publicly, but other apps such as tampermonkey use it, so...
/api/v1/favicon-f/[domain].ico
like above, but will return a placeholder favicon if one is not found. it does not 404.
dabric.xyz.ico
:dummy.ico
: