fleet/website/api/controllers/admin/view-email-templates.js
Eric 2d0f33f369
Website: Add script for creating HTML email partials from Markdown articles (#7574)
* add to-html-email

* email-preview

* add build-html-email script, update .gitignore

* email preview and email-templates pages, update routes, importer and policies

* add newsletter email layout, build-html-email script, to-html-email updates

* Update .gitignore

* add newsletter emails section to growth handbook

* update scripts

* update fonts in emails

* Update README.md

* Update build-html-email.js

* update comments, add page scripts to layouts

* revert change to build-static-content

* update script

* update email layout and helper

* update handbook entry

* update template data and helper

* update email layout

* update fake data and unsubscribe link

* move added handbook section to the marketing handbook

* rename script

* update colors in unused email template

* update capitalization in helper

* view-email-preview » view-email-template-preview

* Hide emails generated from markdown if they don't exist

* update preview page

* update markdown email directory, create sample article email

* lint fixes, add target="_blank" to links in emails

* update page layouts & styles

* update sample newsletter email, code font, newsletter layout

* Update README.md

* Update view-email-template-preview.js

Co-authored-by: Tim Kern <[email protected]>
Co-authored-by: Mike Thomas <[email protected]>
Co-authored-by: Mike McNeil <[email protected]>
2022-12-05 16:30:24 -06:00

60 lines
1.3 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View email templates',
description: 'Display "Email templates" page.',
exits: {
success: {
viewTemplatePath: 'pages/admin/email-templates'
}
},
fn: async function () {
var path = require('path');
// Sniff for top level email templates
let templatePaths = await sails.helpers.fs.ls.with({
dir: path.join(sails.config.paths.views, 'emails/'),
depth: 1,
includeDirs: false,
includeSymlinks: false,
});
let markdownEmailPaths = await sails.helpers.fs.ls.with({
dir: path.join(sails.config.paths.views, 'emails/newsletter'),
depth: 99,
includeDirs: false,
includeSymlinks: false,
});
markdownEmailPaths = markdownEmailPaths.map((templatePath)=>{
let relativePath = path.relative(path.join(sails.config.paths.views, 'emails/'), templatePath);
let extension = path.extname(relativePath);
return _.trimRight(relativePath, extension);
});
templatePaths = templatePaths.map((templatePath)=>{
let relativePath = path.relative(path.join(sails.config.paths.views, 'emails/'), templatePath);
let extension = path.extname(relativePath);
return _.trimRight(relativePath, extension);
});
// Respond with view.
return {
templatePaths,
markdownEmailPaths
};
}
};