@markdownspace/site-generator 1.0.0 → 1.0.1

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.
package/dist/index.js CHANGED
@@ -70102,6 +70102,15 @@ var jsYaml = {
70102
70102
  var js_yaml_default = jsYaml;
70103
70103
 
70104
70104
  // src/ParseFrontmatter.ts
70105
+ function extractFrontmatter(markdown2) {
70106
+ const frontmatterRegex = /^\n*---\n([\s\S]*?)\n---/;
70107
+ const match = markdown2.match(frontmatterRegex);
70108
+ if (!match) {
70109
+ return {};
70110
+ }
70111
+ const [, frontmatter] = match;
70112
+ return frontmatter;
70113
+ }
70105
70114
  function parseFrontmatter(markdown2) {
70106
70115
  const frontmatterRegex = /^\n*---\n([\s\S]*?)\n---/;
70107
70116
  const match = markdown2.match(frontmatterRegex);
@@ -70113,6 +70122,31 @@ function parseFrontmatter(markdown2) {
70113
70122
  const data2 = js_yaml_default.load(frontmatter);
70114
70123
  return { data: data2, content: content3 };
70115
70124
  }
70125
+ function createFrontmatter(data2) {
70126
+ const yamlString = js_yaml_default.dump(data2, {
70127
+ indent: 2,
70128
+ // Sets the indentation level of nested structures
70129
+ noArrayIndent: false,
70130
+ // Controls whether arrays are indented
70131
+ lineWidth: -1
70132
+ // Prevents wrapping of long lines
70133
+ });
70134
+ const indentedYamlString = yamlString.split("\n").map((line) => " " + line).join("\n");
70135
+ return indentedYamlString;
70136
+ }
70137
+ function updateMDFrontmatter(markdown2, newFrontmatter) {
70138
+ const frontmatterRegex = /^\n*---\n([\s\S]*?)\n---/;
70139
+ if (frontmatterRegex.test(markdown2)) {
70140
+ return markdown2.replace(frontmatterRegex, `---
70141
+ ${newFrontmatter}
70142
+ ---`);
70143
+ } else {
70144
+ return `---
70145
+ ${newFrontmatter}
70146
+ ---
70147
+ ${markdown2}`;
70148
+ }
70149
+ }
70116
70150
 
70117
70151
  // src/GenerateSiteData.ts
70118
70152
  init_dirname();
@@ -71163,8 +71197,11 @@ var SiteGenerator_default = {
71163
71197
  export {
71164
71198
  AvailableBootstrapThemes_default as AvailableBootstrapThemes,
71165
71199
  AvailableBulmaThemes_default as AvailableBulmaThemes,
71200
+ createFrontmatter,
71166
71201
  SiteGenerator_default as default,
71167
- parseFrontmatter
71202
+ extractFrontmatter,
71203
+ parseFrontmatter,
71204
+ updateMDFrontmatter
71168
71205
  };
71169
71206
  /*! Bundled license information:
71170
71207