@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
@@ -0,0 +1,51 @@
1
+ import { visit } from "unist-util-visit"
2
+
3
+ const filterObjectDefinedValuesOnly = (obj) =>
4
+ Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined))
5
+
6
+ export default function rehypeImagePlugin() {
7
+ const processImageNode = (altAttributeValue) => {
8
+ if (altAttributeValue) {
9
+ const matchWidth = altAttributeValue.match(/(?<altValue>.*)\|.*?(?<width>\d+(px|%)?)/)?.groups || {}
10
+ const matchNoMargin = altAttributeValue.match(/(?<altValue>.*)\|.*?(?<noMargin>no-margin)/)?.groups || {}
11
+
12
+ return {
13
+ ...filterObjectDefinedValuesOnly(matchWidth),
14
+ ...filterObjectDefinedValuesOnly(matchNoMargin)
15
+ }
16
+ }
17
+ return null
18
+ }
19
+
20
+ const buildImageStyleAttribute = (parsedAltValue) => {
21
+ return `${parsedAltValue.width ? "width:" + parsedAltValue.width + ";height:auto;" : ""}${
22
+ parsedAltValue.noMargin ? "margin:0" : ""
23
+ }`
24
+ }
25
+
26
+ return (tree) => {
27
+ visit(tree, "element", function (node) {
28
+ if (node.tagName === "img") {
29
+ const parsedAltValue = processImageNode(node.properties?.alt)
30
+ if (parsedAltValue) {
31
+ node.properties.style = buildImageStyleAttribute(parsedAltValue)
32
+ node.properties.alt = parsedAltValue.altValue
33
+ }
34
+ }
35
+ })
36
+ visit(tree, "mdxJsxFlowElement", function (node) {
37
+ if (node.name === "astro-image") {
38
+ const alt = node.attributes?.find((attr) => attr.name === "alt")
39
+ const parsedAltValue = processImageNode(alt?.value)
40
+ if (parsedAltValue) {
41
+ node.attributes.push({
42
+ name: "style",
43
+ type: "mdxJsxAttribute",
44
+ value: buildImageStyleAttribute(parsedAltValue)
45
+ })
46
+ alt.value = parsedAltValue.altValue
47
+ }
48
+ }
49
+ })
50
+ }
51
+ }
@@ -0,0 +1,20 @@
1
+ import { visit } from "unist-util-visit"
2
+
3
+ export default function rehypeLinkPlugin() {
4
+ return (tree, file) => {
5
+ const context = JSON.parse(process.env.context || "{}")
6
+ visit(tree, "element", (node) => {
7
+ if (node.tagName === "a") {
8
+ if (node.properties.href.match(/^\.{1,2}\/.*/)) {
9
+ const linkTargetUrl = new URL(node.properties.href, `file://${file.history[0]}`)
10
+ const path = decodeURI(linkTargetUrl.pathname).replaceAll("%20", " ")
11
+ const decodedFilePath = decodeURIComponent(decodeURIComponent(path))
12
+ const filePath = decodedFilePath.replace(process.env.COMPIIILE_SOURCE, "")
13
+ node.properties.href = context.fileRouteMap?.[filePath.substring(1)] + linkTargetUrl.hash
14
+ } else {
15
+ node.properties.target = "_blank"
16
+ }
17
+ }
18
+ })
19
+ }
20
+ }
package/build.js ADDED
@@ -0,0 +1,16 @@
1
+ import { build } from "vite"
2
+ import { unlinkSync } from "node:fs"
3
+
4
+ const jsFileName = "style.es.js"
5
+ await build({
6
+ build: {
7
+ lib: {
8
+ entry: new URL("./.compiiile/src/utils/styles.js", import.meta.url).pathname,
9
+ name: "style",
10
+ formats: ["es"],
11
+ fileName: (_) => jsFileName
12
+ }
13
+ }
14
+ })
15
+
16
+ await unlinkSync(`./dist/${jsFileName}`)
@@ -0,0 +1,6 @@
1
+ export default {
2
+ title: "Compiiile",
3
+ description:
4
+ "Compiiile is the most convenient way to render a folder containing markdown files. Previewing and searching markdown files has never been that easy (it's really just a command away !)",
5
+ siteUrl: "https://compiiile.me"
6
+ }