create-refrakt 0.9.1 → 0.9.3

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 (39) hide show
  1. package/dist/bin.js +96 -42
  2. package/dist/bin.js.map +1 -1
  3. package/dist/scaffold.d.ts +2 -1
  4. package/dist/scaffold.d.ts.map +1 -1
  5. package/dist/scaffold.js +198 -30
  6. package/dist/scaffold.js.map +1 -1
  7. package/package.json +9 -2
  8. package/template/src/routes/[...slug]/+page.server.ts +4 -86
  9. package/template-astro/_gitignore +2 -0
  10. package/template-astro/astro.config.mjs +6 -0
  11. package/template-astro/content/_layout.md +14 -0
  12. package/template-astro/content/docs/getting-started.md +40 -0
  13. package/template-astro/content/index.md +18 -0
  14. package/template-astro/src/pages/[...slug].astro +88 -0
  15. package/template-astro/src/setup.ts +56 -0
  16. package/template-astro/tsconfig.json +7 -0
  17. package/template-eleventy/_gitignore +2 -0
  18. package/template-eleventy/content/_layout.md +14 -0
  19. package/template-eleventy/content/docs/getting-started.md +40 -0
  20. package/template-eleventy/content/index.md +18 -0
  21. package/template-eleventy/eleventy.config.js +22 -0
  22. package/template-eleventy/src/_data/refrakt.js +5 -0
  23. package/template-eleventy/src/_includes/base.njk +22 -0
  24. package/template-eleventy/src/pages.njk +9 -0
  25. package/template-next/_gitignore +2 -0
  26. package/template-next/app/[...slug]/page.tsx +124 -0
  27. package/template-next/app/layout.tsx +10 -0
  28. package/template-next/content/_layout.md +14 -0
  29. package/template-next/content/docs/getting-started.md +40 -0
  30. package/template-next/content/index.md +18 -0
  31. package/template-next/next.config.mjs +14 -0
  32. package/template-next/tsconfig.json +21 -0
  33. package/template-nuxt/_gitignore +2 -0
  34. package/template-nuxt/content/_layout.md +14 -0
  35. package/template-nuxt/content/docs/getting-started.md +40 -0
  36. package/template-nuxt/content/index.md +18 -0
  37. package/template-nuxt/nuxt.config.ts +3 -0
  38. package/template-nuxt/pages/[...slug].vue +107 -0
  39. package/template-nuxt/tsconfig.json +3 -0
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: Getting Started
3
+ description: Learn how to work with your refrakt.md site
4
+ ---
5
+
6
+ # Getting Started
7
+
8
+ This is your first documentation page. You can find this file at `content/docs/getting-started.md`.
9
+
10
+ ## Project Structure
11
+
12
+ Your site has two key directories:
13
+
14
+ - `content/` — Markdown files that make up your pages
15
+ - `build/` — Generated HTML output (created by `npm run build`)
16
+
17
+ ## Writing Content
18
+
19
+ Every Markdown file in `content/` becomes a page. Add frontmatter at the top for metadata:
20
+
21
+ ```markdown
22
+ ---
23
+ title: Page Title
24
+ description: A brief description
25
+ ---
26
+ ```
27
+
28
+ ## Using Runes
29
+
30
+ Runes are Markdoc tags that give your Markdown semantic meaning:
31
+
32
+ {% hint type="note" %}
33
+ This callout is created with the `hint` rune. Try changing the `type` attribute to `warning`, `caution`, or `check`.
34
+ {% /hint %}
35
+
36
+ ## Next Steps
37
+
38
+ - Add more pages by creating `.md` files in `content/`
39
+ - Edit `content/_layout.md` to customize your site's header and navigation
40
+ - Explore the available runes in the refrakt.md documentation
@@ -0,0 +1,18 @@
1
+ ---
2
+ title: Welcome
3
+ description: A new refrakt.md site
4
+ ---
5
+
6
+ {% cta %}
7
+
8
+ # Welcome to your site
9
+
10
+ This site is built with refrakt.md — a content framework that extends Markdown with semantic runes.
11
+
12
+ - [Get Started](/docs/getting-started)
13
+
14
+ {% /cta %}
15
+
16
+ {% hint type="note" %}
17
+ Edit the files in `content/` to start building your site. Run `npm run build` to regenerate after changes.
18
+ {% /hint %}
@@ -0,0 +1,14 @@
1
+ /** @type {import('next').NextConfig} */
2
+ const nextConfig = {
3
+ output: 'export',
4
+ transpilePackages: [
5
+ '@markdoc/markdoc',
6
+ '@refrakt-md/runes',
7
+ '@refrakt-md/content',
8
+ '@refrakt-md/types',
9
+ '@refrakt-md/next',
10
+ '@refrakt-md/transform',
11
+ ],
12
+ };
13
+
14
+ export default nextConfig;
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2017",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "preserve",
15
+ "incremental": true,
16
+ "plugins": [{ "name": "next" }],
17
+ "paths": { "@/*": ["./*"] }
18
+ },
19
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
20
+ "exclude": ["node_modules"]
21
+ }
@@ -0,0 +1,2 @@
1
+ node_modules
2
+ build
@@ -0,0 +1,14 @@
1
+ {% layout %}
2
+ {% region name="header" %}
3
+ # My Site
4
+ {% /region %}
5
+
6
+ {% region name="nav" %}
7
+ {% nav %}
8
+ ## Docs
9
+
10
+ - getting-started
11
+
12
+ {% /nav %}
13
+ {% /region %}
14
+ {% /layout %}
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: Getting Started
3
+ description: Learn how to work with your refrakt.md site
4
+ ---
5
+
6
+ # Getting Started
7
+
8
+ This is your first documentation page. You can find this file at `content/docs/getting-started.md`.
9
+
10
+ ## Project Structure
11
+
12
+ Your site has two key directories:
13
+
14
+ - `content/` — Markdown files that make up your pages
15
+ - `build/` — Generated HTML output (created by `npm run build`)
16
+
17
+ ## Writing Content
18
+
19
+ Every Markdown file in `content/` becomes a page. Add frontmatter at the top for metadata:
20
+
21
+ ```markdown
22
+ ---
23
+ title: Page Title
24
+ description: A brief description
25
+ ---
26
+ ```
27
+
28
+ ## Using Runes
29
+
30
+ Runes are Markdoc tags that give your Markdown semantic meaning:
31
+
32
+ {% hint type="note" %}
33
+ This callout is created with the `hint` rune. Try changing the `type` attribute to `warning`, `caution`, or `check`.
34
+ {% /hint %}
35
+
36
+ ## Next Steps
37
+
38
+ - Add more pages by creating `.md` files in `content/`
39
+ - Edit `content/_layout.md` to customize your site's header and navigation
40
+ - Explore the available runes in the refrakt.md documentation
@@ -0,0 +1,18 @@
1
+ ---
2
+ title: Welcome
3
+ description: A new refrakt.md site
4
+ ---
5
+
6
+ {% cta %}
7
+
8
+ # Welcome to your site
9
+
10
+ This site is built with refrakt.md — a content framework that extends Markdown with semantic runes.
11
+
12
+ - [Get Started](/docs/getting-started)
13
+
14
+ {% /cta %}
15
+
16
+ {% hint type="note" %}
17
+ Edit the files in `content/` to start building your site. Run `npm run build` to regenerate after changes.
18
+ {% /hint %}
@@ -0,0 +1,3 @@
1
+ export default defineNuxtConfig({
2
+ modules: ['@refrakt-md/nuxt'],
3
+ });
@@ -0,0 +1,107 @@
1
+ <script setup lang="ts">
2
+ import '@refrakt-md/lumina';
3
+ import { loadContent } from '@refrakt-md/content';
4
+ import { assembleThemeConfig, createTransform } from '@refrakt-md/transform';
5
+ import { loadRunePackage, mergePackages, runes as coreRunes } from '@refrakt-md/runes';
6
+ import manifest from '@refrakt-md/lumina/manifest';
7
+ import { layouts } from '@refrakt-md/lumina/layouts';
8
+ const theme = { manifest, layouts };
9
+ import { renderPage, buildRefraktHead } from '@refrakt-md/nuxt';
10
+ import type { RendererNode } from '@refrakt-md/types';
11
+ import type { RefraktConfig } from '@refrakt-md/types';
12
+ import type { Schema } from '@markdoc/markdoc';
13
+ import { readFileSync } from 'node:fs';
14
+ import * as path from 'node:path';
15
+
16
+ const config: RefraktConfig = JSON.parse(readFileSync(path.resolve('refrakt.config.json'), 'utf-8'));
17
+ const contentDir = path.resolve(config.contentDir);
18
+
19
+ const themeModule = await import(config.theme + '/transform');
20
+ const themeConfig = themeModule.themeConfig ?? themeModule.luminaConfig ?? themeModule.default;
21
+
22
+ let transformConfig = themeConfig;
23
+ let communityTags: Record<string, Schema> | undefined;
24
+
25
+ const packageNames = config.packages ?? [];
26
+ if (packageNames.length > 0) {
27
+ const loaded = await Promise.all(
28
+ packageNames.map((name: string) => loadRunePackage(name))
29
+ );
30
+ const coreRuneNames = new Set(Object.keys(coreRunes));
31
+ const merged = mergePackages(loaded, coreRuneNames, config.runes?.prefer);
32
+
33
+ communityTags = Object.keys(merged.tags).length > 0 ? merged.tags : undefined;
34
+
35
+ const { config: assembledConfig } = assembleThemeConfig({
36
+ coreConfig: themeConfig,
37
+ packageRunes: merged.themeRunes,
38
+ packageIcons: merged.themeIcons,
39
+ packageBackgrounds: merged.themeBackgrounds,
40
+ extensions: merged.extensions as any,
41
+ provenance: merged.provenance,
42
+ });
43
+
44
+ transformConfig = assembledConfig;
45
+ }
46
+
47
+ const transform = createTransform(transformConfig);
48
+
49
+ const route = useRoute();
50
+
51
+ const { data } = await useAsyncData('refrakt-' + route.path, async () => {
52
+ const site = await loadContent(contentDir, '/', {}, communityTags);
53
+
54
+ const currentPage = site.pages.find((p: any) => p.route.url === route.path);
55
+ if (!currentPage) throw createError({ statusCode: 404, message: 'Page not found' });
56
+
57
+ const renderable = transform(currentPage.renderable) as RendererNode;
58
+ const regions: Record<string, any> = {};
59
+ for (const [name, region] of currentPage.layout.regions.entries()) {
60
+ regions[name] = {
61
+ name: region.name,
62
+ mode: region.mode,
63
+ content: region.content.map((c: any) => transform(c) as RendererNode),
64
+ };
65
+ }
66
+
67
+ const pages = site.pages
68
+ .filter((p: any) => !p.route.draft)
69
+ .map((p: any) => ({
70
+ url: p.route.url,
71
+ title: (p.frontmatter.title as string) ?? '',
72
+ draft: false,
73
+ }));
74
+
75
+ return {
76
+ html: renderPage({
77
+ theme,
78
+ page: {
79
+ renderable,
80
+ regions,
81
+ title: (currentPage.frontmatter.title as string) ?? '',
82
+ url: currentPage.route.url,
83
+ pages,
84
+ frontmatter: currentPage.frontmatter,
85
+ headings: currentPage.headings,
86
+ },
87
+ }),
88
+ seo: buildRefraktHead({
89
+ title: (currentPage.frontmatter.title as string) ?? '',
90
+ frontmatter: currentPage.frontmatter,
91
+ seo: currentPage.seo,
92
+ }),
93
+ };
94
+ });
95
+
96
+ if (data.value?.seo) {
97
+ useHead({
98
+ title: data.value.seo.title,
99
+ meta: data.value.seo.meta,
100
+ script: data.value.seo.script,
101
+ });
102
+ }
103
+ </script>
104
+
105
+ <template>
106
+ <div v-if="data" v-html="data.html" />
107
+ </template>
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./.nuxt/tsconfig.json"
3
+ }