@compiiile/compiiile 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.compiiile/public/favicon.png +0 -0
  2. package/.compiiile/src/app.js +5 -0
  3. package/.compiiile/src/components/ClientScript.vue +48 -0
  4. package/.compiiile/src/components/ContentWrapper.vue +288 -0
  5. package/.compiiile/src/components/SlidesContent.vue +56 -0
  6. package/.compiiile/src/components/TableOfContent.vue +65 -0
  7. package/.compiiile/src/components/layout/HamburgerButton.vue +90 -0
  8. package/.compiiile/src/components/layout/TopBar.vue +106 -0
  9. package/.compiiile/src/components/layout/navBar/FilesTree.vue +35 -0
  10. package/.compiiile/src/components/layout/navBar/NavBar.vue +48 -0
  11. package/.compiiile/src/components/layout/navBar/NavListItem.vue +216 -0
  12. package/.compiiile/src/components/searchBar/SearchBar.vue +371 -0
  13. package/.compiiile/src/components/searchBar/SearchResult.vue +98 -0
  14. package/.compiiile/src/env.d.ts +1 -0
  15. package/.compiiile/src/layouts/BaseLayout.astro +38 -0
  16. package/.compiiile/src/layouts/SlidesLayout.astro +12 -0
  17. package/.compiiile/src/layouts/WorkspaceLayout.astro +58 -0
  18. package/.compiiile/src/pages/404.astro +17 -0
  19. package/.compiiile/src/pages/[...path].astro +61 -0
  20. package/.compiiile/src/style/code-theme.scss +30 -0
  21. package/.compiiile/src/style/index.scss +36 -0
  22. package/.compiiile/src/style/layouts.scss +43 -0
  23. package/.compiiile/src/style/print.scss +80 -0
  24. package/.compiiile/src/style/slides.scss +79 -0
  25. package/.compiiile/src/style/texts.scss +92 -0
  26. package/.compiiile/src/style/variables.scss +47 -0
  27. package/.compiiile/src/utils/searchIndex.js +28 -0
  28. package/.compiiile/src/utils/styles.js +9 -0
  29. package/.eslintrc.cjs +15 -0
  30. package/.github/FUNDING.yml +2 -0
  31. package/.prettierignore +1 -0
  32. package/.prettierrc.json +9 -0
  33. package/CHANGELOG.md +25 -0
  34. package/CONTRIBUTING.md +31 -0
  35. package/LICENCE.md +674 -0
  36. package/README.md +273 -0
  37. package/bin/cli.js +5 -0
  38. package/bin/config.js +137 -0
  39. package/bin/vitePluginCompiiile/index.js +32 -0
  40. package/bin/vitePluginCompiiile/markdownConfig.js +30 -0
  41. package/bin/vitePluginCompiiile/models/Context.js +138 -0
  42. package/bin/vitePluginCompiiile/models/FileListItem.js +10 -0
  43. package/bin/vitePluginCompiiile/models/FilesTreeItem.js +8 -0
  44. package/bin/vitePluginCompiiile/models/RouteListItem.js +9 -0
  45. package/bin/vitePluginCompiiile/rehypeHandleYamlMatterPlugin.js +8 -0
  46. package/bin/vitePluginCompiiile/rehypeImagePlugin.js +51 -0
  47. package/bin/vitePluginCompiiile/rehypeLinkPlugin.js +20 -0
  48. package/build.js +16 -0
  49. package/compiiile.config.js +6 -0
  50. package/dist/style.css +1 -0
  51. package/markdown-preview.md +242 -0
  52. package/package.json +81 -0
  53. package/slides-preview.mdx +39 -0
  54. package/src/env.d.ts +1 -0
  55. package/tsconfig.json +6 -0
Binary file
@@ -0,0 +1,5 @@
1
+ import * as context from "virtual:compiiile"
2
+
3
+ export default (app) => {
4
+ app.config.globalProperties.$context = context
5
+ }
@@ -0,0 +1,48 @@
1
+ <template><div></div></template>
2
+
3
+ <script>
4
+ export default {
5
+ name: "ClientScript",
6
+ beforeRouteUpdate() {
7
+ window.removeEventListener("scroll", this.onScroll)
8
+ },
9
+ mounted() {
10
+ window.addEventListener("scroll", this.onScroll)
11
+
12
+ if (import.meta.env.MODE === "development") {
13
+ console.group("Compiiile context")
14
+ console.log(this.$context)
15
+ console.groupEnd()
16
+ }
17
+ },
18
+ methods: {
19
+ async onScroll() {
20
+ const tocItems = [...document.querySelectorAll(".toc a")]
21
+ const anchors = [...document.querySelectorAll(".header-anchor")]
22
+
23
+ const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
24
+ const cursor = document.querySelector(".cursor")
25
+
26
+ // Iterate backwards, on the first match highlight it and break
27
+ for (let i = tocItems.length - 1; i >= 0; i--) {
28
+ if (scrollTop > anchors[i].offsetTop) {
29
+ for (let j = 0; j < tocItems.length; j++) {
30
+ tocItems[j].classList.remove("active")
31
+ }
32
+
33
+ const activeTocItem = tocItems[i]
34
+ activeTocItem.classList.add("active")
35
+ if (activeTocItem && cursor) {
36
+ const activeTocItemBounds = activeTocItem.getBoundingClientRect()
37
+
38
+ const tocWrapperTop = document.querySelector(".toc")?.getBoundingClientRect()?.top
39
+ cursor.style.height = `${activeTocItemBounds.height}px`
40
+ cursor.style.transform = `translateY(${activeTocItemBounds.top - tocWrapperTop}px)`
41
+ }
42
+ break
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ </script>
@@ -0,0 +1,288 @@
1
+ <template>
2
+ <div>
3
+ <table-of-content :table-of-content="tableOfContent" class="no-print" />
4
+
5
+ <div class="markdown-content">
6
+ <slot></slot>
7
+ </div>
8
+
9
+ <div
10
+ v-if="fileSiblings.prev || fileSiblings.next"
11
+ class="siblings no-print"
12
+ :style="{
13
+ justifyContent: !fileSiblings.prev ? 'flex-end' : 'space-between'
14
+ }"
15
+ >
16
+ <a v-if="fileSiblings.prev" class="sibling-link" :href="fileSiblings.prev.routePath">
17
+ <svg
18
+ class="ph-icon"
19
+ xmlns="http://www.w3.org/2000/svg"
20
+ width="192"
21
+ height="192"
22
+ fill="#000000"
23
+ viewBox="0 0 256 256"
24
+ >
25
+ <rect width="256" height="256" fill="none"></rect>
26
+ <line
27
+ x1="216"
28
+ y1="128"
29
+ x2="40"
30
+ y2="128"
31
+ fill="none"
32
+ stroke="#000000"
33
+ stroke-linecap="round"
34
+ stroke-linejoin="round"
35
+ stroke-width="16"
36
+ ></line>
37
+ <polyline
38
+ points="112 56 40 128 112 200"
39
+ fill="none"
40
+ stroke="#000000"
41
+ stroke-linecap="round"
42
+ stroke-linejoin="round"
43
+ stroke-width="16"
44
+ ></polyline>
45
+ </svg>
46
+ {{ fileSiblings.prev.title }}
47
+ </a>
48
+ <a v-if="fileSiblings.next" class="sibling-link sibling-link--next" :href="fileSiblings.next.routePath">
49
+ {{ fileSiblings.next.title }}
50
+ <svg
51
+ class="ph-icon"
52
+ xmlns="http://www.w3.org/2000/svg"
53
+ width="192"
54
+ height="192"
55
+ fill="#000000"
56
+ viewBox="0 0 256 256"
57
+ >
58
+ <rect width="256" height="256" fill="none"></rect>
59
+ <line
60
+ x1="40"
61
+ y1="128"
62
+ x2="216"
63
+ y2="128"
64
+ fill="none"
65
+ stroke="#000000"
66
+ stroke-linecap="round"
67
+ stroke-linejoin="round"
68
+ stroke-width="16"
69
+ ></line>
70
+ <polyline
71
+ points="144 56 216 128 144 200"
72
+ fill="none"
73
+ stroke="#000000"
74
+ stroke-linecap="round"
75
+ stroke-linejoin="round"
76
+ stroke-width="16"
77
+ ></polyline>
78
+ </svg>
79
+ </a>
80
+ </div>
81
+ </div>
82
+ </template>
83
+
84
+ <script>
85
+ import TableOfContent from "./TableOfContent.vue"
86
+
87
+ export default {
88
+ name: "ContentWrapper",
89
+ components: { TableOfContent },
90
+ props: {
91
+ name: {
92
+ type: String,
93
+ required: true
94
+ },
95
+ tableOfContent: {
96
+ type: Array,
97
+ required: true
98
+ }
99
+ },
100
+ computed: {
101
+ fileIndex() {
102
+ return this.$context.fileList.findIndex((file) => file.uuid === this.name)
103
+ },
104
+ file() {
105
+ return this.fileIndex > -1 ? this.$context.fileList[this.fileIndex] : null
106
+ },
107
+ fileSiblings() {
108
+ return {
109
+ prev: this.$context.fileList[this.fileIndex - 1] ?? null,
110
+ next: this.$context.fileList[this.fileIndex + 1] ?? null
111
+ }
112
+ }
113
+ }
114
+ }
115
+ </script>
116
+
117
+ <style scoped lang="scss">
118
+ :deep(.markdown-content) {
119
+ margin-right: calc(var(--toc-width) + 80px);
120
+
121
+ h1,
122
+ h2,
123
+ h3,
124
+ h4,
125
+ h5 {
126
+ &:before {
127
+ /* hack to offset scroll on route hash navigation */
128
+ padding-top: calc(var(--top-bar-height) - 1px);
129
+ margin-top: calc((var(--top-bar-height) - 1px) * -1);
130
+ content: " ";
131
+ display: block;
132
+ }
133
+ }
134
+
135
+ h2,
136
+ h3,
137
+ h4,
138
+ h5,
139
+ h6 {
140
+ margin: 20px 0 10px;
141
+ }
142
+
143
+ h2 {
144
+ margin-top: 40px;
145
+ }
146
+
147
+ p code,
148
+ li code {
149
+ padding: 2px 4px;
150
+ border-radius: 3px;
151
+ background-color: var(--code-background-color);
152
+ border: solid 1px var(--code-background-color); /* same color, useful when printing without background graphics */
153
+ color: var(--code-color);
154
+ font-family: var(--monospace);
155
+ font-size: 0.85rem;
156
+ }
157
+
158
+ p,
159
+ ul {
160
+ line-height: 1.618rem;
161
+ margin-bottom: 1rem;
162
+ }
163
+
164
+ ul {
165
+ padding-left: 40px;
166
+ }
167
+
168
+ hr {
169
+ margin: 40px 0;
170
+ background-color: var(--separator-color);
171
+ height: 1px;
172
+ border: 0;
173
+ }
174
+
175
+ blockquote {
176
+ background-color: var(--blockquote-background-color);
177
+ border: solid 1px var(--blockquote-border-color);
178
+ border-radius: 8px;
179
+ padding: 0.5em 1em;
180
+ color: #babfc4;
181
+ margin: 20px 0;
182
+
183
+ p {
184
+ margin-bottom: 0;
185
+ }
186
+ }
187
+
188
+ img {
189
+ max-width: 100%;
190
+ margin: 0 auto;
191
+ display: block;
192
+ object-fit: contain;
193
+ }
194
+
195
+ a {
196
+ color: var(--link-color);
197
+ }
198
+
199
+ table {
200
+ padding: 0;
201
+ border-collapse: collapse;
202
+ margin-bottom: 20px;
203
+ }
204
+
205
+ table tr {
206
+ border-top: 1px solid var(--table-border-color);
207
+ background-color: var(--table-odd-lines-background-color);
208
+ margin: 0;
209
+ padding: 0;
210
+ }
211
+
212
+ table tr:nth-child(2n) {
213
+ background-color: var(--table-even-lines-background-color);
214
+ }
215
+
216
+ table tr th {
217
+ font-weight: bold;
218
+ border: 1px solid var(--table-border-color);
219
+ text-align: left;
220
+ margin: 0;
221
+ padding: 6px 13px;
222
+ }
223
+
224
+ table tr td {
225
+ border: 1px solid var(--table-border-color);
226
+ text-align: left;
227
+ margin: 0;
228
+ padding: 6px 13px;
229
+ }
230
+
231
+ table tr th :first-child,
232
+ table tr td :first-child {
233
+ margin-top: 0;
234
+ }
235
+
236
+ table tr th :last-child,
237
+ table tr td :last-child {
238
+ margin-bottom: 0;
239
+ }
240
+
241
+ pre code {
242
+ margin-bottom: 1rem;
243
+ }
244
+
245
+ pre.astro-code {
246
+ margin-bottom: 20px;
247
+ font-size: 0.85rem;
248
+ }
249
+
250
+ .header-anchor {
251
+ float: left;
252
+ margin-left: -0.87em;
253
+ padding-right: 0.23em;
254
+ font-weight: 500;
255
+ opacity: 0;
256
+ transition: opacity 0.25s;
257
+ text-decoration: none;
258
+ }
259
+
260
+ h1:hover .header-anchor,
261
+ h2:hover .header-anchor,
262
+ h3:hover .header-anchor,
263
+ h4:hover .header-anchor,
264
+ h5:hover .header-anchor,
265
+ h6:hover .header-anchor,
266
+ .header-anchor:focus {
267
+ opacity: 1;
268
+ }
269
+ }
270
+
271
+ .siblings {
272
+ display: flex;
273
+ margin-right: calc(var(--toc-width) + 80px);
274
+ color: var(--link-color);
275
+ margin-top: 80px;
276
+ gap: 20px;
277
+ flex-wrap: wrap;
278
+
279
+ .sibling-link {
280
+ text-decoration: none;
281
+ }
282
+
283
+ .sibling-link--next {
284
+ text-align: right;
285
+ margin-left: auto;
286
+ }
287
+ }
288
+ </style>
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <div ref="slidesDeckWrapper" class="slides-deck-wrapper">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ name: "SlidesContent",
10
+ data() {
11
+ return {
12
+ loaded: false
13
+ }
14
+ },
15
+ async mounted() {
16
+ const slidesContent = document.querySelector(".slides-content")
17
+ slidesContent.innerHTML = `<div class="reveal deck"><div class="slides"><section>${slidesContent.innerHTML
18
+ .split("<hr>")
19
+ .join("</section><section>")}</section></div></div>`
20
+
21
+ this.loaded = true
22
+
23
+ const deck = document.querySelector(".deck")
24
+
25
+ const Reveal = (await import("reveal.js")).default(deck, {
26
+ embedded: true
27
+ })
28
+
29
+ await Reveal.initialize({
30
+ slideNumber: "c/t"
31
+ })
32
+
33
+ this.$refs.slidesDeckWrapper.style.opacity = 1
34
+
35
+ Reveal.slide(new URLSearchParams(window.location.search).get("slide") || 0)
36
+
37
+ Reveal.on("slidechanged", (event) => {
38
+ history.replaceState({}, "", `?slide=${event.indexh}`)
39
+ })
40
+ }
41
+ }
42
+ </script>
43
+
44
+ <style lang="scss">
45
+ @import "reveal.js/dist/reveal.css";
46
+ @import "reveal.js/dist/theme/black.css";
47
+ @import "../style/slides.scss";
48
+
49
+ :global(#app) {
50
+ height: 100%;
51
+ }
52
+
53
+ .slides-deck-wrapper {
54
+ opacity: 0;
55
+ }
56
+ </style>
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <ul class="toc text-xs">
3
+ <div ref="cursor" class="cursor"></div>
4
+ <li
5
+ v-for="tocItem in tableOfContent"
6
+ :key="tocItem.slug"
7
+ :style="{ marginLeft: `${20 * (tocItem.depth - 1)}px` }"
8
+ class="toc-item"
9
+ >
10
+ <a :href="`#${tocItem.slug}`" class="toc-link">{{ tocItem.text.substring(1) }}</a>
11
+ </li>
12
+ </ul>
13
+ </template>
14
+
15
+ <script>
16
+ export default {
17
+ name: "TableOfContent",
18
+ props: {
19
+ tableOfContent: {
20
+ type: Array,
21
+ required: true
22
+ }
23
+ }
24
+ }
25
+ </script>
26
+
27
+ <style scoped lang="scss">
28
+ .toc {
29
+ width: var(--toc-width);
30
+ position: sticky;
31
+ right: 0;
32
+ top: 100px;
33
+ float: right;
34
+ padding-left: 15px;
35
+ color: var(--dimmed-text-color);
36
+ list-style-type: none;
37
+ border-left: solid 1px var(--separator-color);
38
+ line-height: 1.3rem;
39
+ }
40
+
41
+ .toc-item {
42
+ padding: 2px 0;
43
+ }
44
+
45
+ .cursor {
46
+ height: 0px;
47
+ position: absolute;
48
+ left: -1px;
49
+ top: 0;
50
+ width: 2px;
51
+ background-color: var(--highlight-color);
52
+ transition:
53
+ height 0.2s var(--ease-in-out-quart),
54
+ transform 0.2s linear;
55
+ }
56
+
57
+ .toc-link {
58
+ text-decoration: none;
59
+ transition: color 0.2s linear;
60
+
61
+ &.active {
62
+ color: var(--text-color-base);
63
+ }
64
+ }
65
+ </style>
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <div class="hamburger" @click="toggleNavBar">
3
+ <span class="hamburger-line"></span>
4
+ <span class="hamburger-line"></span>
5
+ <span class="hamburger-line"></span>
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ export default {
11
+ name: "HamburgerButton",
12
+ data() {
13
+ return {
14
+ isOpened: false
15
+ }
16
+ },
17
+ methods: {
18
+ toggleNavBar() {
19
+ const navBar = document.querySelector("nav")
20
+ const hamburger = document.querySelector(".hamburger")
21
+
22
+ navBar.classList.toggle("navbar--opened")
23
+ hamburger.classList.toggle("hamburger--opened")
24
+ }
25
+ }
26
+ }
27
+ </script>
28
+
29
+ <style lang="scss" scoped>
30
+ .hamburger {
31
+ display: flex;
32
+ flex-direction: column;
33
+ justify-content: space-between;
34
+ height: 13px;
35
+ width: 20px;
36
+ cursor: pointer;
37
+ margin-right: 10px;
38
+ flex: 0 0 auto;
39
+
40
+ .hamburger-line {
41
+ display: block;
42
+ height: 1px;
43
+ position: relative;
44
+ background-color: var(--dimmed-text-color);
45
+ transition:
46
+ transform 0.3s cubic-bezier(0.77, 0.2, 0.05, 1),
47
+ width 0.3s ease,
48
+ opacity 0.35s ease;
49
+
50
+ &:nth-child(1) {
51
+ transform-origin: top left;
52
+ width: 100%;
53
+ }
54
+
55
+ &:nth-child(2) {
56
+ width: 50%;
57
+ }
58
+
59
+ &:nth-child(3) {
60
+ transform-origin: bottom left;
61
+ width: 75%;
62
+ }
63
+ }
64
+
65
+ &.hamburger--opened {
66
+ .hamburger-line:nth-child(1),
67
+ .hamburger-line:nth-child(3) {
68
+ opacity: 1;
69
+ width: 87.5%;
70
+ }
71
+
72
+ .hamburger-line:nth-child(1) {
73
+ transform: translateX(4.5px) rotate(45deg);
74
+ }
75
+
76
+ .hamburger-line:nth-child(2) {
77
+ opacity: 0;
78
+ transform: scale(0, 1);
79
+ }
80
+
81
+ .hamburger-line:nth-child(3) {
82
+ transform: translateX(4.5px) rotate(-45deg);
83
+ }
84
+ }
85
+
86
+ @media screen and (min-width: 900px) {
87
+ display: none;
88
+ }
89
+ }
90
+ </style>
@@ -0,0 +1,106 @@
1
+ <template>
2
+ <div class="top-bar no-print">
3
+ <div class="centered-layout">
4
+ <div class="top-bar-content">
5
+ <hamburger-button />
6
+ <span class="home-link-wrapper">
7
+ <a :href="logoUrl">
8
+ <img
9
+ v-if="isLogoDefined"
10
+ :src="`${base}favicon.png`"
11
+ :width="30"
12
+ :height="30"
13
+ class="logo"
14
+ alt="logo"
15
+ />
16
+ </a>
17
+
18
+ <a :href="base" class="home-link">
19
+ <h1 class="title">{{ title }}</h1>
20
+ </a>
21
+ </span>
22
+ <search-bar />
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </template>
27
+
28
+ <script>
29
+ import SearchBar from "../searchBar/SearchBar.vue"
30
+ import HamburgerButton from "./HamburgerButton.vue"
31
+ import { site } from "virtual:compiiile"
32
+
33
+ export default {
34
+ name: "TopBar",
35
+ components: { HamburgerButton, SearchBar },
36
+ computed: {
37
+ title() {
38
+ return site.title
39
+ },
40
+ isLogoDefined() {
41
+ return site.logo !== undefined
42
+ },
43
+ base() {
44
+ let base = import.meta.env.BASE_URL
45
+
46
+ if (!base.endsWith("/")) {
47
+ base += "/"
48
+ }
49
+
50
+ return base
51
+ },
52
+ logoUrl() {
53
+ return site.logoUrl ?? this.base
54
+ }
55
+ }
56
+ }
57
+ </script>
58
+
59
+ <style scoped>
60
+ .top-bar {
61
+ position: fixed;
62
+ top: 0;
63
+ left: 0;
64
+ width: 100%;
65
+ border-bottom: solid 1px var(--separator-color);
66
+ background-color: var(--layout-background-color);
67
+ z-index: 3;
68
+ }
69
+
70
+ .top-bar-content {
71
+ padding: 20px var(--layout-padding);
72
+ height: var(--top-bar-height);
73
+ display: flex;
74
+ align-items: center;
75
+ justify-content: space-between;
76
+ }
77
+
78
+ .home-link-wrapper {
79
+ display: flex;
80
+ align-items: center;
81
+ }
82
+
83
+ .home-link {
84
+ color: var(--text-color-base) !important;
85
+ text-decoration: none;
86
+ }
87
+
88
+ .title {
89
+ margin: 0;
90
+ font-size: 1.5rem;
91
+ max-width: 100%;
92
+ display: inline-block;
93
+ -webkit-box-orient: vertical;
94
+ display: -webkit-box;
95
+ -webkit-line-clamp: 2;
96
+ overflow: hidden;
97
+ text-overflow: ellipsis;
98
+ white-space: normal;
99
+ }
100
+
101
+ .logo {
102
+ margin-right: 10px;
103
+ border-radius: 2px;
104
+ display: block;
105
+ }
106
+ </style>
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <ul class="files-tree text-xs">
3
+ <nav-list-item
4
+ v-for="navItem in $context.filesTree"
5
+ :key="navItem.uuid"
6
+ :item="navItem"
7
+ :current-path="currentPath"
8
+ />
9
+ </ul>
10
+ </template>
11
+
12
+ <script>
13
+ import NavListItem from "./NavListItem.vue"
14
+
15
+ export default {
16
+ name: "FilesTree",
17
+ components: { NavListItem },
18
+ props: {
19
+ currentPath: {
20
+ type: String,
21
+ required: true
22
+ }
23
+ }
24
+ }
25
+ </script>
26
+
27
+ <style scoped>
28
+ .files-tree {
29
+ list-style-type: none;
30
+ }
31
+
32
+ .files-tree {
33
+ padding-left: 0;
34
+ }
35
+ </style>