Commit 6e68c32a authored by Ken Hawkins's avatar Ken Hawkins
Browse files

Support for marked 4 and babel/core

parent 4cc40dd3
......@@ -27,7 +27,8 @@
"@11ty/eleventy": "1.0.0-beta.8",
"@visual-framework/vf-config": "1.0.1-alpha.0",
"@visual-framework/vf-core": "^2.2.33",
"@visual-framework/vf-extensions": "^1.0.1",
"@visual-framework/vf-core": "^2.2.36",
"@visual-framework/vf-extensions": "^2.0.0-alpha.1",
"html-minifier": "4.0.0",
"node-html-parser": "5.1.0",
"require-dir": "1.2.0",
......
### 2.2.36
* Use `renderMarkdown.parse` for marked 4+ support.
### 2.2.35
* Update @visual-framework/vf-frctl-extensions to ^2.0.0 for marked 4+ support.
### 2.2.34
* Update marked to 4.0.4
......
const renderMarkdown = require("marked");
module.exports = {
// mode: 'build' or 'server'
initialize: function(mode, callback) {
/* Create a new Fractal instance and export it for use elsewhere if required */
const fractal = module.exports = require('@frctl/fractal').create();
const fractal = module.exports = require("@frctl/fractal").create();
const logger = fractal.cli.console;
var vfName = global.vfName || 'Visual Framework component library';
var vfName = global.vfName || "Visual Framework component library";
const projectTitle = vfName;
const path = require('path');
const path = require("path");
/* Set the title of the project */
fractal.set('project.title', projectTitle);
fractal.set("project.title", projectTitle);
/* Tell Fractal where the components will live */
var vfComponentPath = global.vfComponentPath || __dirname + '/components';
var vfComponentPath = global.vfComponentPath || __dirname + "/components";
// Possible needed fix to resolve path
// vfComponentPath = path.resolve('.',vfComponentPath);
fractal.components.set('path', vfComponentPath);
fractal.components.set("path", vfComponentPath);
/* Tell Fractal where the documentation pages will live */
var vfDocsPath = global.vfDocsPath || __dirname + '/docs';
fractal.docs.set('path', vfDocsPath);
var vfDocsPath = global.vfDocsPath || __dirname + "/docs";
fractal.docs.set("path", vfDocsPath);
const nunj = require('@frctl/nunjucks')({
const nunj = require("@frctl/nunjucks")({
env: {
lstripBlocks: true,
trimBlocks: true,
......@@ -35,8 +37,7 @@ module.exports = {
filters: {
// {{ "## Parse me" | marked }}
marked: function(string) {
const renderMarkdown = require('marked');
return renderMarkdown(string);
return renderMarkdown.parse(string);
},
// A filter and non-async version of frctl's context extension from
// https://github.com/frctl/nunjucks/blob/develop/src/extensions/context.js
......@@ -70,46 +71,46 @@ module.exports = {
// // global-name: global-val
// },
extensions: {
codeblock: require('@visual-framework/vf-frctl-extensions/codeblock.js')(fractal),
spaceless: require('@visual-framework/vf-frctl-extensions/spaceless.js')(fractal),
markdown: require('@visual-framework/vf-frctl-extensions/markdown.js')(fractal)
codeblock: require("@visual-framework/vf-frctl-extensions/codeblock.js")(fractal),
spaceless: require("@visual-framework/vf-frctl-extensions/spaceless.js")(fractal),
markdown: require("@visual-framework/vf-frctl-extensions/markdown.js")(fractal)
}
});
fractal.components.set('ext', '.njk'); // look for files with a .nunj file extension
fractal.components.set("ext", ".njk"); // look for files with a .nunj file extension
fractal.components.engine(nunj); /* set as the default template engine for components */
fractal.docs.set('ext', '.njk'); // look for files with a .njk file extension
fractal.docs.set("ext", ".njk"); // look for files with a .njk file extension
fractal.docs.engine(nunj); /* you can also use the same instance for documentation, if you like! */
/* configure components */
fractal.components.set('default.status', 'alpha');
fractal.components.set('default.preview', `@preview`);
fractal.components.set("default.status", "alpha");
fractal.components.set("default.preview", "@preview");
/* build destination */
var vfBuilderPath = global.vfBuilderPath || __dirname + '/build';
fractal.web.set('builder.dest', vfBuilderPath);
fractal.set('components.resources.assets.match', ['**/*.njk', '**/*.config.yml', '**/*.scss', '**/CHANGELOG.md', '**/*.js','**/*.css', '!**/*.precompiled.js', '!**/package.variables.scss', '!**/index.scss'])
var vfBuilderPath = global.vfBuilderPath || __dirname + "/build";
fractal.web.set("builder.dest", vfBuilderPath);
fractal.set("components.resources.assets.match", ["**/*.njk", "**/*.config.yml", "**/*.scss", "**/CHANGELOG.md", "**/*.js","**/*.css", "!**/*.precompiled.js", "!**/package.variables.scss", "!**/index.scss"]);
/* configure web */
var vfStaticPath = global.vfStaticPath || __dirname + '/temp/build-files';
fractal.web.set('static.path', vfStaticPath);
fractal.web.set('server.sync', true);
var vfStaticPath = global.vfStaticPath || __dirname + "/temp/build-files";
fractal.web.set("static.path", vfStaticPath);
fractal.web.set("server.sync", true);
var vfOpenBrowser = typeof global.vfOpenBrowser === "undefined" ? true : global.vfOpenBrowser;
fractal.web.set('server.syncOptions', {
fractal.web.set("server.syncOptions", {
watchOptions: {
// @todo: this should use vfComponentPath
ignored: path.join(__dirname, '../../components/**/*.scss'),
ignored: path.join(__dirname, "../../components/**/*.scss"),
},
open: vfOpenBrowser,
browser: 'default',
browser: "default",
sync: true
});
var vfThemePath = global.vfThemePath || '@frctl/mandelbrot';
var vfThemePath = global.vfThemePath || "@frctl/mandelbrot";
const vfTheme = require(vfThemePath);
const vfThemeConfig = vfTheme({}, fractal);
fractal.components.set('statuses', {
fractal.components.set("statuses", {
/* status definitions here */
alpha: {
label: "alpha",
......@@ -136,8 +137,8 @@ module.exports = {
fractal.web.theme(vfThemeConfig);
if (mode == 'server') {
fractal.set('project.environment.local', 'true');
if (mode == "server") {
fractal.set("project.environment.local", "true");
const fractalServer = fractal.web.server({
sync: true
});
......@@ -150,27 +151,27 @@ module.exports = {
}
// If you want to build static html files
if (mode == 'build') {
fractal.set('project.environment.production', 'true');
if (mode == "build") {
fractal.set("project.environment.production", "true");
const builder = fractal.web.builder();
builder.on('progress', (completed, total) =>
logger.update(`Exported ${completed} of ${total} items`, 'info')
builder.on("progress", (completed, total) =>
logger.update(`Exported ${completed} of ${total} items`, "info")
);
builder.on('error', err => logger.error(err.message));
builder.on("error", err => logger.error(err.message));
return builder.build().then(() => {
logger.success('Fractal build completed!');
logger.success("Fractal build completed!");
callback(fractal);
});
}
// To build the fractal object in memory
if (mode == 'dataobject') {
fractal.set('project.environment.production', 'true');
if (mode == "dataobject") {
fractal.set("project.environment.production", "true");
const server = fractal.web.server();
server.start().then(function(){
console.log('The Fractal component data has been generated.');
console.log("The Fractal component data has been generated.");
callback(fractal);
server.stop();
fractal.unwatch(); // exit fractal
......@@ -178,4 +179,4 @@ module.exports = {
}
}
}
};
{
"name": "@visual-framework/vf-core",
"version": "2.2.34",
"version": "2.2.36",
"description": "Common dependencies for the Visual Framework 2.0.",
"engines": {
"node": ">=12.0.0"
......@@ -31,7 +31,7 @@
"dependencies": {
"@visual-framework/vf-component-generator": "^1.1.5",
"@visual-framework/vf-component-initialization": "^1.1.7",
"@visual-framework/vf-frctl-extensions": "^1.0.1",
"@visual-framework/vf-frctl-extensions": "^2.0.0",
"@visual-framework/vf-sass-compilation": "^1.1.16",
"chalk": "^4.0.0",
"del": "^6.0.0",
......
### 2.0.0
* Invoke marked with `renderMarkdown.parse` for compatibility with version 4.
### 1.0.1
* Updates highlightjs syntax of codeblock tag
......
......@@ -58,14 +58,14 @@ module.exports = function(fractal){
var body = body();
var spacesRegex = /^[\s]+/;
var tabStart = tabStart(); // The column postion of the {% markdown %} tag.
var tabStart = tabStart(); // The column position of the {% markdown %} tag.
if (tabStart > 0) { // If the {% markdown %} tag is tabbed in, normalize the content to the same depth.
body = body.split(/\r?\n/); // Split into lines.
body = body.map(function(line) {
var startSpaces = line.match(spacesRegex);
if (startSpaces && startSpaces[0].length >= tabStart) { // If the content is not at the same or greater tab depth, do nothing..
return line.slice(tabStart); // Subtract the column postion from the start of the string.
return line.slice(tabStart); // Subtract the column position from the start of the string.
} else if (startSpaces) {
return line.slice(startSpaces[0].length);
} else {
......@@ -75,8 +75,8 @@ module.exports = function(fractal){
body = body.join("\n"); // Rejoin into one string.
}
return new nunjucks.runtime.SafeString(renderMarkdown(body));
};
return new nunjucks.runtime.SafeString(renderMarkdown.parse(body));
}
......
{
"name": "@visual-framework/vf-frctl-extensions",
"version": "1.0.1",
"version": "2.0.0",
"description": "Reusable componentised code, modules and config for Visual Framework based projects using Fractal.",
"main": "index.js",
"scripts": {
......
### 1.1.18
* Add now required @babel/core dependency.
### 1.1.17
* Update @babel/preset-env to 7.16.4
......
{
"name": "@visual-framework/vf-sass-compilation",
"version": "1.1.17",
"version": "1.1.18",
"description": "Build the Sass for Visual Framework 2.0 projects.",
"main": "index.js",
"scripts": {
......@@ -12,6 +12,7 @@
},
"private": false,
"dependencies": {
"@babel/core": "^7.16.0",
"@babel/preset-env": "7.16.4",
"eslint": "^8.0.0",
"gulp-autoprefixer": "^8.0.0",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment