MCPcopy
hub / github.com/clauderic/dnd-kit / get

Function get

apps/docs/scripts/generate-og-image.mjs:71–97  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

69
70 const fm = match[1];
71 const get = (key) => {
72 // Handle single-line values: key: 'value' or key: value
73 const singleLine = fm.match(new RegExp(`^${key}:\\s*['"](.*)['"]\\s*$`, 'm'));
74 if (singleLine) return singleLine[1].replace(/\\n/g, '\n');
75
76 const unquoted = fm.match(new RegExp(`^${key}:\\s*(.+)$`, 'm'));
77 if (unquoted) {
78 const val = unquoted[1].trim();
79 // Handle YAML multiline indicators (>-, |-, >, |)
80 if (/^[>|]-?\s*$/.test(val)) {
81 const keyIndex = fm.indexOf(unquoted[0]);
82 const afterKey = fm.slice(keyIndex + unquoted[0].length);
83 const lines = afterKey.split('\n');
84 const continued = [];
85 for (const line of lines) {
86 if (line.match(/^\s+\S/)) {
87 continued.push(line.trim());
88 } else if (continued.length > 0) {
89 break;
90 }
91 }
92 return continued.join(' ').replace(/\\n/g, '\n');
93 }
94 return val.replace(/\\n/g, '\n');
95 }
96 return undefined;
97 };
98
99 return {
100 title: get('title'),

Callers 1

parseFrontmatterFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected