Skip to content

Commit 4d7e42f

Browse files
committed
📘 blog: scalar
1 parent 4f8e399 commit 4d7e42f

File tree

12 files changed

+136
-3
lines changed

12 files changed

+136
-3
lines changed

components/blog/Layout.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
<img
2424
:src="props.src"
2525
:alt="props.alt"
26-
class="w-full shadow-2xl my-6"
26+
class="w-full my-6"
27+
:class="props.shadow ? 'shadow-xl' : 'border'"
2728
/>
2829
<main id="blog-content">
2930
<slot />
@@ -51,6 +52,7 @@ const props = defineProps<{
5152
alt: string
5253
author: keyof Authors
5354
date: string
55+
shadow?: boolean
5456
}>()
5557
5658
const author = authors[props.author]
@@ -116,7 +118,7 @@ onUnmounted(() => {
116118
#blog-content > img,
117119
#blog-content > * > img {
118120
@apply rounded-xl my-4;
119-
box-shadow: 0 8px 25px rgba(0,0,0,.1)
121+
/* box-shadow: 0 8px 25px rgba(0,0,0,.1) */
120122
}
121123
122124
.-png {

docs/blog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ head:
2424

2525
<Blogs
2626
:blogs="[
27+
{
28+
title: 'Introducing support for Scalar - Elysia',
29+
href: '/blog/elysia-scalar',
30+
detail: 'We are changing API documentation provider to Scalar instead of Swagger UI by default. Scalar is a modern, beautiful API references for OpenAPI compatible, and customizable built on-top of Vue. Elysia now ship @elysia/swagger package by using Scalar as a default provider, with option to switch back to Swagger UI if need.'
31+
},
2732
{
2833
title: 'Introducing Elysia 0.8 - Gate of Steiner',
2934
href: '/blog/elysia-08',

docs/blog/elysia-08.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ head:
3434
src="/blog/elysia-08/gate-of-steiner.webp"
3535
alt="Satellite floating in space before the vast world"
3636
author="saltyaom"
37-
date="20 Sep 2023"
37+
date="23 Dec 2023"
3838
>
3939
4040
Named after the ending song of Steins;Gate Zero, [**"Gate of Steiner"**](https://youtu.be/S5fnglcM5VI).

docs/blog/elysia-scalar.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
title: Introducing support for Scalar - Elysia
3+
sidebar: false
4+
editLink: false
5+
search: false
6+
head:
7+
- - meta
8+
- property: 'og:title'
9+
content: Introducing support for Scalar - Elysia
10+
11+
- - meta
12+
- name: 'description'
13+
content: We are changing API documentation provider to Scalar instead of Swagger UI by default. Scalar is a modern, beautiful API references for OpenAPI compatible, and customizable built on-top of Vue. Elysia now ship @elysia/swagger package by using Scalar as a default provider, with option to switch back to Swagger UI if need.
14+
15+
- - meta
16+
- property: 'og:description'
17+
content: We are changing API documentation provider to Scalar instead of Swagger UI by default. Scalar is a modern, beautiful API references for OpenAPI compatible, and customizable built on-top of Vue. Elysia now ship @elysia/swagger package by using Scalar as a default provider, with option to switch back to Swagger UI if need.
18+
19+
- - meta
20+
- property: 'og:image'
21+
content: https://elysiajs.com/blog/elysia-08/gate-of-steiner.webp
22+
23+
- - meta
24+
- property: 'twitter:image'
25+
content: https://elysiajs.com/blog/elysia-08/gate-of-steiner.webp
26+
---
27+
28+
<script setup>
29+
import Blog from '../../components/blog/Layout.vue'
30+
</script>
31+
32+
<Blog
33+
title="Introducing support for Scalar - Elysia"
34+
src="/blog/elysia-scalar/scalar-by-default.webp"
35+
alt="Scalar Web client on the left with the word 'Scalar by default' on the right with Elysia logo under the title"
36+
author="saltyaom"
37+
date="7 Jan 2024"
38+
>
39+
40+
We believe that good developer experience is crucial to create good software.
41+
42+
Giving you, developers. Wonderful tools have been our mission since day one of creating Elysia.
43+
44+
> **We believe in creativity.**
45+
46+
That developer and open-source community will be able to create a new way to interact with software.
47+
48+
You are the visionary, seeking freedom not bound to words but through actions.
49+
50+
We search for the best tooling we can find and provide, for you to create wonderful things.
51+
52+
Today, we changed the default documentation provider from Swagger to [Scalar](https://github.com/scalar/scalar) by default.
53+
54+
## Scalar
55+
Starting from 0.8.1 of `@elysiajs/swagger`, the documentation provider will be using Scalar by default.
56+
57+
![Scalar documentation running for Elysia server](/blog/elysia-scalar/landing.webp)
58+
59+
Scalar is a modern, beautiful, and customizable OpenAPI specification documentation built on Vue.
60+
61+
Open-source and maintained by a very active team of talented developers.
62+
63+
As same as Swagger UI, providing the same **detail** in route will be available in Scalar documentation to communicate with your team or take note for a route.
64+
65+
```typescript
66+
import { Elysia } from 'elysia'
67+
68+
new Elysia()
69+
.get('/', 'hi', {
70+
detail: {
71+
title: 'hello',
72+
description: 'This is a test path'
73+
}
74+
})
75+
```
76+
77+
Scalar provides a snippet for working with your favorite tools and programming language to communicate with the endpoint, so even if you or one of your team don't know how to, the documentation will provide that for your need.
78+
![Scalar documentation running for Elysia server](/blog/elysia-scalar/snippet.webp)
79+
80+
Scalar also offers search, and expressive UI for composing requests with the basic auto-fill template you need out of the box.
81+
![Scalar documentation running for Elysia server](/blog/elysia-scalar/editor.webp)
82+
83+
Lastly, what you probably are looking for, is dark mode.
84+
![Scalar documentation running for Elysia server](/blog/elysia-scalar/dark-mode.webp)
85+
86+
## Provider
87+
If not satisfied and prefer to stick with Swagger UI, you can use **provider** option to switch between **swagger-ui** and **scalar**, and it would just work.
88+
89+
```typescript
90+
import { Elysia } from 'elysia'
91+
import { swagger } from '@elysiajs/swagger'
92+
93+
new Elysia()
94+
.use(swagger({
95+
provider: 'swagger-ui'
96+
}))
97+
.get('/', () => 'hi')
98+
.post('/hello', () => 'world')
99+
.listen(8080)
100+
```
101+
102+
You can find out more about Scalar customization in [Swagger plugin](/plugins/swagger).
103+
104+
## Wrapping up
105+
106+
That's wrapping it up for today.
107+
108+
Might not be as exciting as the new version or feature, but we plan to add some Elysia-specific integration for Scalar in the future.
109+
110+
Scalar provides a Vue component support that we can build on top of, allowing us to explore and customization with Vue.
111+
112+
If you like to try out Scalar today, update `@elysiajs/swagger` to the latest version and see your new shiny documentation for yourself.
113+
114+
Be sure to check out [Scalar on GitHub](https://github.com/scalar/scalar) as they provide excellent support for many open-source projects out there including Hono, Nestjs, Fastify, and Express as well.
115+
116+
</Blog>

docs/plugins/swagger.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ Accessing `/swagger` would show you a Swagger UI with the generated endpoint doc
3939
## Config
4040
Below is a config which is accepted by the plugin
4141

42+
### provider
43+
@default `scalar`
44+
45+
UI Provider for documentation. Default to Scalar.
46+
47+
### scalar
48+
Configuration for customizing Scalar.
49+
50+
Please refer to the [Scalar config](https://github.com/scalar/scalar?tab=readme-ov-file#configuration)
51+
4252
### swagger
4353
Configuration for customizing Swagger.
4454

94.4 KB
Binary file not shown.
113 KB
Binary file not shown.
92.4 KB
Binary file not shown.
Loading
Binary file not shown.

0 commit comments

Comments
 (0)