@refrakt-md/learning 0.7.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.
@@ -0,0 +1,3 @@
1
+ import type { RuneConfig } from '@refrakt-md/transform';
2
+ export declare const config: Record<string, RuneConfig>;
3
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CA0C7C,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,44 @@
1
+ export const config = {
2
+ HowTo: {
3
+ block: 'howto',
4
+ contentWrapper: { tag: 'div', ref: 'content' },
5
+ modifiers: {
6
+ estimatedTime: { source: 'meta' },
7
+ difficulty: { source: 'meta', default: 'medium' },
8
+ },
9
+ structure: {
10
+ meta: {
11
+ tag: 'div', before: true,
12
+ conditionAny: ['estimatedTime', 'difficulty'],
13
+ children: [
14
+ { tag: 'span', ref: 'meta-item', metaText: 'estimatedTime', transform: 'duration', textPrefix: 'Estimated time: ', condition: 'estimatedTime' },
15
+ { tag: 'span', ref: 'meta-item', metaText: 'difficulty', textPrefix: 'Difficulty: ', condition: 'difficulty' },
16
+ ],
17
+ },
18
+ },
19
+ },
20
+ Recipe: {
21
+ block: 'recipe',
22
+ contentWrapper: { tag: 'div', ref: 'content' },
23
+ modifiers: {
24
+ prepTime: { source: 'meta' },
25
+ cookTime: { source: 'meta' },
26
+ servings: { source: 'meta' },
27
+ difficulty: { source: 'meta', default: 'medium' },
28
+ },
29
+ structure: {
30
+ meta: {
31
+ tag: 'div', before: true,
32
+ conditionAny: ['prepTime', 'cookTime', 'servings', 'difficulty'],
33
+ children: [
34
+ { tag: 'span', ref: 'meta-item', metaText: 'prepTime', transform: 'duration', textPrefix: 'Prep: ', condition: 'prepTime' },
35
+ { tag: 'span', ref: 'meta-item', metaText: 'cookTime', transform: 'duration', textPrefix: 'Cook: ', condition: 'cookTime' },
36
+ { tag: 'span', ref: 'meta-item', metaText: 'servings', textPrefix: 'Serves: ', condition: 'servings' },
37
+ { tag: 'span', ref: 'badge', metaText: 'difficulty', condition: 'difficulty' },
38
+ ],
39
+ },
40
+ },
41
+ },
42
+ RecipeIngredient: { block: 'recipe-ingredient', parent: 'Recipe' },
43
+ };
44
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAA+B;IACjD,KAAK,EAAE;QACN,KAAK,EAAE,OAAO;QACd,cAAc,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE;QAC9C,SAAS,EAAE;YACV,aAAa,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;YACjC,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE;SACjD;QACD,SAAS,EAAE;YACV,IAAI,EAAE;gBACL,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI;gBACxB,YAAY,EAAE,CAAC,eAAe,EAAE,YAAY,CAAC;gBAC7C,QAAQ,EAAE;oBACT,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,SAAS,EAAE,eAAe,EAAE;oBAC/I,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE;iBAC9G;aACD;SACD;KACD;IACD,MAAM,EAAE;QACP,KAAK,EAAE,QAAQ;QACf,cAAc,EAAE,EAAE,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default learning;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD,eAAO,MAAM,QAAQ,EAAE,WAsDtB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,60 @@
1
+ import { howto } from './tags/howto.js';
2
+ import { recipe } from './tags/recipe.js';
3
+ import { config } from './config.js';
4
+ export const learning = {
5
+ name: 'learning',
6
+ displayName: 'Learning',
7
+ version: '0.6.0',
8
+ runes: {
9
+ 'howto': {
10
+ transform: howto,
11
+ aliases: ['how-to'],
12
+ description: 'Step-by-step how-to guide with tools/materials list and instructions',
13
+ seoType: 'HowTo',
14
+ reinterprets: { 'ordered list': 'steps', list: 'tools/materials', heading: 'title' },
15
+ fixture: `{% howto estimatedTime="PT45M" difficulty="easy" %}
16
+ # Set Up a Refrakt Theme
17
+
18
+ - Node.js 20+
19
+ - A code editor
20
+ - Basic CSS knowledge
21
+
22
+ 1. Create a new directory for your theme
23
+ 2. Run \`npm init\` and add the theme-base dependency
24
+ 3. Create your \`theme.config.ts\` extending baseConfig
25
+ 4. Write CSS targeting the BEM selectors from \`refrakt inspect\`
26
+ 5. Test with \`refrakt inspect --serve\`
27
+ {% /howto %}`,
28
+ },
29
+ 'recipe': {
30
+ transform: recipe,
31
+ description: 'Recipe with ingredients, steps, and chef tips. Lists become ingredients, ordered lists become steps, blockquotes become tips.',
32
+ seoType: 'Recipe',
33
+ reinterprets: { list: 'ingredients', 'ordered list': 'steps', blockquote: 'chef tips', image: 'recipe photo', heading: 'recipe name' },
34
+ fixture: `{% recipe prepTime="PT15M" cookTime="PT30M" servings="4" difficulty="medium" %}
35
+ # Classic Margherita Pizza
36
+
37
+ - 500g bread flour
38
+ - 7g dried yeast
39
+ - 1 tsp salt
40
+ - 300ml warm water
41
+ - San Marzano tomatoes
42
+ - Fresh mozzarella
43
+ - Fresh basil leaves
44
+
45
+ 1. Mix flour, yeast, and salt in a large bowl
46
+ 2. Add warm water and knead for 10 minutes until smooth
47
+ 3. Let the dough rise for 1 hour at room temperature
48
+ 4. Shape into rounds and add toppings
49
+ 5. Bake at 250°C for 8-10 minutes
50
+
51
+ > For the best crust, preheat your oven with a pizza stone for at least 30 minutes before baking.
52
+ {% /recipe %}`,
53
+ },
54
+ },
55
+ theme: {
56
+ runes: config,
57
+ },
58
+ };
59
+ export default learning;
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,CAAC,MAAM,QAAQ,GAAgB;IACnC,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU;IACvB,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE;QACL,OAAO,EAAE;YACP,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,CAAC,QAAQ,CAAC;YACnB,WAAW,EAAE,sEAAsE;YACnF,OAAO,EAAE,OAAO;YAChB,YAAY,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAE;YACpF,OAAO,EAAE;;;;;;;;;;;;aAYF;SACR;QACD,QAAQ,EAAE;YACR,SAAS,EAAE,MAAM;YACjB,WAAW,EAAE,+HAA+H;YAC5I,OAAO,EAAE,QAAQ;YACjB,YAAY,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE;YACtI,OAAO,EAAE;;;;;;;;;;;;;;;;;;cAkBD;SACT;KACF;IACD,KAAK,EAAE;QACL,KAAK,EAAE,MAA4D;KACpE;CACF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { ComponentType, PageSection, PageSectionProperties } from "@refrakt-md/types";
2
+ export declare class HowTo extends PageSection {
3
+ estimatedTime: string;
4
+ difficulty: string;
5
+ }
6
+ export interface HowToProperties extends PageSectionProperties {
7
+ estimatedTime: 'meta';
8
+ difficulty: 'meta';
9
+ }
10
+ export interface HowToComponent extends ComponentType<HowTo> {
11
+ tag: 'article';
12
+ properties: HowToProperties;
13
+ refs: {
14
+ tools: 'ul';
15
+ steps: 'ol';
16
+ };
17
+ }
18
+ //# sourceMappingURL=howto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"howto.d.ts","sourceRoot":"","sources":["../../src/schema/howto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEtF,qBAAa,KAAM,SAAQ,WAAW;IACrC,aAAa,EAAE,MAAM,CAAM;IAC3B,UAAU,EAAE,MAAM,CAAM;CACxB;AAED,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa,CAAC,KAAK,CAAC;IAC3D,GAAG,EAAE,SAAS,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;IAC5B,IAAI,EAAE;QACL,KAAK,EAAE,IAAI,CAAC;QACZ,KAAK,EAAE,IAAI,CAAC;KACZ,CAAA;CACD"}
@@ -0,0 +1,9 @@
1
+ import { PageSection } from "@refrakt-md/types";
2
+ export class HowTo extends PageSection {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.estimatedTime = '';
6
+ this.difficulty = '';
7
+ }
8
+ }
9
+ //# sourceMappingURL=howto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"howto.js","sourceRoot":"","sources":["../../src/schema/howto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAyB,MAAM,mBAAmB,CAAC;AAEtF,MAAM,OAAO,KAAM,SAAQ,WAAW;IAAtC;;QACC,kBAAa,GAAW,EAAE,CAAC;QAC3B,eAAU,GAAW,EAAE,CAAC;IACzB,CAAC;CAAA"}
@@ -0,0 +1,37 @@
1
+ import { ComponentType, PageSection, PageSectionProperties } from "@refrakt-md/types";
2
+ export declare class RecipeIngredient {
3
+ amount: string;
4
+ unit: string;
5
+ name: string;
6
+ }
7
+ export interface RecipeIngredientComponent extends ComponentType<RecipeIngredient> {
8
+ tag: 'li';
9
+ properties: {
10
+ amount: 'span';
11
+ unit: 'span';
12
+ name: 'span';
13
+ };
14
+ refs: {};
15
+ }
16
+ export declare class Recipe extends PageSection {
17
+ prepTime: string;
18
+ cookTime: string;
19
+ servings: number | undefined;
20
+ difficulty: string;
21
+ }
22
+ export interface RecipeProperties extends PageSectionProperties {
23
+ prepTime: 'meta';
24
+ cookTime: 'meta';
25
+ servings: 'meta';
26
+ difficulty: 'meta';
27
+ }
28
+ export interface RecipeComponent extends ComponentType<Recipe> {
29
+ tag: 'article';
30
+ properties: RecipeProperties;
31
+ refs: {
32
+ ingredients: 'ul';
33
+ steps: 'ol';
34
+ tips: 'div';
35
+ };
36
+ }
37
+ //# sourceMappingURL=recipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe.d.ts","sourceRoot":"","sources":["../../src/schema/recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEtF,qBAAa,gBAAgB;IAC5B,MAAM,EAAE,MAAM,CAAM;IACpB,IAAI,EAAE,MAAM,CAAM;IAClB,IAAI,EAAE,MAAM,CAAM;CAClB;AAED,MAAM,WAAW,yBAA0B,SAAQ,aAAa,CAAC,gBAAgB,CAAC;IACjF,GAAG,EAAE,IAAI,CAAC;IACV,UAAU,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACb,CAAC;IACF,IAAI,EAAE,EAAE,CAAA;CACR;AAED,qBAAa,MAAO,SAAQ,WAAW;IACtC,QAAQ,EAAE,MAAM,CAAM;IACtB,QAAQ,EAAE,MAAM,CAAM;IACtB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAa;IACzC,UAAU,EAAE,MAAM,CAAY;CAC9B;AAED,MAAM,WAAW,gBAAiB,SAAQ,qBAAqB;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa,CAAC,MAAM,CAAC;IAC7D,GAAG,EAAE,SAAS,CAAC;IACf,UAAU,EAAE,gBAAgB,CAAC;IAC7B,IAAI,EAAE;QACL,WAAW,EAAE,IAAI,CAAC;QAClB,KAAK,EAAE,IAAI,CAAC;QACZ,IAAI,EAAE,KAAK,CAAC;KACZ,CAAA;CACD"}
@@ -0,0 +1,18 @@
1
+ import { PageSection } from "@refrakt-md/types";
2
+ export class RecipeIngredient {
3
+ constructor() {
4
+ this.amount = '';
5
+ this.unit = '';
6
+ this.name = '';
7
+ }
8
+ }
9
+ export class Recipe extends PageSection {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.prepTime = '';
13
+ this.cookTime = '';
14
+ this.servings = undefined;
15
+ this.difficulty = 'medium';
16
+ }
17
+ }
18
+ //# sourceMappingURL=recipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe.js","sourceRoot":"","sources":["../../src/schema/recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAyB,MAAM,mBAAmB,CAAC;AAEtF,MAAM,OAAO,gBAAgB;IAA7B;QACC,WAAM,GAAW,EAAE,CAAC;QACpB,SAAI,GAAW,EAAE,CAAC;QAClB,SAAI,GAAW,EAAE,CAAC;IACnB,CAAC;CAAA;AAYD,MAAM,OAAO,MAAO,SAAQ,WAAW;IAAvC;;QACC,aAAQ,GAAW,EAAE,CAAC;QACtB,aAAQ,GAAW,EAAE,CAAC;QACtB,aAAQ,GAAuB,SAAS,CAAC;QACzC,eAAU,GAAW,QAAQ,CAAC;IAC/B,CAAC;CAAA"}
@@ -0,0 +1,3 @@
1
+ import Markdoc from '@markdoc/markdoc';
2
+ export declare const howto: Markdoc.Schema;
3
+ //# sourceMappingURL=howto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"howto.d.ts","sourceRoot":"","sources":["../../src/tags/howto.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAoFvC,eAAO,MAAM,KAAK,gBAA2B,CAAC"}
@@ -0,0 +1,95 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import Markdoc from '@markdoc/markdoc';
11
+ const { Ast, Tag } = Markdoc;
12
+ import { attribute, group, Model, createComponentRenderable, createSchema, NodeStream, pageSectionProperties, headingsToList } from '@refrakt-md/runes';
13
+ import { schema } from '../types.js';
14
+ const difficultyType = ['easy', 'medium', 'hard'];
15
+ class HowToModel extends Model {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.estimatedTime = '';
19
+ this.difficulty = '';
20
+ this.headingLevel = undefined;
21
+ }
22
+ processChildren(nodes) {
23
+ if (this.headingLevel !== undefined) {
24
+ return super.processChildren(headingsToList({ level: this.headingLevel })(nodes));
25
+ }
26
+ return super.processChildren(nodes);
27
+ }
28
+ transform() {
29
+ const header = this.header.transform();
30
+ const body = this.body.transform();
31
+ const estimatedTimeMeta = new Tag('meta', { content: this.estimatedTime });
32
+ const difficultyMeta = new Tag('meta', { content: this.difficulty });
33
+ // Separate unordered lists (tools/materials) and ordered lists (steps)
34
+ const allNodes = body.toArray();
35
+ const tools = [];
36
+ const steps = [];
37
+ for (const node of allNodes) {
38
+ if (Markdoc.Tag.isTag(node)) {
39
+ if (node.name === 'ul') {
40
+ tools.push(...(node.children || []));
41
+ }
42
+ else if (node.name === 'ol') {
43
+ steps.push(...(node.children || []));
44
+ }
45
+ }
46
+ }
47
+ const toolsList = new Tag('ul', {}, tools);
48
+ const stepsList = new Tag('ol', {}, steps);
49
+ const children = [
50
+ estimatedTimeMeta,
51
+ difficultyMeta,
52
+ header.wrap('header').next(),
53
+ ];
54
+ if (tools.length > 0) {
55
+ children.push(toolsList);
56
+ }
57
+ children.push(stepsList);
58
+ return createComponentRenderable(schema.HowTo, {
59
+ tag: 'article',
60
+ property: 'contentSection',
61
+ properties: {
62
+ ...pageSectionProperties(header),
63
+ estimatedTime: estimatedTimeMeta,
64
+ difficulty: difficultyMeta,
65
+ },
66
+ refs: {
67
+ tools: toolsList,
68
+ steps: stepsList,
69
+ },
70
+ children,
71
+ });
72
+ }
73
+ }
74
+ __decorate([
75
+ attribute({ type: String, required: false }),
76
+ __metadata("design:type", String)
77
+ ], HowToModel.prototype, "estimatedTime", void 0);
78
+ __decorate([
79
+ attribute({ type: String, required: false, matches: difficultyType.slice() }),
80
+ __metadata("design:type", String)
81
+ ], HowToModel.prototype, "difficulty", void 0);
82
+ __decorate([
83
+ attribute({ type: Number, required: false }),
84
+ __metadata("design:type", Object)
85
+ ], HowToModel.prototype, "headingLevel", void 0);
86
+ __decorate([
87
+ group({ include: ['heading', 'paragraph', 'image'] }),
88
+ __metadata("design:type", NodeStream)
89
+ ], HowToModel.prototype, "header", void 0);
90
+ __decorate([
91
+ group({ include: ['list', 'tag'] }),
92
+ __metadata("design:type", NodeStream)
93
+ ], HowToModel.prototype, "body", void 0);
94
+ export const howto = createSchema(HowToModel);
95
+ //# sourceMappingURL=howto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"howto.js","sourceRoot":"","sources":["../../src/tags/howto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,yBAAyB,EAAE,YAAY,EAAE,UAAU,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxJ,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAE3D,MAAM,UAAW,SAAQ,KAAK;IAA9B;;QAEC,kBAAa,GAAW,EAAE,CAAC;QAG3B,eAAU,GAAW,EAAE,CAAC;QAGxB,iBAAY,GAAuB,SAAS,CAAC;IAkE9C,CAAC;IA1DA,eAAe,CAAC,KAAa;QAC5B,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO,KAAK,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,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are const recipe: Markdoc.Schema;
3
+ //# sourceMappingURL=recipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe.d.ts","sourceRoot":"","sources":["../../src/tags/recipe.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AA4FvC,eAAO,MAAM,MAAM,gBAA4B,CAAC"}
@@ -0,0 +1,107 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import Markdoc from '@markdoc/markdoc';
11
+ const { Tag } = Markdoc;
12
+ import { attribute, group, Model, createComponentRenderable, createSchema, NodeStream, pageSectionProperties } from '@refrakt-md/runes';
13
+ import { schema } from '../types.js';
14
+ const difficultyType = ['easy', 'medium', 'hard'];
15
+ class RecipeModel extends Model {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.prepTime = '';
19
+ this.cookTime = '';
20
+ this.servings = undefined;
21
+ this.difficulty = 'medium';
22
+ }
23
+ transform() {
24
+ const header = this.header.transform();
25
+ const body = this.body.transform();
26
+ const prepTimeMeta = new Tag('meta', { content: this.prepTime });
27
+ const cookTimeMeta = new Tag('meta', { content: this.cookTime });
28
+ const servingsMeta = new Tag('meta', { content: this.servings != null ? String(this.servings) : '' });
29
+ const difficultyMeta = new Tag('meta', { content: this.difficulty });
30
+ // Separate unordered lists (ingredients), ordered lists (steps), and blockquotes (tips)
31
+ const allNodes = body.toArray();
32
+ const ingredients = [];
33
+ const steps = [];
34
+ const tips = [];
35
+ for (const node of allNodes) {
36
+ if (Markdoc.Tag.isTag(node)) {
37
+ if (node.name === 'ul' && ingredients.length === 0) {
38
+ ingredients.push(...(node.children || []));
39
+ }
40
+ else if (node.name === 'ol' && steps.length === 0) {
41
+ steps.push(...(node.children || []));
42
+ }
43
+ else if (node.name === 'blockquote') {
44
+ tips.push(node);
45
+ }
46
+ }
47
+ }
48
+ const ingredientsList = new Tag('ul', {}, ingredients);
49
+ const stepsList = new Tag('ol', {}, steps);
50
+ const tipsDiv = new Tag('div', {}, tips);
51
+ const children = [
52
+ prepTimeMeta,
53
+ cookTimeMeta,
54
+ servingsMeta,
55
+ difficultyMeta,
56
+ header.wrap('header').next(),
57
+ ingredientsList,
58
+ stepsList,
59
+ ];
60
+ if (tips.length > 0) {
61
+ children.push(tipsDiv);
62
+ }
63
+ return createComponentRenderable(schema.Recipe, {
64
+ tag: 'article',
65
+ property: 'contentSection',
66
+ properties: {
67
+ ...pageSectionProperties(header),
68
+ prepTime: prepTimeMeta,
69
+ cookTime: cookTimeMeta,
70
+ servings: servingsMeta,
71
+ difficulty: difficultyMeta,
72
+ },
73
+ refs: {
74
+ ingredients: ingredientsList,
75
+ steps: stepsList,
76
+ tips: tipsDiv,
77
+ },
78
+ children,
79
+ });
80
+ }
81
+ }
82
+ __decorate([
83
+ attribute({ type: String, required: false }),
84
+ __metadata("design:type", String)
85
+ ], RecipeModel.prototype, "prepTime", void 0);
86
+ __decorate([
87
+ attribute({ type: String, required: false }),
88
+ __metadata("design:type", String)
89
+ ], RecipeModel.prototype, "cookTime", void 0);
90
+ __decorate([
91
+ attribute({ type: Number, required: false }),
92
+ __metadata("design:type", Object)
93
+ ], RecipeModel.prototype, "servings", void 0);
94
+ __decorate([
95
+ attribute({ type: String, required: false, matches: difficultyType.slice() }),
96
+ __metadata("design:type", Object)
97
+ ], RecipeModel.prototype, "difficulty", void 0);
98
+ __decorate([
99
+ group({ include: ['heading', 'paragraph', 'image'] }),
100
+ __metadata("design:type", NodeStream)
101
+ ], RecipeModel.prototype, "header", void 0);
102
+ __decorate([
103
+ group({ include: ['list', 'tag', 'blockquote'] }),
104
+ __metadata("design:type", NodeStream)
105
+ ], RecipeModel.prototype, "body", void 0);
106
+ export const recipe = createSchema(RecipeModel);
107
+ //# sourceMappingURL=recipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe.js","sourceRoot":"","sources":["../../src/tags/recipe.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,yBAAyB,EAAE,YAAY,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACxI,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAE3D,MAAM,WAAY,SAAQ,KAAK;IAA/B;;QAEC,aAAQ,GAAW,EAAE,CAAC;QAGtB,aAAQ,GAAW,EAAE,CAAC;QAGtB,aAAQ,GAAuB,SAAS,CAAC;QAGzC,eAAU,GAAkC,QAAQ,CAAC;IAuEtD,CAAC;IA/DA,SAAS;QACR,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QAEnC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,C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E,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,EAAE,CAAC;;+CACzB;AAGrD;IADC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,CAAC;8BAC9C,UAAU;2CAAC;AAGnB;IADC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,EAAE,CAAC;8BAC5C,UAAU;yCAAC;AAmElB,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { RecipeComponent, RecipeIngredientComponent } from './schema/recipe.js';
2
+ import { HowToComponent } from './schema/howto.js';
3
+ export declare const schema: {
4
+ Recipe: import("@refrakt-md/types").Type<RecipeComponent>;
5
+ RecipeIngredient: import("@refrakt-md/types").Type<RecipeIngredientComponent>;
6
+ HowTo: import("@refrakt-md/types").Type<HowToComponent>;
7
+ };
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,eAAe,EAAoB,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC1G,OAAO,EAAS,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE1D,eAAO,MAAM,MAAM;;;;CAIlB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ import { useSchema } from '@refrakt-md/types';
2
+ import { Recipe, RecipeIngredient } from './schema/recipe.js';
3
+ import { HowTo } from './schema/howto.js';
4
+ export const schema = {
5
+ Recipe: useSchema(Recipe).defineType('Recipe'),
6
+ RecipeIngredient: useSchema(RecipeIngredient).defineType('RecipeIngredient'),
7
+ HowTo: useSchema(HowTo).defineType('HowTo'),
8
+ };
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAmB,gBAAgB,EAA6B,MAAM,oBAAoB,CAAC;AAC1G,OAAO,EAAE,KAAK,EAAkB,MAAM,mBAAmB,CAAC;AAE1D,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,UAAU,CAAkB,QAAQ,CAAC;IAC/D,gBAAgB,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC,UAAU,CAA4B,kBAAkB,CAAC;IACvG,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,UAAU,CAAiB,OAAO,CAAC;CAC5D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@refrakt-md/learning",
3
+ "description": "Learning runes for refrakt.md — how-to guides and recipes",
4
+ "version": "0.7.0",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/refrakt-md/refrakt.git",
10
+ "directory": "runes/learning"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "main": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc"
22
+ },
23
+ "dependencies": {
24
+ "@refrakt-md/types": "0.7.0",
25
+ "@refrakt-md/transform": "0.7.0",
26
+ "@refrakt-md/runes": "0.7.0",
27
+ "@markdoc/markdoc": "0.4.0",
28
+ "reflect-metadata": "^0.2.0"
29
+ }
30
+ }