Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More build suggestions #15

Merged
merged 7 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/defaults.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/** @type {import('@cloudcannon/configuration-types').MarkdownAttributeElementOptions} */
export const commonmarkAttributeElementOptions = {
inline: 'none',
block: 'space right',
img: 'right',
ul: 'below',
ol: 'below',
li: 'space right',
table: 'newline below',
blockquote: 'below',
}
inline: 'none',
block: 'space right',
img: 'right',
ul: 'below',
ol: 'below',
li: 'space right',
table: 'newline below',
blockquote: 'below',
};

/** @type {import('@cloudcannon/configuration-types').MarkdownAttributeElementOptions} */
export const kramdownAttributeElementOptions = {
inline: 'right',
block: 'below',
tr: 'none',
td: 'none',
li: 'right-of-prefix',
}
inline: 'right',
block: 'below',
tr: 'none',
td: 'none',
li: 'right-of-prefix',
};
29 changes: 29 additions & 0 deletions src/ssgs/astro.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Ssg from './ssg.js';

export default class Astro extends Ssg {
constructor() {
super('astro');
}

/**
* Generates a list of build suggestions.
*
* @param filePaths {string[]} List of input file paths.
* @param options {{ config?: Record<string, any>; source?: string; readFile?: (path: string) => Promise<string | undefined>; }}
* @returns {Promise<import('../types').BuildCommands>}
*/
async generateBuildCommands(filePaths, options) {
const commands = await super.generateBuildCommands(filePaths, options);

commands.build.push({
value: 'npx astro build',
attribution: 'default for Astro sites',
});
commands.output.push({
value: 'dist',
attribution: 'default for Astro sites',
});

return commands;
}
}
40 changes: 40 additions & 0 deletions src/ssgs/bridgetown.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { joinPaths } from '../utility.js';
import Ssg from './ssg.js';

export default class Bridgetown extends Ssg {
Expand All @@ -12,4 +13,43 @@ export default class Bridgetown extends Ssg {
templateExtensions() {
return super.templateExtensions().concat(['.liquid']);
}

/**
* Generates a list of build suggestions.
*
* @param filePaths {string[]} List of input file paths.
* @param options {{ config?: Record<string, any>; source?: string; readFile?: (path: string) => Promise<string | undefined>; }}
* @returns {Promise<import('../types').BuildCommands>}
*/
async generateBuildCommands(filePaths, options) {
const commands = await super.generateBuildCommands(filePaths, options);

if (filePaths.includes(joinPaths([options.source, 'Gemfile']))) {
commands.install.unshift({
value: 'bundle install',
attribution: 'because of your Gemfile',
});

if (options.source) {
commands.environment['BUNDLE_GEMFILE'] = {
value: joinPaths([options.source, 'Gemfile']),
attribution: 'because of your Gemfile',
};
}
}

if (filePaths.includes('bin/bridgetown')) {
commands.build.unshift({
value: 'bin/bridgetown deploy',
attribution: 'most common for Bridgetown sites',
});
}

commands.output.unshift({
value: 'output',
attribution: 'most common for Bridgetown sites',
});

return commands;
}
}
29 changes: 29 additions & 0 deletions src/ssgs/gatsby.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Ssg from './ssg.js';

export default class Gatsby extends Ssg {
constructor() {
super('gatsby');
}

/**
* Generates a list of build suggestions.
*
* @param filePaths {string[]} List of input file paths.
* @param options {{ config?: Record<string, any>; source?: string; readFile?: (path: string) => Promise<string | undefined>; }}
* @returns {Promise<import('../types').BuildCommands>}
*/
async generateBuildCommands(filePaths, options) {
const commands = await super.generateBuildCommands(filePaths, options);

commands.build.unshift({
value: 'npx gatsby build',
attribution: 'default for Gatsby sites',
});
commands.output.unshift({
value: 'public',
attribution: 'default for Gatsby sites',
});

return commands;
}
}
12 changes: 9 additions & 3 deletions src/ssgs/hugo.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,15 @@ export default class Hugo extends Ssg {
headingTags.forEach((tag) => {
attribute_elements[tag] = !!parser?.attribute?.title ? 'space right' : 'none';
});

/** @type {(keyof HTMLElementTagNameMap)[]} */
const otherTags = ['blockquote', 'hr', 'ol', 'ul', 'p', 'table'];
otherTags.forEach((tag) => {
attribute_elements[tag] = !!parser?.attribute?.block ? 'below' : 'none';
});

const imgAttrsAllowed = !!parser?.attribute?.block && parser?.wrapStandAloneImageWithinParagraph === false;
const imgAttrsAllowed =
!!parser?.attribute?.block && parser?.wrapStandAloneImageWithinParagraph === false;
attribute_elements.img = imgAttrsAllowed ? 'below' : 'none';

options.attribute_elements = attribute_elements;
Expand All @@ -225,8 +226,13 @@ export default class Hugo extends Ssg {
async generateBuildCommands(filePaths, options) {
const commands = await super.generateBuildCommands(filePaths, options);

commands.install.unshift({
value: 'export NODE_PATH=`pwd`/node_modules:$NODE_PATH',
attribution: 'workaround for a Hugo issue', // https://github.com/gohugoio/hugo/issues/9800
});

commands.build.unshift({
value: 'hugo',
value: 'hugo -b /',
attribution: 'most common for Hugo sites',
});
commands.output.unshift({
Expand Down
8 changes: 7 additions & 1 deletion src/ssgs/jekyll.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ export default class Jekyll extends Ssg {

options.attributes = true;
options.attribute_elements = kramdownAttributeElementOptions;

} else if (config) {
const commonmarkConfig = config?.['commonmark'] || {};

Expand Down Expand Up @@ -346,6 +345,13 @@ export default class Jekyll extends Ssg {
value: 'bundle exec jekyll build',
attribution: 'because of your Gemfile',
});

if (options.source) {
commands.environment['BUNDLE_GEMFILE'] = {
value: joinPaths([options.source, 'Gemfile']),
attribution: 'because of your Gemfile',
};
}
} else {
commands.build.unshift({
value: 'jekyll build',
Expand Down
29 changes: 29 additions & 0 deletions src/ssgs/lume.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Ssg from './ssg.js';

export default class Lume extends Ssg {
constructor() {
super('lume');
}

/**
* Generates a list of build suggestions.
*
* @param filePaths {string[]} List of input file paths.
* @param options {{ config?: Record<string, any>; source?: string; readFile?: (path: string) => Promise<string | undefined>; }}
* @returns {Promise<import('../types.js').BuildCommands>}
*/
async generateBuildCommands(filePaths, options) {
const commands = await super.generateBuildCommands(filePaths, options);

commands.build.push({
value: 'deno task lume',
attribution: 'default for Lume sites',
});
commands.output.unshift({
value: '_site',
attribution: 'most common for Lume sites',
});

return commands;
}
}
29 changes: 29 additions & 0 deletions src/ssgs/mkdocs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Ssg from './ssg.js';

export default class MkDocs extends Ssg {
constructor() {
super('mkdocs');
}

/**
* Generates a list of build suggestions.
*
* @param filePaths {string[]} List of input file paths.
* @param options {{ config?: Record<string, any>; source?: string; readFile?: (path: string) => Promise<string | undefined>; }}
* @returns {Promise<import('../types').BuildCommands>}
*/
async generateBuildCommands(filePaths, options) {
const commands = await super.generateBuildCommands(filePaths, options);

commands.build.push({
value: 'npx mkdocs build',
attribution: 'default for MkDocs sites',
});
commands.output.unshift({
value: 'site',
attribution: 'most common for MkDocs sites',
});

return commands;
}
}
22 changes: 22 additions & 0 deletions src/ssgs/next-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,26 @@ export default class NextJs extends Ssg {
'public/', // static assets
]);
}

/**
* Generates a list of build suggestions.
*
* @param filePaths {string[]} List of input file paths.
* @param options {{ config?: Record<string, any>; source?: string; readFile?: (path: string) => Promise<string | undefined>; }}
* @returns {Promise<import('../types').BuildCommands>}
*/
async generateBuildCommands(filePaths, options) {
const commands = await super.generateBuildCommands(filePaths, options);

commands.build.unshift({
value: 'npx next build && npx next export',
attribution: 'most common for Next.js sites',
});
commands.output.unshift({
value: 'out',
attribution: 'default for Next.js sites',
});

return commands;
}
}
29 changes: 29 additions & 0 deletions src/ssgs/nuxt-js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Ssg from './ssg.js';

export default class NuxtJs extends Ssg {
constructor() {
super('nuxtjs');
}

/**
* Generates a list of build suggestions.
*
* @param filePaths {string[]} List of input file paths.
* @param options {{ config?: Record<string, any>; source?: string; readFile?: (path: string) => Promise<string | undefined>; }}
* @returns {Promise<import('../types').BuildCommands>}
*/
async generateBuildCommands(filePaths, options) {
const commands = await super.generateBuildCommands(filePaths, options);

commands.build.push({
value: 'npx nuxt generate',
attribution: 'default for Nuxt sites',
});
commands.output.unshift({
value: 'dist',
attribution: 'most common for Nuxt sites',
});

return commands;
}
}
Loading
Loading