+ `);
+ }
+
+ mergedLayoutContents = appLayoutContents.replace(/<\/page-outlet>/, '');
+ } else {
+ const appTitle = appRoot ? appRoot.querySelector('head title') : null;
+ const appBody = appRoot.querySelector('body') ? appRoot.querySelector('body').innerHTML : '';
+ const pageBody = pageRoot && pageRoot.querySelector('body') ? pageRoot.querySelector('body').innerHTML : '';
+ const pageTitle = pageRoot && pageRoot.querySelector('head title');
+ const hasInterpolatedFrontmatter = pageTitle && pageTitle.rawText.indexOf('${globalThis.page.title}') >= 0
+ || appTitle && appTitle.rawText.indexOf('${globalThis.page.title}') >= 0;
+
+ const title = hasInterpolatedFrontmatter // favor frontmatter interpolation first
+ ? pageTitle && pageTitle.rawText
+ ? pageTitle.rawText
+ : appTitle.rawText
+ : frontmatterTitle // otherwise, work in order of specificity from page -> page layout -> app layout
+ ? frontmatterTitle
+ : pageTitle && pageTitle.rawText
+ ? pageTitle.rawText
+ : appTitle && appTitle.rawText
+ ? appTitle.rawText
+ : 'My App';
+
+ const mergedHtml = pageRoot && pageRoot.querySelector('html').rawAttrs !== ''
+ ? ``
+ : appRoot.querySelector('html').rawAttrs !== ''
+ ? ``
+ : '';
+
+ const mergedMeta = [
+ ...appRoot.querySelectorAll('head meta'),
+ ...[...(pageRoot && pageRoot.querySelectorAll('head meta')) || []]
+ ].join('\n');
+
+ const mergedLinks = [
+ ...appRoot.querySelectorAll('head link'),
+ ...[...(pageRoot && pageRoot.querySelectorAll('head link')) || []]
+ ].join('\n');
+
+ const mergedStyles = [
+ ...appRoot.querySelectorAll('head style'),
+ ...[...(pageRoot && pageRoot.querySelectorAll('head style')) || []],
+ ...customImports.filter(resource => resource.split('.').pop() === 'css')
+ .map(resource => ``)
+ ].join('\n');
+
+ const mergedScripts = [
+ ...appRoot.querySelectorAll('head script'),
+ ...[...(pageRoot && pageRoot.querySelectorAll('head script')) || []],
+ ...customImports.filter(resource => resource.split('.').pop() === 'js')
+ .map(resource => ``)
+ ].join('\n');
+
+ const finalBody = pageLayoutContents
+ ? appBody.replace(/<\/page-outlet>/, pageBody)
+ : appBody;
+
+ mergedLayoutContents = `
+ ${mergedHtml}
+
+ ${title}
+ ${mergedMeta}
+ ${mergedLinks}
+ ${mergedStyles}
+ ${mergedScripts}
+
+
+ ${finalBody}
+
+
+ `;
+ }
+
+ return mergedLayoutContents;
+}
+
+async function getUserScripts (contents, compilation) {
+ const { config } = compilation;
+
+ contents = contents.replace('', `
+
+
+ `);
+
+ return contents;
+}
+
+export {
+ getAppLayout,
+ getPageLayout,
+ getUserScripts
+};
\ No newline at end of file
diff --git a/packages/cli/src/lib/resource-utils.js b/packages/cli/src/lib/resource-utils.js
index a08cd9c57..6a78e4647 100644
--- a/packages/cli/src/lib/resource-utils.js
+++ b/packages/cli/src/lib/resource-utils.js
@@ -86,7 +86,7 @@ async function checkResourceExists(url) {
// turn relative paths into relatively absolute based on a known root directory
// * deep link route - /blog/releases/some-post
-// * and a nested path in the template - ../../styles/theme.css
+// * and a nested path in the layout - ../../styles/theme.css
// so will get resolved as `${rootUrl}/styles/theme.css`
async function resolveForRelativeUrl(url, rootUrl) {
const search = url.search || '';
@@ -111,11 +111,6 @@ async function resolveForRelativeUrl(url, rootUrl) {
return reducedUrl;
}
-// does this make more sense in bundle lifecycle?
-// https://github.com/ProjectEvergreen/greenwood/issues/970
-// or could this be done sooner (like in appTemplate building in html resource plugin)?
-// Or do we need to ensure userland code / plugins have gone first
-// before we can curate the final list of `)
- ].join('\n');
-
- const finalBody = pageTemplateContents
- ? appBody.replace(/<\/page-outlet>/, pageBody)
- : appBody;
-
- mergedTemplateContents = `
- ${mergedHtml}
-
- ${title}
- ${mergedMeta}
- ${mergedLinks}
- ${mergedStyles}
- ${mergedScripts}
-
-
- ${finalBody}
-
-
- `;
- }
-
- return mergedTemplateContents;
-}
-
-async function getUserScripts (contents, compilation) {
- const { config } = compilation;
-
- contents = contents.replace('', `
-
-
- `);
-
- return contents;
-}
-
-export {
- getAppTemplate,
- getPageTemplate,
- getUserScripts
-};
\ No newline at end of file
diff --git a/packages/cli/src/lifecycles/bundle.js b/packages/cli/src/lifecycles/bundle.js
index 352fe485a..33319cfa2 100644
--- a/packages/cli/src/lifecycles/bundle.js
+++ b/packages/cli/src/lifecycles/bundle.js
@@ -1,9 +1,9 @@
/* eslint-disable max-depth, max-len */
import fs from 'fs/promises';
import { getRollupConfigForApis, getRollupConfigForScriptResources, getRollupConfigForSsr } from '../config/rollup.config.js';
-import { getAppTemplate, getPageTemplate, getUserScripts } from '../lib/templating-utils.js';
+import { getAppLayout, getPageLayout, getUserScripts } from '../lib/layout-utils.js';
import { hashString } from '../lib/hashing-utils.js';
-import { checkResourceExists, mergeResponse, normalizePathnameForWindows } from '../lib/resource-utils.js';
+import { checkResourceExists, mergeResponse, normalizePathnameForWindows, trackResourcesForRoute } from '../lib/resource-utils.js';
import path from 'path';
import { rollup } from 'rollup';
@@ -217,84 +217,96 @@ async function bundleApiRoutes(compilation) {
}
}
-async function bundleSsrPages(compilation) {
- // https://rollupjs.org/guide/en/#differences-to-the-javascript-api
- // TODO context plugins for SSR ?
- // const contextPlugins = compilation.config.plugins.filter((plugin) => {
- // return plugin.type === 'context';
- // }).map((plugin) => {
- // return plugin.provider(compilation);
- // });
- const hasSSRPages = compilation.graph.filter(page => page.isSSR).length > 0;
+async function bundleSsrPages(compilation, optimizePlugins) {
+ const { context, config } = compilation;
+ const ssrPages = compilation.graph.filter(page => page.isSSR && !page.prerender);
+ const ssrPrerenderPagesRouteMapper = {};
const input = [];
- if (!compilation.config.prerender && hasSSRPages) {
- const htmlOptimizer = compilation.config.plugins.find(plugin => plugin.name === 'plugin-standard-html').provider(compilation);
- const { executeModuleUrl } = compilation.config.plugins.find(plugin => plugin.type === 'renderer').provider();
+ if (!config.prerender && ssrPages.length > 0) {
+ const { executeModuleUrl } = config.plugins.find(plugin => plugin.type === 'renderer').provider();
const { executeRouteModule } = await import(executeModuleUrl);
- const { pagesDir, scratchDir } = compilation.context;
-
- for (const page of compilation.graph) {
- if (page.isSSR && !page.prerender) {
- const { filename, imports, route, template, title, relativeWorkspacePagePath } = page;
- const entryFileUrl = new URL(`.${relativeWorkspacePagePath}`, scratchDir);
- const moduleUrl = new URL(`.${relativeWorkspacePagePath}`, pagesDir);
- const outputPathRootUrl = new URL(`file://${path.dirname(entryFileUrl.pathname)}`);
- const request = new Request(moduleUrl); // TODO not really sure how to best no-op this?
- // TODO getTemplate has to be static (for now?)
- // https://github.com/ProjectEvergreen/greenwood/issues/955
- const data = await executeRouteModule({ moduleUrl, compilation, page, prerender: false, htmlContents: null, scripts: [], request });
- const pagesPathDiff = compilation.context.pagesDir.pathname.replace(compilation.context.projectDirectory.pathname, '');
- const relativeDepth = relativeWorkspacePagePath.replace(`/${filename}`, '') === ''
- ? '../'
- : '../'.repeat(relativeWorkspacePagePath.replace(`/${filename}`, '').split('/').length);
- let staticHtml = '';
-
- staticHtml = data.template ? data.template : await getPageTemplate(staticHtml, compilation.context, template, []);
- staticHtml = await getAppTemplate(staticHtml, compilation.context, imports, [], false, title);
- staticHtml = await getUserScripts(staticHtml, compilation);
- staticHtml = await (await interceptPage(new URL(`http://localhost:8080${route}`), new Request(new URL(`http://localhost:8080${route}`)), getPluginInstances(compilation), staticHtml)).text();
- staticHtml = await (await htmlOptimizer.optimize(new URL(`http://localhost:8080${route}`), new Response(staticHtml))).text();
- staticHtml = staticHtml.replace(/[`\\$]/g, '\\$&'); // https://stackoverflow.com/a/75688937/417806
-
- if (!await checkResourceExists(outputPathRootUrl)) {
- await fs.mkdir(outputPathRootUrl, {
- recursive: true
- });
- }
+ const { pagesDir, scratchDir } = context;
+
+ // one pass to generate initial static HTML and to track all combined static resources across layouts
+ // and before we optimize so that all bundled assets can tracked up front
+ // would be nice to see if this can be done in a single pass though...
+ for (const page of ssrPages) {
+ const { imports, route, layout, title, relativeWorkspacePagePath } = page;
+ const moduleUrl = new URL(`.${relativeWorkspacePagePath}`, pagesDir);
+ const request = new Request(moduleUrl);
+ // TODO getLayout has to be static (for now?)
+ // https://github.com/ProjectEvergreen/greenwood/issues/955
+ const data = await executeRouteModule({ moduleUrl, compilation, page, prerender: false, htmlContents: null, scripts: [], request });
+ let staticHtml = '';
+
+ staticHtml = data.layout ? data.layout : await getPageLayout(staticHtml, compilation, layout);
+ staticHtml = await getAppLayout(staticHtml, compilation, imports, title);
+ staticHtml = await getUserScripts(staticHtml, compilation);
+ staticHtml = await (await interceptPage(new URL(`http://localhost:8080${route}`), new Request(new URL(`http://localhost:8080${route}`)), getPluginInstances(compilation), staticHtml)).text();
+
+ await trackResourcesForRoute(staticHtml, compilation, route);
+
+ ssrPrerenderPagesRouteMapper[route] = staticHtml;
+ }
- // better way to write out this inline code?
- // using a URL here produces a bundled chunk, but at leasts its bundled
- await fs.writeFile(entryFileUrl, `
- import { executeRouteModule } from '${normalizePathnameForWindows(executeModuleUrl)}';
+ // technically this happens in the start of bundleCompilation once
+ // so might be nice to detect those static assets to see if they have be "de-duped" from bundling here
+ await bundleScriptResources(compilation);
+ await bundleStyleResources(compilation, optimizePlugins);
+
+ // second pass to link all bundled assets to their resources before optimizing and generating SSR bundles
+ for (const page of ssrPages) {
+ const { filename, route, relativeWorkspacePagePath } = page;
+ const entryFileUrl = new URL(`.${relativeWorkspacePagePath}`, scratchDir);
+ const outputPathRootUrl = new URL(`file://${path.dirname(entryFileUrl.pathname)}`);
+ const htmlOptimizer = config.plugins.find(plugin => plugin.name === 'plugin-standard-html').provider(compilation);
+ const pagesPathDiff = context.pagesDir.pathname.replace(context.projectDirectory.pathname, '');
+ const relativeDepth = relativeWorkspacePagePath.replace(`/${filename}`, '') === ''
+ ? '../'
+ : '../'.repeat(relativeWorkspacePagePath.replace(`/${filename}`, '').split('/').length);
+
+ let staticHtml = ssrPrerenderPagesRouteMapper[route];
+ staticHtml = await (await htmlOptimizer.optimize(new URL(`http://localhost:8080${route}`), new Response(staticHtml))).text();
+ staticHtml = staticHtml.replace(/[`\\$]/g, '\\$&'); // https://stackoverflow.com/a/75688937/417806
- const moduleUrl = new URL('${relativeDepth}${pagesPathDiff}${relativeWorkspacePagePath.replace('/', '')}', import.meta.url);
+ if (!await checkResourceExists(outputPathRootUrl)) {
+ await fs.mkdir(outputPathRootUrl, {
+ recursive: true
+ });
+ }
- export async function handler(request) {
- const compilation = JSON.parse('${JSON.stringify(compilation)}');
- const page = JSON.parse('${JSON.stringify(page)}');
- const data = await executeRouteModule({ moduleUrl, compilation, page, request });
- let staticHtml = \`${staticHtml}\`;
+ // better way to write out this inline code?
+ await fs.writeFile(entryFileUrl, `
+ import { executeRouteModule } from '${normalizePathnameForWindows(executeModuleUrl)}';
- if (data.body) {
- staticHtml = staticHtml.replace(\/\(.*)<\\/content-outlet>\/s, data.body);
- }
+ const moduleUrl = new URL('${relativeDepth}${pagesPathDiff}${relativeWorkspacePagePath.replace('/', '')}', import.meta.url);
+
+ export async function handler(request) {
+ const compilation = JSON.parse('${JSON.stringify(compilation)}');
+ const page = JSON.parse('${JSON.stringify(page)}');
+ const data = await executeRouteModule({ moduleUrl, compilation, page, request });
+ let staticHtml = \`${staticHtml}\`;
- return new Response(staticHtml, {
- headers: {
- 'Content-Type': 'text/html'
- }
- });
+ if (data.body) {
+ staticHtml = staticHtml.replace(\/\(.*)<\\/content-outlet>\/s, data.body);
}
- `);
- input.push(normalizePathnameForWindows(entryFileUrl));
- }
+ return new Response(staticHtml, {
+ headers: {
+ 'Content-Type': 'text/html'
+ }
+ });
+ }
+ `);
+
+ input.push(normalizePathnameForWindows(entryFileUrl));
}
const ssrConfigs = await getRollupConfigForSsr(compilation, input);
if (ssrConfigs.length > 0 && ssrConfigs[0].input !== '') {
+ console.info('bundling dynamic pages...');
for (const configIndex in ssrConfigs) {
const rollupConfig = ssrConfigs[configIndex];
const bundle = await rollup(rollupConfig);
@@ -337,7 +349,7 @@ const bundleCompilation = async (compilation) => {
]);
// bundleSsrPages depends on bundleScriptResources having run first
- await bundleSsrPages(compilation);
+ await bundleSsrPages(compilation, optimizeResourcePlugins);
console.info('optimizing static pages....');
await optimizeStaticPages(compilation, optimizeResourcePlugins);
diff --git a/packages/cli/src/lifecycles/compile.js b/packages/cli/src/lifecycles/compile.js
index 8b09af2a7..fb48336fe 100644
--- a/packages/cli/src/lifecycles/compile.js
+++ b/packages/cli/src/lifecycles/compile.js
@@ -22,7 +22,7 @@ const generateCompilation = () => {
console.info('Initializing project config');
compilation.config = await initConfig();
- // determine whether to use default template or user detected workspace
+ // determine whether to use default layout or user detected workspace
console.info('Initializing project workspace contexts');
compilation.context = await initContext(compilation);
diff --git a/packages/cli/src/lifecycles/config.js b/packages/cli/src/lifecycles/config.js
index e15fcc998..7ee7fc2f7 100644
--- a/packages/cli/src/lifecycles/config.js
+++ b/packages/cli/src/lifecycles/config.js
@@ -52,7 +52,7 @@ const defaultConfig = {
prerender: false,
isolation: false,
pagesDirectory: 'pages',
- templatesDirectory: 'templates'
+ layoutsDirectory: 'layouts'
};
const readAndMergeConfig = async() => {
@@ -77,7 +77,7 @@ const readAndMergeConfig = async() => {
if (hasConfigFile) {
const userCfgFile = (await import(configUrl)).default;
- const { workspace, devServer, markdown, optimization, plugins, port, prerender, basePath, staticRouter, pagesDirectory, templatesDirectory, interpolateFrontmatter, isolation } = userCfgFile;
+ const { workspace, devServer, markdown, optimization, plugins, port, prerender, basePath, staticRouter, pagesDirectory, layoutsDirectory, interpolateFrontmatter, isolation } = userCfgFile;
// workspace validation
if (workspace) {
@@ -205,10 +205,10 @@ const readAndMergeConfig = async() => {
reject(`Error: provided pagesDirectory "${pagesDirectory}" is not supported. Please make sure to pass something like 'docs/'`);
}
- if (templatesDirectory && typeof templatesDirectory === 'string') {
- customConfig.templatesDirectory = templatesDirectory;
- } else if (templatesDirectory) {
- reject(`Error: provided templatesDirectory "${templatesDirectory}" is not supported. Please make sure to pass something like 'layouts/'`);
+ if (layoutsDirectory && typeof layoutsDirectory === 'string') {
+ customConfig.layoutsDirectory = layoutsDirectory;
+ } else if (layoutsDirectory) {
+ reject(`Error: provided layoutsDirectory "${layoutsDirectory}" is not supported. Please make sure to pass something like 'layouts/'`);
}
if (prerender !== undefined) {
diff --git a/packages/cli/src/lifecycles/context.js b/packages/cli/src/lifecycles/context.js
index d49ae226b..e4f45b564 100644
--- a/packages/cli/src/lifecycles/context.js
+++ b/packages/cli/src/lifecycles/context.js
@@ -5,17 +5,17 @@ const initContext = async({ config }) => {
return new Promise(async (resolve, reject) => {
try {
- const { workspace, pagesDirectory, templatesDirectory } = config;
+ const { workspace, pagesDirectory, layoutsDirectory } = config;
const projectDirectory = new URL(`file://${process.cwd()}/`);
const scratchDir = new URL('./.greenwood/', projectDirectory);
const outputDir = new URL('./public/', projectDirectory);
const dataDir = new URL('../data/', import.meta.url);
- const templatesDir = new URL('../templates/', import.meta.url);
+ const layoutsDir = new URL('../layouts/', import.meta.url);
const userWorkspace = workspace;
- const apisDir = new URL('./api/', userWorkspace);
const pagesDir = new URL(`./${pagesDirectory}/`, userWorkspace);
- const userTemplatesDir = new URL(`./${templatesDirectory}/`, userWorkspace);
+ const apisDir = new URL('./api/', pagesDir);
+ const userLayoutsDir = new URL(`./${layoutsDirectory}/`, userWorkspace);
const context = {
dataDir,
@@ -23,10 +23,10 @@ const initContext = async({ config }) => {
userWorkspace,
apisDir,
pagesDir,
- userTemplatesDir,
+ userLayoutsDir,
scratchDir,
projectDirectory,
- templatesDir
+ layoutsDir
};
if (!await checkResourceExists(scratchDir)) {
diff --git a/packages/cli/src/lifecycles/graph.js b/packages/cli/src/lifecycles/graph.js
index 57b53b7bc..ad7415d30 100644
--- a/packages/cli/src/lifecycles/graph.js
+++ b/packages/cli/src/lifecycles/graph.js
@@ -11,7 +11,12 @@ const generateGraph = async (compilation) => {
try {
const { context, config } = compilation;
const { basePath } = config;
- const { apisDir, pagesDir, projectDirectory, userWorkspace } = context;
+ const { pagesDir, projectDirectory, userWorkspace } = context;
+ const customPageFormatPlugins = config.plugins
+ .filter(plugin => plugin.type === 'resource' && !plugin.isGreenwoodDefaultPlugin)
+ .map(plugin => plugin.provider(compilation));
+
+ let apis = new Map();
let graph = [{
outputPath: '/index.html',
filename: 'index.html',
@@ -26,7 +31,7 @@ const generateGraph = async (compilation) => {
isolation: false
}];
- const walkDirectoryForPages = async function(directory, pages = []) {
+ const walkDirectoryForPages = async function(directory, pages = [], apiRoutes = new Map()) {
const files = await fs.readdir(directory);
for (const filename of files) {
@@ -35,254 +40,254 @@ const generateGraph = async (compilation) => {
const isDirectory = await checkResourceExists(filenameUrlAsDir) && (await fs.stat(filenameUrlAsDir)).isDirectory();
if (isDirectory) {
- pages = await walkDirectoryForPages(filenameUrlAsDir, pages);
+ const nextPages = await walkDirectoryForPages(filenameUrlAsDir, pages, apiRoutes);
+
+ pages = nextPages.pages;
+ apiRoutes = nextPages.apiRoutes;
} else {
+ const req = new Request(filenameUrl, { headers: { 'Accept': 'text/html' } });
const extension = `.${filenameUrl.pathname.split('.').pop()}`;
- const isStatic = extension === '.md' || extension === '.html';
- const isDynamic = extension === '.js';
+ const isCustom = customPageFormatPlugins[0] && customPageFormatPlugins[0].shouldServe && await customPageFormatPlugins[0].shouldServe(filenameUrl, req)
+ ? customPageFormatPlugins[0].servePage
+ : null;
const relativePagePath = filenameUrl.pathname.replace(pagesDir.pathname, '/');
const relativeWorkspacePath = directory.pathname.replace(projectDirectory.pathname, '');
- let route = relativePagePath.replace(extension, '');
- let id = filename.split('/')[filename.split('/').length - 1].replace(extension, '');
- let template = 'page';
- let title = null;
- let imports = [];
- let customData = {};
- let filePath;
- let prerender = true;
- let isolation = false;
- let hydration = false;
-
- /*
- * check if additional nested directories exist to correctly determine route (minus filename)
- * examples:
- * - pages/index.{html,md,js} -> /
- * - pages/about.{html,md,js} -> /about/
- * - pages/blog/index.{html,md,js} -> /blog/
- * - pages/blog/some-post.{html,md,js} -> /blog/some-post/
- */
- if (relativePagePath.lastIndexOf('/') > 0) {
- // https://github.com/ProjectEvergreen/greenwood/issues/455
- route = id === 'index' || route.replace('/index', '') === `/${id}`
- ? route.replace('index', '')
- : `${route}/`;
- } else {
- route = route === '/index'
- ? '/'
- : `${route}/`;
- }
+ const isStatic = isCustom === 'static' || extension === '.md' || extension === '.html';
+ const isDynamic = isCustom === 'dynamic' || extension === '.js';
+ const isApiRoute = relativePagePath.startsWith('/api');
+ const isPage = isStatic || isDynamic;
+
+ if (isApiRoute) {
+ const req = new Request(filenameUrl);
+ const extension = filenameUrl.pathname.split('.').pop();
+ const isCustom = customPageFormatPlugins[0] && customPageFormatPlugins[0].shouldServe && await customPageFormatPlugins[0].shouldServe(filenameUrl, req);
+
+ if (extension !== 'js' && !isCustom) {
+ console.warn(`${filenameUrl} is not a supported API file extension, skipping...`);
+ return;
+ }
- if (isStatic) {
- const fileContents = await fs.readFile(filenameUrl, 'utf8');
- const { attributes } = fm(fileContents);
-
- template = attributes.template || 'page';
- title = attributes.title || title;
- id = attributes.label || id;
- imports = attributes.imports || [];
- filePath = `${relativeWorkspacePath}${filename}`;
-
- // prune "reserved" attributes that are supported by Greenwood
- // https://www.greenwoodjs.io/docs/front-matter
- customData = attributes;
-
- delete customData.label;
- delete customData.imports;
- delete customData.title;
- delete customData.template;
-
- /* Menu Query
- * Custom front matter - Variable Definitions
- * --------------------------------------------------
- * menu: the name of the menu in which this item can be listed and queried
- * index: the index of this list item within a menu
- * linkheadings: flag to tell us where to add page's table of contents as menu items
- * tableOfContents: json object containing page's table of contents(list of headings)
+ const relativeApiPath = filenameUrl.pathname.replace(pagesDir.pathname, '/');
+ const route = `${basePath}${relativeApiPath.replace(`.${extension}`, '')}`;
+ // TODO should this be run in isolation like SSR pages?
+ // https://github.com/ProjectEvergreen/greenwood/issues/991
+ const { isolation } = await import(filenameUrl).then(module => module);
+
+ /*
+ * API Properties (per route)
+ *----------------------
+ * filename: base filename of the page
+ * outputPath: the filename to write to when generating a build
+ * path: path to the file relative to the workspace
+ * route: URL route for a given page on outputFilePath
+ * isolation: if this should be run in isolated mode
+ */
+ apiRoutes.set(route, {
+ filename: filename,
+ outputPath: `/api/${filename.replace(`.${extension}`, '.js')}`,
+ path: relativeApiPath,
+ route,
+ isolation
+ });
+ } else if (isPage) {
+ let route = relativePagePath.replace(extension, '');
+ let id = filename.split('/')[filename.split('/').length - 1].replace(extension, '');
+ let layout = extension === '.html' ? null : 'page';
+ let title = null;
+ let imports = [];
+ let customData = {};
+ let filePath;
+ let prerender = true;
+ let isolation = false;
+ let hydration = false;
+
+ /*
+ * check if additional nested directories exist to correctly determine route (minus filename)
+ * examples:
+ * - pages/index.{html,md,js} -> /
+ * - pages/about.{html,md,js} -> /about/
+ * - pages/blog/index.{html,md,js} -> /blog/
+ * - pages/blog/some-post.{html,md,js} -> /blog/some-post/
*/
- // set specific menu to place this page
- customData.menu = customData.menu || '';
+ if (relativePagePath.lastIndexOf('/') > 0) {
+ // https://github.com/ProjectEvergreen/greenwood/issues/455
+ route = id === 'index' || route.replace('/index', '') === `/${id}`
+ ? route.replace('index', '')
+ : `${route}/`;
+ } else {
+ route = route === '/index'
+ ? '/'
+ : `${route}/`;
+ }
- // set specific index list priority of this item within a menu
- customData.index = customData.index || '';
+ if (isStatic) {
+ const fileContents = await fs.readFile(filenameUrl, 'utf8');
+ const { attributes } = fm(fileContents);
- // set flag whether to gather a list of headings on a page as menu items
- customData.linkheadings = customData.linkheadings || 0;
- customData.tableOfContents = [];
+ layout = attributes.layout || layout;
+ title = attributes.title || title;
+ id = attributes.label || id;
+ imports = attributes.imports || [];
+ filePath = `${relativeWorkspacePath}${filename}`;
- if (customData.linkheadings > 0) {
- // parse markdown for table of contents and output to json
- customData.tableOfContents = toc(fileContents).json;
- customData.tableOfContents.shift();
+ // prune "reserved" attributes that are supported by Greenwood
+ // https://www.greenwoodjs.io/docs/front-matter
+ customData = attributes;
- // parse table of contents for only the pages user wants linked
- if (customData.tableOfContents.length > 0 && customData.linkheadings > 0) {
- customData.tableOfContents = customData.tableOfContents
- .filter((item) => item.lvl === customData.linkheadings);
- }
- }
- /* ---------End Menu Query-------------------- */
- } else if (isDynamic) {
- const routeWorkerUrl = compilation.config.plugins.filter(plugin => plugin.type === 'renderer')[0].provider(compilation).executeModuleUrl;
- let ssrFrontmatter;
-
- filePath = route;
-
- await new Promise(async (resolve, reject) => {
- const worker = new Worker(new URL('../lib/ssr-route-worker.js', import.meta.url));
- // TODO "faux" new Request here, a better way?
- const request = await requestAsObject(new Request(filenameUrl));
-
- worker.on('message', async (result) => {
- prerender = result.prerender ?? false;
- isolation = result.isolation ?? isolation;
- hydration = result.hydration ?? hydration;
-
- if (result.frontmatter) {
- result.frontmatter.imports = result.frontmatter.imports || [];
- ssrFrontmatter = result.frontmatter;
- }
+ delete customData.label;
+ delete customData.imports;
+ delete customData.title;
+ delete customData.layout;
- resolve();
- });
- worker.on('error', reject);
- worker.on('exit', (code) => {
- if (code !== 0) {
- reject(new Error(`Worker stopped with exit code ${code}`));
+ /* Menu Query
+ * Custom front matter - Variable Definitions
+ * --------------------------------------------------
+ * menu: the name of the menu in which this item can be listed and queried
+ * index: the index of this list item within a menu
+ * linkheadings: flag to tell us where to add page's table of contents as menu items
+ * tableOfContents: json object containing page's table of contents(list of headings)
+ */
+ // set specific menu to place this page
+ customData.menu = customData.menu || '';
+
+ // set specific index list priority of this item within a menu
+ customData.index = customData.index || '';
+
+ // set flag whether to gather a list of headings on a page as menu items
+ customData.linkheadings = customData.linkheadings || 0;
+ customData.tableOfContents = [];
+
+ if (customData.linkheadings > 0) {
+ // parse markdown for table of contents and output to json
+ customData.tableOfContents = toc(fileContents).json;
+ customData.tableOfContents.shift();
+
+ // parse table of contents for only the pages user wants linked
+ if (customData.tableOfContents.length > 0 && customData.linkheadings > 0) {
+ customData.tableOfContents = customData.tableOfContents
+ .filter((item) => item.lvl === customData.linkheadings);
}
+ }
+ /* ---------End Menu Query-------------------- */
+ } else if (isDynamic) {
+ const routeWorkerUrl = compilation.config.plugins.filter(plugin => plugin.type === 'renderer')[0].provider(compilation).executeModuleUrl;
+ let ssrFrontmatter;
+
+ filePath = route;
+
+ await new Promise(async (resolve, reject) => {
+ const worker = new Worker(new URL('../lib/ssr-route-worker.js', import.meta.url));
+ const request = await requestAsObject(new Request(filenameUrl));
+
+ worker.on('message', async (result) => {
+ prerender = result.prerender ?? false;
+ isolation = result.isolation ?? isolation;
+ hydration = result.hydration ?? hydration;
+
+ if (result.frontmatter) {
+ result.frontmatter.imports = result.frontmatter.imports || [];
+ ssrFrontmatter = result.frontmatter;
+ }
+
+ resolve();
+ });
+ worker.on('error', reject);
+ worker.on('exit', (code) => {
+ if (code !== 0) {
+ reject(new Error(`Worker stopped with exit code ${code}`));
+ }
+ });
+
+ worker.postMessage({
+ executeModuleUrl: routeWorkerUrl.href,
+ moduleUrl: filenameUrl.href,
+ compilation: JSON.stringify(compilation),
+ // TODO need to get as many of these params as possible
+ // or ignore completely?
+ page: JSON.stringify({
+ servePage: isCustom,
+ route,
+ id,
+ label: id.split('-')
+ .map((idPart) => {
+ return `${idPart.charAt(0).toUpperCase()}${idPart.substring(1)}`;
+ }).join(' ')
+ }),
+ request
+ });
});
- worker.postMessage({
- executeModuleUrl: routeWorkerUrl.href,
- moduleUrl: filenameUrl.href,
- compilation: JSON.stringify(compilation),
- // TODO need to get as many of these params as possible
- // or ignore completely?
- page: JSON.stringify({
- route,
- id,
- label: id.split('-')
- .map((idPart) => {
- return `${idPart.charAt(0).toUpperCase()}${idPart.substring(1)}`;
- }).join(' ')
- }),
- request
- });
- });
-
- if (ssrFrontmatter) {
- template = ssrFrontmatter.template || template;
- title = ssrFrontmatter.title || title;
- imports = ssrFrontmatter.imports || imports;
- customData = ssrFrontmatter.data || customData;
-
- /* Menu Query
- * Custom front matter - Variable Definitions
- * --------------------------------------------------
- * menu: the name of the menu in which this item can be listed and queried
- * index: the index of this list item within a menu
- * linkheadings: flag to tell us where to add page's table of contents as menu items
- * tableOfContents: json object containing page's table of contents(list of headings)
- */
- customData.menu = ssrFrontmatter.menu || '';
- customData.index = ssrFrontmatter.index || '';
+ if (ssrFrontmatter) {
+ layout = ssrFrontmatter.layout || layout;
+ title = ssrFrontmatter.title || title;
+ imports = ssrFrontmatter.imports || imports;
+ customData = ssrFrontmatter.data || customData;
+
+ /* Menu Query
+ * Custom front matter - Variable Definitions
+ * --------------------------------------------------
+ * menu: the name of the menu in which this item can be listed and queried
+ * index: the index of this list item within a menu
+ * linkheadings: flag to tell us where to add page's table of contents as menu items
+ * tableOfContents: json object containing page's table of contents(list of headings)
+ */
+ customData.menu = ssrFrontmatter.menu || '';
+ customData.index = ssrFrontmatter.index || '';
+ }
}
- } else {
- console.debug(`Unhandled extension (.${extension}) for route => ${route}`);
- }
- /*
- * Graph Properties (per page)
- *----------------------
- * data: custom page frontmatter
- * filename: base filename of the page
- * id: filename without the extension
- * relativeWorkspacePagePath: the file path relative to the user's workspace directory
- * label: "pretty" text representation of the filename
- * imports: per page JS or CSS file imports to be included in HTML output from frontmatter
- * resources: sum of all resources for the entire page
- * outputPath: the filename to write to when generating static HTML
- * path: path to the file relative to the workspace
- * route: URL route for a given page on outputFilePath
- * template: page template to use as a base for a generated component
- * title: a default value that can be used for
- * isSSR: if this is a server side route
- * prerender: if this should be statically exported
- * isolation: if this should be run in isolated mode
- * hydration: if this page needs hydration support
- */
- pages.push({
- data: customData || {},
- filename,
- id,
- relativeWorkspacePagePath: relativePagePath,
- label: id.split('-')
- .map((idPart) => {
- return `${idPart.charAt(0).toUpperCase()}${idPart.substring(1)}`;
- }).join(' '),
- imports,
- resources: [],
- outputPath: route === '/404/'
- ? '/404.html'
- : `${route}index.html`,
- path: filePath,
- route: `${basePath}${route}`,
- template,
- title,
- isSSR: !isStatic,
- prerender,
- isolation,
- hydration
- });
- }
- }
-
- return pages;
- };
-
- const walkDirectoryForApis = async function(directory, apis = new Map()) {
- const files = await fs.readdir(directory);
-
- for (const filename of files) {
- const filenameUrl = new URL(`./${filename}`, directory);
- const filenameUrlAsDir = new URL(`./${filename}/`, directory);
- const isDirectory = await checkResourceExists(filenameUrlAsDir) && (await fs.stat(filenameUrlAsDir)).isDirectory();
-
- if (isDirectory) {
- apis = await walkDirectoryForApis(filenameUrlAsDir, apis);
- } else {
- const extension = filenameUrl.pathname.split('.').pop();
-
- if (extension !== 'js') {
- console.warn(`${filenameUrl} is not a JavaScript file, skipping...`);
- return;
+ /*
+ * Graph Properties (per page)
+ *----------------------
+ * data: custom page frontmatter
+ * filename: base filename of the page
+ * id: filename without the extension
+ * relativeWorkspacePagePath: the file path relative to the user's workspace directory
+ * label: "pretty" text representation of the filename
+ * imports: per page JS or CSS file imports to be included in HTML output from frontmatter
+ * resources: sum of all resources for the entire page
+ * outputPath: the filename to write to when generating static HTML
+ * path: path to the file relative to the workspace
+ * route: URL route for a given page on outputFilePath
+ * layout: page layout to use as a base for a generated component
+ * title: a default value that can be used for
+ * isSSR: if this is a server side route
+ * prerender: if this should be statically exported
+ * isolation: if this should be run in isolated mode
+ * hydration: if this page needs hydration support
+ * servePage: signal that this is a custom page file type (static | dynamic)
+ */
+ pages.push({
+ data: customData || {},
+ filename,
+ id,
+ relativeWorkspacePagePath: relativePagePath,
+ label: id.split('-')
+ .map((idPart) => {
+ return `${idPart.charAt(0).toUpperCase()}${idPart.substring(1)}`;
+ }).join(' '),
+ imports,
+ resources: [],
+ outputPath: route === '/404/'
+ ? '/404.html'
+ : `${route}index.html`,
+ path: filePath,
+ route: `${basePath}${route}`,
+ layout,
+ title,
+ isSSR: !isStatic,
+ prerender,
+ isolation,
+ hydration,
+ servePage: isCustom
+ });
+ } else {
+ console.debug(`Unhandled extension (${extension}) for route => ${route}`);
}
-
- const relativeApiPath = filenameUrl.pathname.replace(userWorkspace.pathname, '/');
- const route = `${basePath}${relativeApiPath.replace(`.${extension}`, '')}`;
- // TODO should this be run in isolation like SSR pages?
- // https://github.com/ProjectEvergreen/greenwood/issues/991
- const { isolation } = await import(filenameUrl).then(module => module);
-
- /*
- * API Properties (per route)
- *----------------------
- * filename: base filename of the page
- * outputPath: the filename to write to when generating a build
- * path: path to the file relative to the workspace
- * route: URL route for a given page on outputFilePath
- * isolation: if this should be run in isolated mode
- */
- apis.set(route, {
- filename: filename,
- outputPath: `/api/${filename}`,
- path: relativeApiPath,
- route,
- isolation
- });
}
}
- return apis;
+ return { pages, apiRoutes };
};
console.debug('building from local sources...');
@@ -296,8 +301,10 @@ const generateGraph = async (compilation) => {
}];
} else {
const oldGraph = graph[0];
+ const pages = await checkResourceExists(pagesDir) ? await walkDirectoryForPages(pagesDir) : { pages: graph, apiRoutes: apis };
- graph = await checkResourceExists(pagesDir) ? await walkDirectoryForPages(pagesDir) : graph;
+ graph = pages.pages;
+ apis = pages.apiRoutes;
const has404Page = graph.find(page => page.route.endsWith('/404/'));
@@ -353,12 +360,7 @@ const generateGraph = async (compilation) => {
}
compilation.graph = graph;
-
- if (await checkResourceExists(apisDir)) {
- const apis = await walkDirectoryForApis(apisDir);
-
- compilation.manifest = { apis };
- }
+ compilation.manifest = { apis };
resolve(compilation);
} catch (err) {
diff --git a/packages/cli/src/lifecycles/prerender.js b/packages/cli/src/lifecycles/prerender.js
index 804cfd4a1..04007e00e 100644
--- a/packages/cli/src/lifecycles/prerender.js
+++ b/packages/cli/src/lifecycles/prerender.js
@@ -3,8 +3,6 @@ import { checkResourceExists, trackResourcesForRoute } from '../lib/resource-uti
import os from 'os';
import { WorkerPool } from '../lib/threadpool.js';
-// TODO a lot of these are duplicated in the build lifecycle too
-// would be good to refactor
async function createOutputDirectory(route, outputDir) {
if (!route.endsWith('/404/') && !await checkResourceExists(outputDir)) {
await fs.mkdir(outputDir, {
@@ -62,18 +60,32 @@ async function preRenderCompilationWorker(compilation, workerPrerender) {
const pool = new WorkerPool(os.cpus().length, new URL('../lib/ssr-route-worker.js', import.meta.url));
for (const page of pages) {
- const { route, outputPath, resources } = page;
+ const { route, outputPath } = page;
const outputPathUrl = new URL(`.${outputPath}`, scratchDir);
const url = new URL(`http://localhost:${compilation.config.port}${route}`);
const request = new Request(url);
+ let ssrContents;
+ // do we negate the worker pool by also running this, outside the pool?
let body = await (await servePage(url, request, plugins)).text();
body = await (await interceptPage(url, request, plugins, body)).text();
- await createOutputDirectory(route, new URL(outputPathUrl.href.replace('index.html', '')));
+ // hack to avoid over-rendering SSR content
+ // https://github.com/ProjectEvergreen/greenwood/issues/1044
+ // https://github.com/ProjectEvergreen/greenwood/issues/988#issuecomment-1288168858
+ if (page.isSSR) {
+ const ssrContentsMatch = /(.*.)/s;
+
+ ssrContents = body.match(ssrContentsMatch)[0];
+ body = body.replace(ssrContents, '');
+
+ ssrContents = ssrContents
+ .replace('', '')
+ .replace('', '');
+ }
+ const resources = await trackResourcesForRoute(body, compilation, route);
const scripts = resources
- .map(resource => compilation.resources.get(resource))
.filter(resource => resource.type === 'script')
.map(resource => resource.sourcePathURL.href);
@@ -95,6 +107,11 @@ async function preRenderCompilationWorker(compilation, workerPrerender) {
});
});
+ if (page.isSSR) {
+ body = body.replace('', ssrContents);
+ }
+
+ await createOutputDirectory(route, new URL(outputPathUrl.href.replace('index.html', '')));
await fs.writeFile(outputPathUrl, body);
console.info('generated page...', route);
@@ -117,7 +134,7 @@ async function preRenderCompilationCustom(compilation, customPrerender) {
body = body.replace(/
`)
diff --git a/packages/cli/test/cases/build.config.error-templates-directory/build.config.error-templates-directory.spec.js b/packages/cli/test/cases/build.config.error-layouts-directory/build.config.error-layouts-directory.spec.js
similarity index 63%
rename from packages/cli/test/cases/build.config.error-templates-directory/build.config.error-templates-directory.spec.js
rename to packages/cli/test/cases/build.config.error-layouts-directory/build.config.error-layouts-directory.spec.js
index 8b481fd00..e48c2130a 100644
--- a/packages/cli/test/cases/build.config.error-templates-directory/build.config.error-templates-directory.spec.js
+++ b/packages/cli/test/cases/build.config.error-layouts-directory/build.config.error-layouts-directory.spec.js
@@ -1,6 +1,6 @@
/*
* Use Case
- * Run Greenwood build command with a bad value for templatesDirectory in a custom config.
+ * Run Greenwood build command with a bad value for layoutsDirectory in a custom config.
*
* User Result
* Should throw an error.
@@ -10,7 +10,7 @@
*
* User Config
* {
- * templatesDirectory: {}
+ * layoutsDirectory: {}
* }
*
* User Workspace
@@ -35,13 +35,13 @@ describe('Build Greenwood With: ', function() {
runner = new Runner();
});
- describe('Custom Configuration with a bad value for templatesDirectory', function() {
- it('should throw an error that templatesDirectory must be a string', function() {
+ describe('Custom Configuration with a bad value for layoutsDirectory', function() {
+ it('should throw an error that layoutsDirectory must be a string', async function() {
try {
runner.setup(outputPath);
runner.runCommand(cliPath, 'build');
} catch (err) {
- expect(err).to.contain('Error: provided templatesDirectory "[object Object]" is not supported. Please make sure to pass something like \'layouts/\'');
+ expect(err).to.contain('Error: provided layoutsDirectory "[object Object]" is not supported. Please make sure to pass something like \'layouts/\'');
}
});
});
diff --git a/packages/cli/test/cases/build.config.error-layouts-directory/greenwood.config.js b/packages/cli/test/cases/build.config.error-layouts-directory/greenwood.config.js
new file mode 100644
index 000000000..376ab3249
--- /dev/null
+++ b/packages/cli/test/cases/build.config.error-layouts-directory/greenwood.config.js
@@ -0,0 +1,3 @@
+export default {
+ layoutsDirectory: {}
+};
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.config.error-templates-directory/greenwood.config.js b/packages/cli/test/cases/build.config.error-templates-directory/greenwood.config.js
deleted file mode 100644
index b8e6daaba..000000000
--- a/packages/cli/test/cases/build.config.error-templates-directory/greenwood.config.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export default {
- templatesDirectory: {}
-};
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.config.interpolate-frontmatter/build.config.interpolate-frontmatter.spec.js b/packages/cli/test/cases/build.config.interpolate-frontmatter/build.config.interpolate-frontmatter.spec.js
index 62b30ae9c..b39193067 100644
--- a/packages/cli/test/cases/build.config.interpolate-frontmatter/build.config.interpolate-frontmatter.spec.js
+++ b/packages/cli/test/cases/build.config.interpolate-frontmatter/build.config.interpolate-frontmatter.spec.js
@@ -19,7 +19,7 @@
* pages/
* blog/
* first-post.md
- * templates/
+ * layouts/
* blog.html
*/
import { JSDOM } from 'jsdom';
diff --git a/packages/cli/test/cases/build.config.interpolate-frontmatter/src/templates/blog.html b/packages/cli/test/cases/build.config.interpolate-frontmatter/src/layouts/blog.html
similarity index 100%
rename from packages/cli/test/cases/build.config.interpolate-frontmatter/src/templates/blog.html
rename to packages/cli/test/cases/build.config.interpolate-frontmatter/src/layouts/blog.html
diff --git a/packages/cli/test/cases/build.config.interpolate-frontmatter/src/pages/blog/first-post.md b/packages/cli/test/cases/build.config.interpolate-frontmatter/src/pages/blog/first-post.md
index deae1bb80..fa488585c 100644
--- a/packages/cli/test/cases/build.config.interpolate-frontmatter/src/pages/blog/first-post.md
+++ b/packages/cli/test/cases/build.config.interpolate-frontmatter/src/pages/blog/first-post.md
@@ -1,6 +1,6 @@
---
title: Ny First Post
-template: blog
+layout: blog
published: 11/11/2022
author: Owen Buckley
---
diff --git a/packages/cli/test/cases/build.config.templates-directory/build.config.templates-directory.spec.js b/packages/cli/test/cases/build.config.layouts-directory/build.config.layouts-directory.spec.js
similarity index 89%
rename from packages/cli/test/cases/build.config.templates-directory/build.config.templates-directory.spec.js
rename to packages/cli/test/cases/build.config.layouts-directory/build.config.layouts-directory.spec.js
index baac1c79b..f206cf923 100644
--- a/packages/cli/test/cases/build.config.templates-directory/build.config.templates-directory.spec.js
+++ b/packages/cli/test/cases/build.config.layouts-directory/build.config.layouts-directory.spec.js
@@ -1,6 +1,6 @@
/*
* Use Case
- * Run Greenwood with a custom name for templates directory.
+ * Run Greenwood with a custom name for layouts directory.
*
* User Result
* Should generate a bare bones Greenwood build. (same as build.default.spec.js) with custom title in header
@@ -10,7 +10,7 @@
*
* User Config
* {
- * templatesDirectory: 'layouts'
+ * layoutsDirectory: 'layouts'
* }
*
* User Workspace
@@ -68,7 +68,7 @@ describe('Build Greenwood With: ', function() {
it('should have the correct page heading', function() {
const heading = dom.window.document.querySelectorAll('head title')[0].textContent;
- expect(heading).to.be.equal('Custom Layout Page Template');
+ expect(heading).to.be.equal('Custom Layout Page Layout');
});
it('should have the correct page heading', function() {
@@ -80,7 +80,7 @@ describe('Build Greenwood With: ', function() {
it('should have the correct page heading', function() {
const paragraph = dom.window.document.querySelectorAll('body p')[0].textContent;
- expect(paragraph).to.be.equal('A page using a page template from a custom layout directory.');
+ expect(paragraph).to.be.equal('A page using a page layout from a custom layout directory.');
});
});
});
diff --git a/packages/cli/test/cases/build.config.layouts-directory/greenwood.config.js b/packages/cli/test/cases/build.config.layouts-directory/greenwood.config.js
new file mode 100644
index 000000000..04634f17c
--- /dev/null
+++ b/packages/cli/test/cases/build.config.layouts-directory/greenwood.config.js
@@ -0,0 +1,3 @@
+export default {
+ layoutsDirectory: 'my-layouts'
+};
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.config.templates-directory/src/layouts/page.html b/packages/cli/test/cases/build.config.layouts-directory/src/my-layouts/page.html
similarity index 66%
rename from packages/cli/test/cases/build.config.templates-directory/src/layouts/page.html
rename to packages/cli/test/cases/build.config.layouts-directory/src/my-layouts/page.html
index b7fe92d12..0fc6a16f9 100644
--- a/packages/cli/test/cases/build.config.templates-directory/src/layouts/page.html
+++ b/packages/cli/test/cases/build.config.layouts-directory/src/my-layouts/page.html
@@ -1,6 +1,6 @@
- Custom Layout Page Template
+ Custom Layout Page Layout
diff --git a/packages/cli/test/cases/build.config.layouts-directory/src/pages/index.md b/packages/cli/test/cases/build.config.layouts-directory/src/pages/index.md
new file mode 100644
index 000000000..3332d3216
--- /dev/null
+++ b/packages/cli/test/cases/build.config.layouts-directory/src/pages/index.md
@@ -0,0 +1,3 @@
+# Home Page
+
+A page using a page layout from a custom layout directory.
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.config.optimization-inline/build.config-optimization-inline.spec.js b/packages/cli/test/cases/build.config.optimization-inline/build.config-optimization-inline.spec.js
index 149ae06dd..f025f762b 100644
--- a/packages/cli/test/cases/build.config.optimization-inline/build.config-optimization-inline.spec.js
+++ b/packages/cli/test/cases/build.config.optimization-inline/build.config-optimization-inline.spec.js
@@ -18,6 +18,8 @@
* components/
* foobar.js
* header.js
+ * layouts/
+ * app.html
* pages/
* index.html
* styles/
diff --git a/packages/cli/test/cases/build.config.optimization-inline/src/templates/app.html b/packages/cli/test/cases/build.config.optimization-inline/src/layouts/app.html
similarity index 100%
rename from packages/cli/test/cases/build.config.optimization-inline/src/templates/app.html
rename to packages/cli/test/cases/build.config.optimization-inline/src/layouts/app.html
diff --git a/packages/cli/test/cases/build.config.prerender/build.config.prerender.spec.js b/packages/cli/test/cases/build.config.prerender/build.config.prerender.spec.js
index 6a86102e6..881d19886 100644
--- a/packages/cli/test/cases/build.config.prerender/build.config.prerender.spec.js
+++ b/packages/cli/test/cases/build.config.prerender/build.config.prerender.spec.js
@@ -98,12 +98,6 @@ describe('Build Greenwood With: ', function() {
});
});
- it('should have the expected heading text within the index page in the public directory', function() {
- const heading = dom.window.document.querySelector('body h1').textContent;
-
- expect(heading).to.equal('Welcome to Greenwood!');
- });
-
it('should have prerendered content from component', function() {
const appHeader = dom.window.document.querySelectorAll('body app-header');
const header = dom.window.document.querySelectorAll('body header');
diff --git a/packages/cli/test/cases/build.config.static-router/build.config.static-router.spec.js b/packages/cli/test/cases/build.config.static-router/build.config.static-router.spec.js
index 56a992c28..f90f340a3 100644
--- a/packages/cli/test/cases/build.config.static-router/build.config.static-router.spec.js
+++ b/packages/cli/test/cases/build.config.static-router/build.config.static-router.spec.js
@@ -95,7 +95,7 @@ describe('Build Greenwood With: ', function() {
expect(inlineRouterTags.length).to.be.equal(1);
expect(inlineRouterTags[0].textContent).to.contain('window.__greenwood = window.__greenwood || {};');
- expect(inlineRouterTags[0].textContent).to.contain('window.__greenwood.currentTemplate = "page"');
+ expect(inlineRouterTags[0].textContent).to.contain('window.__greenwood.currentLayout = "page"');
});
it('should have one tag in the for the content', function() {
@@ -117,7 +117,7 @@ describe('Build Greenwood With: ', function() {
const dataset = aboutRouteTag[0].dataset;
expect(aboutRouteTag.length).to.be.equal(1);
- expect(dataset.template).to.be.equal('test');
+ expect(dataset.layout).to.be.equal('test');
expect(dataset.key).to.be.equal('/_routes/about/index.html');
});
@@ -128,7 +128,7 @@ describe('Build Greenwood With: ', function() {
const dataset = aboutRouteTag[0].dataset;
expect(aboutRouteTag.length).to.be.equal(1);
- expect(dataset.template).to.be.equal('page');
+ expect(dataset.layout).to.be.equal('page');
expect(dataset.key).to.be.equal('/_routes/index.html');
});
diff --git a/packages/cli/test/cases/build.config.static-router/src/pages/about.md b/packages/cli/test/cases/build.config.static-router/src/pages/about.md
index b90299ace..5618aaa66 100644
--- a/packages/cli/test/cases/build.config.static-router/src/pages/about.md
+++ b/packages/cli/test/cases/build.config.static-router/src/pages/about.md
@@ -1,5 +1,5 @@
---
-template: test
+layout: test
---
### Greenwood
diff --git a/packages/cli/test/cases/build.config.static-router/src/pages/regex-test.html b/packages/cli/test/cases/build.config.static-router/src/pages/regex-test.html
index e25174ef9..70b2aba4e 100644
--- a/packages/cli/test/cases/build.config.static-router/src/pages/regex-test.html
+++ b/packages/cli/test/cases/build.config.static-router/src/pages/regex-test.html
@@ -176,7 +176,7 @@
The static site generator for your. . .
-
+
Greenwood is a modern and performant static site generator for Web Component based development.
diff --git a/packages/cli/test/cases/build.config.templates-directory/greenwood.config.js b/packages/cli/test/cases/build.config.templates-directory/greenwood.config.js
deleted file mode 100644
index 4ea248e54..000000000
--- a/packages/cli/test/cases/build.config.templates-directory/greenwood.config.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export default {
- templatesDirectory: 'layouts'
-};
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.config.templates-directory/src/pages/index.md b/packages/cli/test/cases/build.config.templates-directory/src/pages/index.md
deleted file mode 100644
index a44ed2d17..000000000
--- a/packages/cli/test/cases/build.config.templates-directory/src/pages/index.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Home Page
-
-A page using a page template from a custom layout directory.
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.meta/build.default.meta.spec.js b/packages/cli/test/cases/build.default.meta/build.default.meta.spec.js
index 23efa5a6d..5dae7737f 100644
--- a/packages/cli/test/cases/build.default.meta/build.default.meta.spec.js
+++ b/packages/cli/test/cases/build.default.meta/build.default.meta.spec.js
@@ -1,6 +1,6 @@
/*
* Use Case
- * Run Greenwood and tests for correct `` tag merging for pages and templates.
+ * Run Greenwood and tests for correct `` tag merging for pages and layouts.
*
* User Result
* Should generate a bare bones Greenwood build with one nested About page with expected meta values.
@@ -19,7 +19,7 @@
* index.md
* hello.md
* index.md
- * template/
+ * layout/
* app.html
* page.html
*/
diff --git a/packages/cli/test/cases/build.default.meta/src/templates/page.html b/packages/cli/test/cases/build.default.meta/src/layouts/page.html
similarity index 100%
rename from packages/cli/test/cases/build.default.meta/src/templates/page.html
rename to packages/cli/test/cases/build.default.meta/src/layouts/page.html
diff --git a/packages/cli/test/cases/build.default.ssr-prerender/build.default.ssr-prerender.spec.js b/packages/cli/test/cases/build.default.ssr-prerender/build.default.ssr-prerender.spec.js
index f4eb9413e..001fd39a8 100644
--- a/packages/cli/test/cases/build.default.ssr-prerender/build.default.ssr-prerender.spec.js
+++ b/packages/cli/test/cases/build.default.ssr-prerender/build.default.ssr-prerender.spec.js
@@ -19,7 +19,7 @@
* footer.js
* pages/
* index.js
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
@@ -68,17 +68,35 @@ describe('Build Greenwood With: ', function() {
expect(headings[0].textContent).to.equal('This is the home page.');
});
- it('should have one top level element with a with an open shadowroot', function() {
- expect(dom.window.document.querySelectorAll('app-footer template[shadowrootmode="open"]').length).to.equal(1);
- expect(dom.window.document.querySelectorAll('template').length).to.equal(1);
+ it('should have one top level tag with a with an open shadowroot', function() {
+ const header = dom.window.document.querySelectorAll('app-header template[shadowrootmode="open"]');
+ const headerContentsDom = new JSDOM(header[0].innerHTML);
+ const heading = headerContentsDom.window.document.querySelectorAll('h1');
+
+ expect(header.length).to.equal(1);
+ expect(heading.length).to.equal(1);
+ expect(heading[0].textContent.trim()).to.equal('This is the header component.');
+ });
+
+ // specifically to test for these bugs
+ // https://github.com/ProjectEvergreen/greenwood/issues/1044
+ // https://github.com/ProjectEvergreen/greenwood/issues/988#issuecomment-1288168858
+ it('should have one two top level tag with expected link items', function() {
+ // one set comes from the HTML, one from the SSR page
+ const links = dom.window.document.querySelectorAll('body > app-social-links ul li a');
+
+ expect(links.length).to.equal(6);
});
- it('should have the expected SSR Shadow DOM content for the footer', function() {
- const wrapper = new JSDOM(dom.window.document.querySelectorAll('app-footer template[shadowrootmode="open"]')[0].innerHTML);
- const footer = wrapper.window.document.querySelectorAll('footer');
+ it('should have one top level tag with expected link items', function() {
+ const footer = dom.window.document.querySelectorAll('app-footer');
+ const paragraph = footer[0].querySelectorAll('p');
+ const links = footer[0].querySelectorAll('app-social-links ul li a');
expect(footer.length).to.equal(1);
- expect(footer[0].textContent).to.equal('This is the footer component.');
+ expect(paragraph.length).to.equal(1);
+ expect(paragraph[0].textContent.trim()).to.equal('This is the footer component.');
+ expect(links.length).to.equal(3);
});
});
});
diff --git a/packages/cli/test/cases/build.default.ssr-prerender/src/components/footer.js b/packages/cli/test/cases/build.default.ssr-prerender/src/components/footer.js
index 2aef0ca53..50ec19179 100644
--- a/packages/cli/test/cases/build.default.ssr-prerender/src/components/footer.js
+++ b/packages/cli/test/cases/build.default.ssr-prerender/src/components/footer.js
@@ -1,15 +1,14 @@
-const template = document.createElement('template');
-
-template.innerHTML = '';
+import './social-links.js';
export default class FooterComponent extends HTMLElement {
- constructor() {
- super();
- this.attachShadow({ mode: 'open' });
- }
connectedCallback() {
- this.shadowRoot.appendChild(template.content.cloneNode(true));
+ this.innerHTML = `
+
+ `;
}
}
diff --git a/packages/cli/test/cases/build.default.ssr-prerender/src/components/header.js b/packages/cli/test/cases/build.default.ssr-prerender/src/components/header.js
new file mode 100644
index 000000000..f5165a913
--- /dev/null
+++ b/packages/cli/test/cases/build.default.ssr-prerender/src/components/header.js
@@ -0,0 +1,20 @@
+const template = document.createElement('template');
+
+template.innerHTML = `
+
+
This is the header component.
+
+`;
+
+export default class HeaderComponent extends HTMLElement {
+ constructor() {
+ super();
+ this.attachShadow({ mode: 'open' });
+ }
+
+ connectedCallback() {
+ this.shadowRoot.appendChild(template.content.cloneNode(true));
+ }
+}
+
+customElements.define('app-header', HeaderComponent);
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.ssr-prerender/src/components/social-links.js b/packages/cli/test/cases/build.default.ssr-prerender/src/components/social-links.js
new file mode 100644
index 000000000..a9bd49d09
--- /dev/null
+++ b/packages/cli/test/cases/build.default.ssr-prerender/src/components/social-links.js
@@ -0,0 +1,13 @@
+export default class SocialLinksComponent extends HTMLElement {
+ connectedCallback() {
+ this.innerHTML = `
+
+ `;
+ }
+}
+
+customElements.define('app-social-links', SocialLinksComponent);
\ No newline at end of file
diff --git a/packages/cli/test/cases/serve.default.ssr-prerender/src/templates/app.html b/packages/cli/test/cases/build.default.ssr-prerender/src/layouts/app.html
similarity index 64%
rename from packages/cli/test/cases/serve.default.ssr-prerender/src/templates/app.html
rename to packages/cli/test/cases/build.default.ssr-prerender/src/layouts/app.html
index 939d14bb4..c005c0a73 100644
--- a/packages/cli/test/cases/serve.default.ssr-prerender/src/templates/app.html
+++ b/packages/cli/test/cases/build.default.ssr-prerender/src/layouts/app.html
@@ -4,10 +4,14 @@
Default Title
+
+
-
+
+
+
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.ssr-prerender/src/pages/index.js b/packages/cli/test/cases/build.default.ssr-prerender/src/pages/index.js
index fa3d8e447..06e33b925 100644
--- a/packages/cli/test/cases/build.default.ssr-prerender/src/pages/index.js
+++ b/packages/cli/test/cases/build.default.ssr-prerender/src/pages/index.js
@@ -1,7 +1,10 @@
+import '../components/social-links.js';
+
export default class HomePage extends HTMLElement {
connectedCallback() {
this.innerHTML = `
This is the home page.
+
`;
}
}
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.ssr-static-export/build.default.ssr-static-export.spec.js b/packages/cli/test/cases/build.default.ssr-static-export/build.default.ssr-static-export.spec.js
index 566348c5c..762f5fe1d 100644
--- a/packages/cli/test/cases/build.default.ssr-static-export/build.default.ssr-static-export.spec.js
+++ b/packages/cli/test/cases/build.default.ssr-static-export/build.default.ssr-static-export.spec.js
@@ -18,7 +18,7 @@
* footer.js
* pages/
* artists.js
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
diff --git a/packages/cli/test/cases/build.default.ssr-static-export/src/templates/app.html b/packages/cli/test/cases/build.default.ssr-static-export/src/layouts/app.html
similarity index 100%
rename from packages/cli/test/cases/build.default.ssr-static-export/src/templates/app.html
rename to packages/cli/test/cases/build.default.ssr-static-export/src/layouts/app.html
diff --git a/packages/cli/test/cases/build.default.ssr-static-export/src/pages/artists.js b/packages/cli/test/cases/build.default.ssr-static-export/src/pages/artists.js
index 47d510d6f..8a80b59ad 100644
--- a/packages/cli/test/cases/build.default.ssr-static-export/src/pages/artists.js
+++ b/packages/cli/test/cases/build.default.ssr-static-export/src/pages/artists.js
@@ -1,4 +1,4 @@
-async function getTemplate(compilation, { route }) {
+async function getLayout(compilation, { route }) {
return `
@@ -85,7 +85,7 @@ async function getFrontmatter() {
export const prerender = true;
export {
- getTemplate,
+ getLayout,
getBody,
getFrontmatter
};
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.title/build.default.title.spec.js b/packages/cli/test/cases/build.default.title/build.default.title.spec.js
index 6a755bac1..787ef2693 100644
--- a/packages/cli/test/cases/build.default.title/build.default.title.spec.js
+++ b/packages/cli/test/cases/build.default.title/build.default.title.spec.js
@@ -1,6 +1,6 @@
/*
* Use Case
- * Run Greenwood and tests for correct `` tag merging for pages and templates.
+ * Run Greenwood and tests for correct `` tag merging for pages and layouts.
*
* User Result
* Should generate a bare bones Greenwood build with expected values.
@@ -17,7 +17,7 @@
* pages/
* index.md
* hello.md
- * templates/
+ * layouts/
* page.html
*/
import fs from 'fs';
diff --git a/packages/cli/test/cases/build.default.title/src/templates/page.html b/packages/cli/test/cases/build.default.title/src/layouts/page.html
similarity index 100%
rename from packages/cli/test/cases/build.default.title/src/templates/page.html
rename to packages/cli/test/cases/build.default.title/src/layouts/page.html
diff --git a/packages/cli/test/cases/build.default.workspace-404-markdown/build.default.workspace-404-markdown.spec.js b/packages/cli/test/cases/build.default.workspace-404-markdown/build.default.workspace-404-markdown.spec.js
index 2084a4b79..fadc6d86e 100644
--- a/packages/cli/test/cases/build.default.workspace-404-markdown/build.default.workspace-404-markdown.spec.js
+++ b/packages/cli/test/cases/build.default.workspace-404-markdown/build.default.workspace-404-markdown.spec.js
@@ -1,9 +1,9 @@
/*
* Use Case
- * Run Greenwood build command with no config and custom 404 page in markldown with custom frontmatter exports (and app) template.
+ * Run Greenwood build command with no config and custom 404 page in markldown with custom frontmatter exports (and app) layout.
*
* User Result
- * Should generate a bare bones Greenwood build with custom page template.
+ * Should generate a bare bones Greenwood build with custom page layout.
*
* User Command
* greenwood build
@@ -21,7 +21,7 @@
* styles/
* 404.css
* theme.css
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
@@ -37,7 +37,7 @@ import { fileURLToPath, URL } from 'url';
const expect = chai.expect;
describe('Build Greenwood With: ', function() {
- const LABEL = 'Default Greenwood Configuration and Workspace w/Custom 404 Page in markdown and App Template';
+ const LABEL = 'Default Greenwood Configuration and Workspace w/Custom 404 Page in markdown and App Layout';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = fileURLToPath(new URL('.', import.meta.url));
let runner;
@@ -57,7 +57,7 @@ describe('Build Greenwood With: ', function() {
runSmokeTest(['public'], LABEL);
- describe('Custom 404 Page with App Template', function() {
+ describe('Custom 404 Page with App Layout', function() {
let dom;
let jsFiles;
let cssFiles;
@@ -95,16 +95,16 @@ describe('Build Greenwood With: ', function() {
expect(linkTags.length).to.equal(2);
});
- it('should have 1 app template specific
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/app-layout-one.js b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/app-layout-one.js
new file mode 100644
index 000000000..1d334140e
--- /dev/null
+++ b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/app-layout-one.js
@@ -0,0 +1 @@
+export default 'app layout one';
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/app-layout-two.js b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/app-layout-two.js
new file mode 100644
index 000000000..01f87a29f
--- /dev/null
+++ b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/app-layout-two.js
@@ -0,0 +1 @@
+export default 'app layout two';
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/page-layout-one.js b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/page-layout-one.js
new file mode 100644
index 000000000..ebb68f447
--- /dev/null
+++ b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/page-layout-one.js
@@ -0,0 +1 @@
+export default 'page layout one';
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/page-layout-two.js b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/page-layout-two.js
new file mode 100644
index 000000000..fce7a1272
--- /dev/null
+++ b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/scripts/page-layout-two.js
@@ -0,0 +1 @@
+export default 'page layout two';
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.workspace-template-page-and-app/src/styles/app-template-one.css b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/styles/app-layout-one.css
similarity index 100%
rename from packages/cli/test/cases/build.default.workspace-template-page-and-app/src/styles/app-template-one.css
rename to packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/styles/app-layout-one.css
diff --git a/packages/cli/test/cases/build.default.workspace-template-page-and-app/src/styles/app-template-two.css b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/styles/app-layout-two.css
similarity index 100%
rename from packages/cli/test/cases/build.default.workspace-template-page-and-app/src/styles/app-template-two.css
rename to packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/styles/app-layout-two.css
diff --git a/packages/cli/test/cases/build.default.workspace-template-page-and-app/src/styles/page-template-one.css b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/styles/page-layout-one.css
similarity index 100%
rename from packages/cli/test/cases/build.default.workspace-template-page-and-app/src/styles/page-template-one.css
rename to packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/styles/page-layout-one.css
diff --git a/packages/cli/test/cases/build.default.workspace-template-page-and-app/src/styles/page-template-two.css b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/styles/page-layout-two.css
similarity index 100%
rename from packages/cli/test/cases/build.default.workspace-template-page-and-app/src/styles/page-template-two.css
rename to packages/cli/test/cases/build.default.workspace-layouts-page-and-app/src/styles/page-layout-two.css
diff --git a/packages/cli/test/cases/build.default.workspace-template-page-bare-merging/build.default.workspace-template-page-bare-merging.spec.js b/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/build.default.workspace-layouts-page-bare-merging.spec.js
similarity index 95%
rename from packages/cli/test/cases/build.default.workspace-template-page-bare-merging/build.default.workspace-template-page-bare-merging.spec.js
rename to packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/build.default.workspace-layouts-page-bare-merging.spec.js
index 35647d25d..efc58645f 100644
--- a/packages/cli/test/cases/build.default.workspace-template-page-bare-merging/build.default.workspace-template-page-bare-merging.spec.js
+++ b/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/build.default.workspace-layouts-page-bare-merging.spec.js
@@ -1,6 +1,6 @@
/*
* Use Case
- * Run Greenwood build command with no config and emplty page templates.
+ * Run Greenwood build command with no config and emplty page layouts.
*
* User Result
* Should generate a bare bones Greenwood build.
@@ -15,7 +15,7 @@
* src/
* pages/
* index.md
- * templates/
+ * layouts/
* page.html
*/
import chai from 'chai';
@@ -101,7 +101,7 @@ describe('Build Greenwood With: ', function() {
const h1 = dom.window.document.querySelectorAll('body h1');
expect(h1.length).to.be.equal(1);
- expect(h1[0].textContent).to.be.equal('Page Template Heading');
+ expect(h1[0].textContent).to.be.equal('Page Layout Heading');
});
it('should have expected h2 tag in the ', function() {
diff --git a/packages/cli/test/cases/build.default.workspace-template-page-bare-merging/src/templates/page.html b/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/layouts/page.html
similarity index 80%
rename from packages/cli/test/cases/build.default.workspace-template-page-bare-merging/src/templates/page.html
rename to packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/layouts/page.html
index cbc1b9124..515e26ec0 100644
--- a/packages/cli/test/cases/build.default.workspace-template-page-bare-merging/src/templates/page.html
+++ b/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/layouts/page.html
@@ -4,7 +4,7 @@
-
Page Template Heading
+
Page Layout Heading
diff --git a/packages/cli/test/cases/build.default.workspace-template-page-bare-merging/src/pages/index.md b/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/pages/index.md
similarity index 100%
rename from packages/cli/test/cases/build.default.workspace-template-page-bare-merging/src/pages/index.md
rename to packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/pages/index.md
diff --git a/packages/cli/test/cases/build.default.workspace-template-page/build.default.workspace-template-page.spec.js b/packages/cli/test/cases/build.default.workspace-layouts-page/build.default.workspace-layouts-page.spec.js
similarity index 88%
rename from packages/cli/test/cases/build.default.workspace-template-page/build.default.workspace-template-page.spec.js
rename to packages/cli/test/cases/build.default.workspace-layouts-page/build.default.workspace-layouts-page.spec.js
index e7062b94d..6cce97f24 100644
--- a/packages/cli/test/cases/build.default.workspace-template-page/build.default.workspace-template-page.spec.js
+++ b/packages/cli/test/cases/build.default.workspace-layouts-page/build.default.workspace-layouts-page.spec.js
@@ -1,9 +1,9 @@
/*
* Use Case
- * Run Greenwood build command with no config and custom page template.
+ * Run Greenwood build command with no config and custom page layout.
*
* User Result
- * Should generate a bare bones Greenwood build with custom page template.
+ * Should generate a bare bones Greenwood build with custom page layout.
*
* User Command
* greenwood build
@@ -17,7 +17,7 @@
* main.js
* styles/
* theme.css
- * templates/
+ * layouts/
* page.html
*/
import chai from 'chai';
@@ -31,7 +31,7 @@ import { fileURLToPath, URL } from 'url';
const expect = chai.expect;
describe('Build Greenwood With: ', function() {
- const LABEL = 'Default Greenwood Configuration and Workspace w/Custom Page Template';
+ const LABEL = 'Default Greenwood Configuration and Workspace w/Custom Page Layout';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = fileURLToPath(new URL('.', import.meta.url));
let runner;
@@ -52,14 +52,14 @@ describe('Build Greenwood With: ', function() {
runSmokeTest(['public', 'index'], LABEL);
- describe('Custom Page Template', function() {
+ describe('Custom Page Layout', function() {
let dom;
before(async function() {
dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html'));
});
- describe('correct merge order for default app and custom page template tags', function() {
+ describe('correct merge order for default app and custom page layout tags', function() {
let scriptTags;
let linkTags;
let styleTags;
@@ -90,35 +90,35 @@ describe('Build Greenwood With: ', function() {
expect(styleTags.length).to.equal(1);
});
- it('should add one page template
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.workspace-templates-empty/src/scripts/main.js b/packages/cli/test/cases/build.default.workspace-templates-empty/src/scripts/main.js
deleted file mode 100644
index 9c4338f1e..000000000
--- a/packages/cli/test/cases/build.default.workspace-templates-empty/src/scripts/main.js
+++ /dev/null
@@ -1 +0,0 @@
-export default 'app template one';
\ No newline at end of file
diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/build.default.workspace-user-directory-mapping.spec.js b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/build.default.workspace-user-directory-mapping.spec.js
index 0d6a88532..a5a71dce6 100644
--- a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/build.default.workspace-user-directory-mapping.spec.js
+++ b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/build.default.workspace-user-directory-mapping.spec.js
@@ -27,7 +27,7 @@
* pages/
* pages.js
* components.js
- * templates/
+ * layouts/
* page.html
*/
import chai from 'chai';
diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/templates/page.html b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/layouts/page.html
similarity index 100%
rename from packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/templates/page.html
rename to packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/layouts/page.html
diff --git a/packages/cli/test/cases/build.default/build.default.spec.js b/packages/cli/test/cases/build.default/build.default.spec.js
index 7eb653cb2..4fabaad35 100644
--- a/packages/cli/test/cases/build.default/build.default.spec.js
+++ b/packages/cli/test/cases/build.default/build.default.spec.js
@@ -102,14 +102,6 @@ describe('Build Greenwood With: ', function() {
done();
});
});
-
- describe('default content', function() {
- it('should have the expected heading text within the index page in the public directory', function() {
- const heading = dom.window.document.querySelector('body h1').textContent;
-
- expect(heading).to.equal('Welcome to Greenwood!');
- });
- });
});
describe('Default output for 404.html', function() {
diff --git a/packages/cli/test/cases/build.plugins.adapter/build.config.plugins-adapter.spec.js b/packages/cli/test/cases/build.plugins.adapter/build.config.plugins-adapter.spec.js
index c3fd39b24..2b78f563e 100644
--- a/packages/cli/test/cases/build.plugins.adapter/build.config.plugins-adapter.spec.js
+++ b/packages/cli/test/cases/build.plugins.adapter/build.config.plugins-adapter.spec.js
@@ -21,12 +21,12 @@
*
* Custom Workspace
* src/
- * api/
- * greeting.js
- * pages/
- * index.js
* components/
* card.js
+ * pages/
+ * api/
+ * greeting.js
+ * index.js
*/
import chai from 'chai';
import path from 'path';
diff --git a/packages/cli/test/cases/build.plugins.adapter/src/api/greeting.js b/packages/cli/test/cases/build.plugins.adapter/src/pages/api/greeting.js
similarity index 100%
rename from packages/cli/test/cases/build.plugins.adapter/src/api/greeting.js
rename to packages/cli/test/cases/build.plugins.adapter/src/pages/api/greeting.js
diff --git a/packages/cli/test/cases/build.plugins.context/build.plugins.context.spec.js b/packages/cli/test/cases/build.plugins.context/build.plugins.context.spec.js
index 457e18c19..ca44520ab 100644
--- a/packages/cli/test/cases/build.plugins.context/build.plugins.context.spec.js
+++ b/packages/cli/test/cases/build.plugins.context/build.plugins.context.spec.js
@@ -1,9 +1,9 @@
/*
* Use Case
- * Build with Greenwood when using a custom context plugin (e.g. installed via npm) that provides custom templates (app / page) and resources (JS / CSS); aka a "theme pack".
+ * Build with Greenwood when using a custom context plugin (e.g. installed via npm) that provides custom layouts (app / page) and resources (JS / CSS); aka a "theme pack".
*
* User Result
- * Should generate a bare bones Greenwood build with expected templates being used from node_modules along with JS and CSS.
+ * Should generate a bare bones Greenwood build with expected layouts being used from node_modules along with JS and CSS.
*
* User Command
* greenwood build
@@ -47,9 +47,9 @@ describe('Build Greenwood With: ', function() {
before(async function() {
// copy fixtures into node_modules
// to match the location specified in the plugin under test
- const themePacktemplates = await getDependencyFiles(
- `${outputPath}/fixtures/layouts/*.html`,
- `${outputPath}/node_modules/my-theme-pack/dist/layouts`
+ const themePackLayouts = await getDependencyFiles(
+ `${outputPath}/fixtures/my-layouts/*.html`,
+ `${outputPath}/node_modules/my-theme-pack/dist/my-layouts`
);
const themePackStyles = await getDependencyFiles(
`${outputPath}/fixtures/styles/*.css`,
@@ -62,7 +62,7 @@ describe('Build Greenwood With: ', function() {
runner.setup(outputPath, [
...getSetupFiles(outputPath),
- ...themePacktemplates,
+ ...themePackLayouts,
...themePackStyles,
...themePackComponents
]);
@@ -71,7 +71,7 @@ describe('Build Greenwood With: ', function() {
runSmokeTest(['public', 'index'], LABEL);
- describe('Custom Default App and Page Templates', function() {
+ describe('Custom Default App and Page Layout', function() {
let dom;
before(async function() {
@@ -79,15 +79,15 @@ describe('Build Greenwood With: ', function() {
});
it('should have expected text from from a mock package layout/app.html in node_modules/', function() {
- const pageTemplateHeading = dom.window.document.querySelectorAll('body h1')[0];
+ const pageLayoutHeading = dom.window.document.querySelectorAll('body h1')[0];
- expect(pageTemplateHeading.textContent).to.be.equal('This is a custom app template from the custom layouts directory.');
+ expect(pageLayoutHeading.textContent).to.be.equal('This is a custom app layout from the custom layouts directory.');
});
it('should have expected text from from a mock package layout/page.html in node_modules/', function() {
- const pageTemplateHeading = dom.window.document.querySelectorAll('body h2')[0];
+ const pageLayoutHeading = dom.window.document.querySelectorAll('body h2')[0];
- expect(pageTemplateHeading.textContent).to.be.equal('This is a custom (default) page template from the custom layouts directory.');
+ expect(pageLayoutHeading.textContent).to.be.equal('This is a custom (default) page layout from the custom layouts directory.');
});
it('should have expected text from user workspace pages/index.md', function() {
@@ -99,7 +99,7 @@ describe('Build Greenwood With: ', function() {
});
});
- describe('Custom Title Page Template', function() {
+ describe('Custom Title Page Layout', function() {
let dom;
before(async function() {
@@ -107,15 +107,15 @@ describe('Build Greenwood With: ', function() {
});
it('should have expected text from from a mock package layout/app.html in node_modules/', function() {
- const pageTemplateHeading = dom.window.document.querySelectorAll('body h1')[0];
+ const pageLayoutHeading = dom.window.document.querySelectorAll('body h1')[0];
- expect(pageTemplateHeading.textContent).to.be.equal('This is a custom app template from the custom layouts directory.');
+ expect(pageLayoutHeading.textContent).to.be.equal('This is a custom app layout from the custom layouts directory.');
});
it('should have expected text from from a mock package layout/title.html in node_modules/', function() {
- const pageTemplateHeading = dom.window.document.querySelectorAll('body h2')[0];
+ const pageLayoutHeading = dom.window.document.querySelectorAll('body h2')[0];
- expect(pageTemplateHeading.textContent).to.be.equal('This is a custom page template called title from the layouts directory.');
+ expect(pageLayoutHeading.textContent).to.be.equal('This is a custom page layout called title from the layouts directory.');
});
it('should have expected text from user workspace pages/index.md', function() {
@@ -127,7 +127,7 @@ describe('Build Greenwood With: ', function() {
});
});
- describe('Custom Theme Pack theme.css in app template', function() {
+ describe('Custom Theme Pack theme.css in app layout', function() {
let dom;
before(async function() {
@@ -149,7 +149,7 @@ describe('Build Greenwood With: ', function() {
});
});
- describe('Custom Theme Pack greeting.js in custom title page template', function() {
+ describe('Custom Theme Pack greeting.js in custom title page layout', function() {
let dom;
before(async function() {
diff --git a/packages/cli/test/cases/build.plugins.context/fixtures/layouts/app.html b/packages/cli/test/cases/build.plugins.context/fixtures/my-layouts/app.html
similarity index 82%
rename from packages/cli/test/cases/build.plugins.context/fixtures/layouts/app.html
rename to packages/cli/test/cases/build.plugins.context/fixtures/my-layouts/app.html
index 69828b3cb..154129696 100644
--- a/packages/cli/test/cases/build.plugins.context/fixtures/layouts/app.html
+++ b/packages/cli/test/cases/build.plugins.context/fixtures/my-layouts/app.html
@@ -9,7 +9,7 @@
-
This is a custom app template from the custom layouts directory.
+
This is a custom app layout from the custom layouts directory.
diff --git a/packages/cli/test/cases/build.plugins.context/fixtures/layouts/page.html b/packages/cli/test/cases/build.plugins.context/fixtures/my-layouts/page.html
similarity index 55%
rename from packages/cli/test/cases/build.plugins.context/fixtures/layouts/page.html
rename to packages/cli/test/cases/build.plugins.context/fixtures/my-layouts/page.html
index f15c1960a..6acb0e3e6 100644
--- a/packages/cli/test/cases/build.plugins.context/fixtures/layouts/page.html
+++ b/packages/cli/test/cases/build.plugins.context/fixtures/my-layouts/page.html
@@ -2,7 +2,7 @@
-
This is a custom (default) page template from the custom layouts directory.
+
This is a custom (default) page layout from the custom layouts directory.
diff --git a/packages/cli/test/cases/develop.plugins.context/fixtures/layouts/title.html b/packages/cli/test/cases/build.plugins.context/fixtures/my-layouts/title.html
similarity index 72%
rename from packages/cli/test/cases/develop.plugins.context/fixtures/layouts/title.html
rename to packages/cli/test/cases/build.plugins.context/fixtures/my-layouts/title.html
index d0f96ecf5..e7b1cb140 100644
--- a/packages/cli/test/cases/develop.plugins.context/fixtures/layouts/title.html
+++ b/packages/cli/test/cases/build.plugins.context/fixtures/my-layouts/title.html
@@ -6,7 +6,7 @@
-
This is a custom page template called title from the layouts directory.
+
This is a custom page layout called title from the layouts directory.
diff --git a/packages/cli/test/cases/build.plugins.context/src/pages/slides/index.md b/packages/cli/test/cases/build.plugins.context/src/pages/slides/index.md
index fdd9da9b1..0f24fda7f 100644
--- a/packages/cli/test/cases/build.plugins.context/src/pages/slides/index.md
+++ b/packages/cli/test/cases/build.plugins.context/src/pages/slides/index.md
@@ -1,5 +1,5 @@
---
-template: 'title'
+layout: 'title'
---
### Title Page
diff --git a/packages/cli/test/cases/build.plugins.context/theme-pack-context-plugin.js b/packages/cli/test/cases/build.plugins.context/theme-pack-context-plugin.js
index 2227fbad2..15da0a215 100644
--- a/packages/cli/test/cases/build.plugins.context/theme-pack-context-plugin.js
+++ b/packages/cli/test/cases/build.plugins.context/theme-pack-context-plugin.js
@@ -7,13 +7,13 @@ const myThemePackPlugin = (options = {}) => [{
provider: () => {
const { name } = packageJson;
- const templateLocation = options.__isDevelopment // eslint-disable-line no-underscore-dangle
- ? new URL('./fixtures/layouts/', import.meta.url)
- : new URL(`./node_modules/${name}/dist/layouts/`, import.meta.url);
+ const layoutLocation = options.__isDevelopment // eslint-disable-line no-underscore-dangle
+ ? new URL('./fixtures/my-layouts/', import.meta.url)
+ : new URL(`./node_modules/${name}/dist/my-layouts/`, import.meta.url);
return {
- templates: [
- templateLocation
+ layouts: [
+ layoutLocation
]
};
}
diff --git a/packages/cli/test/cases/build.plugins.source/build.plugins-source.spec.js b/packages/cli/test/cases/build.plugins.source/build.plugins-source.spec.js
index 18dfb6461..258dc1c78 100644
--- a/packages/cli/test/cases/build.plugins.source/build.plugins-source.spec.js
+++ b/packages/cli/test/cases/build.plugins.source/build.plugins-source.spec.js
@@ -3,7 +3,7 @@
* Run Greenwood and get external custom resource plugin and default workspace.
*
* User Result
- * Should generate a bare bones Greenwood build with expected artists data as static files using a custom template.
+ * Should generate a bare bones Greenwood build with expected artists data as static files using a custom layout.
*
* User Command
* greenwood build
@@ -28,7 +28,7 @@
* pages/
* about.md
* index.md
- * templates/
+ * layouts/
* artist.html
*/
import chai from 'chai';
@@ -44,7 +44,7 @@ import { fileURLToPath, URL } from 'url';
const expect = chai.expect;
describe('Build Greenwood With: ', function() {
- const LABEL = 'Custom Sources Plugin and Custom Template';
+ const LABEL = 'Custom Sources Plugin and Custom Layout';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = fileURLToPath(new URL('.', import.meta.url));
const publicDir = path.join(outputPath, 'public');
@@ -110,7 +110,7 @@ describe('Build Greenwood With: ', function() {
expect(pages.length).to.equal(3);
});
- it('should have expected heading content for each artist page template', function() {
+ it('should have expected heading content for each artist page layout', function() {
doms.forEach((dom) => {
const headings = dom.window.document.querySelectorAll('body h1');
diff --git a/packages/cli/test/cases/build.plugins.source/greenwood.config.js b/packages/cli/test/cases/build.plugins.source/greenwood.config.js
index 807c59130..6487b68f7 100644
--- a/packages/cli/test/cases/build.plugins.source/greenwood.config.js
+++ b/packages/cli/test/cases/build.plugins.source/greenwood.config.js
@@ -19,7 +19,7 @@ const customExternalSourcesPlugin = {
`,
route,
id,
- template: 'artist',
+ layout: 'artist',
label: name,
data: {
imageUrl
diff --git a/packages/cli/test/cases/build.plugins.source/src/templates/artist.html b/packages/cli/test/cases/build.plugins.source/src/layouts/artist.html
similarity index 100%
rename from packages/cli/test/cases/build.plugins.source/src/templates/artist.html
rename to packages/cli/test/cases/build.plugins.source/src/layouts/artist.html
diff --git a/packages/cli/test/cases/develop.config.base-path/develop.config.base-path.spec.js b/packages/cli/test/cases/develop.config.base-path/develop.config.base-path.spec.js
index 916adbe78..89cc43120 100644
--- a/packages/cli/test/cases/develop.config.base-path/develop.config.base-path.spec.js
+++ b/packages/cli/test/cases/develop.config.base-path/develop.config.base-path.spec.js
@@ -20,13 +20,13 @@
*
* User Workspace
* src/
- * api/
- * greeting.js
* assets/
* logo.png
* components/
* card.js
* pages/
+ * api/
+ * greeting.js
* index.html
* users.js
* styles/
diff --git a/packages/cli/test/cases/develop.config.base-path/src/api/greeting.js b/packages/cli/test/cases/develop.config.base-path/src/pages/api/greeting.js
similarity index 100%
rename from packages/cli/test/cases/develop.config.base-path/src/api/greeting.js
rename to packages/cli/test/cases/develop.config.base-path/src/pages/api/greeting.js
diff --git a/packages/cli/test/cases/develop.default/develop.default.spec.js b/packages/cli/test/cases/develop.default/develop.default.spec.js
index 3958267f5..94cd73cd4 100644
--- a/packages/cli/test/cases/develop.default/develop.default.spec.js
+++ b/packages/cli/test/cases/develop.default/develop.default.spec.js
@@ -17,13 +17,6 @@
*
* User Workspace
* src/
- * api/
- * fragment.js
- * greeting.js
- * missing.js
- * nothing.js
- * submit-form-data.js
- * submit-json.js
* assets/
* data.json
* favicon.ico
@@ -38,7 +31,14 @@
* card.js
* header.js
* pages/
- * index.html
+ * api/
+ * fragment.js
+ * greeting.js
+ * missing.js
+ * nothing.js
+ * submit-form-data.js
+ * submit-json.js
+ * index.html
* styles/
* main.css
* package.json
diff --git a/packages/cli/test/cases/develop.default/src/api/fragment.js b/packages/cli/test/cases/develop.default/src/pages/api/fragment.js
similarity index 89%
rename from packages/cli/test/cases/develop.default/src/api/fragment.js
rename to packages/cli/test/cases/develop.default/src/pages/api/fragment.js
index ab5a5722c..2b55d86ac 100644
--- a/packages/cli/test/cases/develop.default/src/api/fragment.js
+++ b/packages/cli/test/cases/develop.default/src/pages/api/fragment.js
@@ -6,7 +6,7 @@ export async function handler(request) {
const { html } = await renderFromHTML(`
`, [
- new URL('../components/card.js', import.meta.url)
+ new URL('../../components/card.js', import.meta.url)
]);
return new Response(html, {
diff --git a/packages/cli/test/cases/develop.default/src/api/greeting.js b/packages/cli/test/cases/develop.default/src/pages/api/greeting.js
similarity index 100%
rename from packages/cli/test/cases/develop.default/src/api/greeting.js
rename to packages/cli/test/cases/develop.default/src/pages/api/greeting.js
diff --git a/packages/cli/test/cases/develop.default/src/api/missing.js b/packages/cli/test/cases/develop.default/src/pages/api/missing.js
similarity index 100%
rename from packages/cli/test/cases/develop.default/src/api/missing.js
rename to packages/cli/test/cases/develop.default/src/pages/api/missing.js
diff --git a/packages/cli/test/cases/develop.default/src/api/nothing.js b/packages/cli/test/cases/develop.default/src/pages/api/nothing.js
similarity index 100%
rename from packages/cli/test/cases/develop.default/src/api/nothing.js
rename to packages/cli/test/cases/develop.default/src/pages/api/nothing.js
diff --git a/packages/cli/test/cases/develop.default/src/api/submit-form-data.js b/packages/cli/test/cases/develop.default/src/pages/api/submit-form-data.js
similarity index 100%
rename from packages/cli/test/cases/develop.default/src/api/submit-form-data.js
rename to packages/cli/test/cases/develop.default/src/pages/api/submit-form-data.js
diff --git a/packages/cli/test/cases/develop.default/src/api/submit-json.js b/packages/cli/test/cases/develop.default/src/pages/api/submit-json.js
similarity index 100%
rename from packages/cli/test/cases/develop.default/src/api/submit-json.js
rename to packages/cli/test/cases/develop.default/src/pages/api/submit-json.js
diff --git a/packages/cli/test/cases/develop.plugins.context/develop.plugins.context.spec.js b/packages/cli/test/cases/develop.plugins.context/develop.plugins.context.spec.js
index 4c3aad577..444a64eb7 100644
--- a/packages/cli/test/cases/develop.plugins.context/develop.plugins.context.spec.js
+++ b/packages/cli/test/cases/develop.plugins.context/develop.plugins.context.spec.js
@@ -1,9 +1,9 @@
/*
* Use Case
- * Develop with Greenwood when using a custom context plugin (e.g. installed via npm) that provides custom templates (app / page) and resources (JS / CSS); aka a "theme pack".
+ * Develop with Greenwood when using a custom context plugin (e.g. installed via npm) that provides custom layouts (app / page) and resources (JS / CSS); aka a "theme pack".
*
* User Result
- * Should start development server with expected templates being used from node_modules along with JS and CSS.
+ * Should start development server with expected layouts being used from node_modules along with JS and CSS.
*
* User Command
* greenwood develop
@@ -76,16 +76,16 @@ describe('Develop Greenwood With: ', function() {
});
it('should have expected text from from a mock package layout/app.html in node_modules/', function(done) {
- const pageTemplateHeading = dom.window.document.querySelectorAll('body h1')[0];
+ const pageLayoutHeading = dom.window.document.querySelectorAll('body h1')[0];
- expect(pageTemplateHeading.textContent).to.be.equal('This is a custom app template from the custom layouts directory.');
+ expect(pageLayoutHeading.textContent).to.be.equal('This is a custom app layout from the custom layouts directory.');
done();
});
it('should have expected text from from a mock package layout/page.html in node_modules/', function(done) {
- const pageTemplateHeading = dom.window.document.querySelectorAll('body h2')[0];
+ const pageLayoutHeading = dom.window.document.querySelectorAll('body h2')[0];
- expect(pageTemplateHeading.textContent).to.be.equal('This is a custom (default) page template from the custom layouts directory.');
+ expect(pageLayoutHeading.textContent).to.be.equal('This is a custom (default) page layout from the custom layouts directory.');
done();
});
diff --git a/packages/cli/test/cases/develop.plugins.context/fixtures/layouts/app.html b/packages/cli/test/cases/develop.plugins.context/fixtures/my-layouts/app.html
similarity index 82%
rename from packages/cli/test/cases/develop.plugins.context/fixtures/layouts/app.html
rename to packages/cli/test/cases/develop.plugins.context/fixtures/my-layouts/app.html
index e1170c3c9..fc369371e 100644
--- a/packages/cli/test/cases/develop.plugins.context/fixtures/layouts/app.html
+++ b/packages/cli/test/cases/develop.plugins.context/fixtures/my-layouts/app.html
@@ -9,7 +9,7 @@
-
This is a custom app template from the custom layouts directory.
+
This is a custom app layout from the custom layouts directory.
diff --git a/packages/cli/test/cases/develop.plugins.context/fixtures/layouts/page.html b/packages/cli/test/cases/develop.plugins.context/fixtures/my-layouts/page.html
similarity index 55%
rename from packages/cli/test/cases/develop.plugins.context/fixtures/layouts/page.html
rename to packages/cli/test/cases/develop.plugins.context/fixtures/my-layouts/page.html
index f15c1960a..6acb0e3e6 100644
--- a/packages/cli/test/cases/develop.plugins.context/fixtures/layouts/page.html
+++ b/packages/cli/test/cases/develop.plugins.context/fixtures/my-layouts/page.html
@@ -2,7 +2,7 @@
-
This is a custom (default) page template from the custom layouts directory.
+
This is a custom (default) page layout from the custom layouts directory.
diff --git a/packages/cli/test/cases/build.plugins.context/fixtures/layouts/title.html b/packages/cli/test/cases/develop.plugins.context/fixtures/my-layouts/title.html
similarity index 72%
rename from packages/cli/test/cases/build.plugins.context/fixtures/layouts/title.html
rename to packages/cli/test/cases/develop.plugins.context/fixtures/my-layouts/title.html
index d0f96ecf5..e7b1cb140 100644
--- a/packages/cli/test/cases/build.plugins.context/fixtures/layouts/title.html
+++ b/packages/cli/test/cases/develop.plugins.context/fixtures/my-layouts/title.html
@@ -6,7 +6,7 @@
-
This is a custom page template called title from the layouts directory.
+
This is a custom page layout called title from the layouts directory.
diff --git a/packages/cli/test/cases/develop.plugins.context/src/pages/slides/index.md b/packages/cli/test/cases/develop.plugins.context/src/pages/slides/index.md
index fdd9da9b1..0f24fda7f 100644
--- a/packages/cli/test/cases/develop.plugins.context/src/pages/slides/index.md
+++ b/packages/cli/test/cases/develop.plugins.context/src/pages/slides/index.md
@@ -1,5 +1,5 @@
---
-template: 'title'
+layout: 'title'
---
### Title Page
diff --git a/packages/cli/test/cases/develop.ssr/develop.ssr.spec.js b/packages/cli/test/cases/develop.ssr/develop.ssr.spec.js
index 9a4628250..6ae34e4ff 100644
--- a/packages/cli/test/cases/develop.ssr/develop.ssr.spec.js
+++ b/packages/cli/test/cases/develop.ssr/develop.ssr.spec.js
@@ -21,7 +21,7 @@
* index.js
* artists.js
* post.js
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
@@ -142,7 +142,7 @@ describe('Develop Greenwood With: ', function() {
});
});
- describe('Develop command with HTML route response using getTemplate, getBody, getFrontmatter', function() {
+ describe('Develop command with HTML route response using getLayout, getBody, getFrontmatter', function() {
let response = {};
let dom;
let artistsPageGraphData;
diff --git a/packages/cli/test/cases/develop.ssr/src/templates/app.html b/packages/cli/test/cases/develop.ssr/src/layouts/app.html
similarity index 100%
rename from packages/cli/test/cases/develop.ssr/src/templates/app.html
rename to packages/cli/test/cases/develop.ssr/src/layouts/app.html
diff --git a/packages/cli/test/cases/develop.ssr/src/pages/artists.js b/packages/cli/test/cases/develop.ssr/src/pages/artists.js
index 300d509c3..5c7a58388 100644
--- a/packages/cli/test/cases/develop.ssr/src/pages/artists.js
+++ b/packages/cli/test/cases/develop.ssr/src/pages/artists.js
@@ -1,4 +1,4 @@
-async function getTemplate(compilation, { route }) {
+async function getLayout(compilation, { route }) {
return `
@@ -83,7 +83,7 @@ async function getFrontmatter(compilation, { route }) {
}
export {
- getTemplate,
+ getLayout,
getBody,
getFrontmatter
};
\ No newline at end of file
diff --git a/packages/cli/test/cases/loaders-build.plugins.resource-page/contact.bar b/packages/cli/test/cases/loaders-build.plugins.resource-page/contact.bar
new file mode 100644
index 000000000..616ee9eea
--- /dev/null
+++ b/packages/cli/test/cases/loaders-build.plugins.resource-page/contact.bar
@@ -0,0 +1,7 @@
+export default class ContactPage extends HTMLElement {
+ connectedCallback() {
+ this.innerHTML = `
+
Welcome to our Contact page!
+ `;
+ }
+}
\ No newline at end of file
diff --git a/packages/cli/test/cases/loaders-build.plugins.resource-page/greenwood.config.js b/packages/cli/test/cases/loaders-build.plugins.resource-page/greenwood.config.js
new file mode 100644
index 000000000..b395ac06a
--- /dev/null
+++ b/packages/cli/test/cases/loaders-build.plugins.resource-page/greenwood.config.js
@@ -0,0 +1,44 @@
+import fs from 'fs/promises';
+
+class FooResource {
+ constructor(compilation, options) {
+ this.compilation = compilation;
+ this.options = options;
+ this.servePage = options.servePage;
+
+ this.extensions = ['foo'];
+ this.contentType = 'text/javascript';
+ }
+
+ async shouldServe(url) {
+ return url.pathname.split('.').pop() === this.extensions[0] && this.servePage;
+ }
+
+ async serve(url) {
+ let body = await fs.readFile(url, 'utf-8');
+
+ body = body.replace(/interface (.*){(.*)}/s, '');
+
+ return new Response(body, {
+ headers: new Headers({
+ 'Content-Type': this.contentType
+ })
+ });
+ }
+}
+
+const greenwoodPluginFooResource = (options = {}) => {
+ return [{
+ type: 'resource',
+ name: 'plugin-import-foo:resource',
+ provider: (compilation) => new FooResource(compilation, options)
+ }];
+};
+
+export default {
+ plugins: [
+ greenwoodPluginFooResource({
+ servePage: 'static'
+ })
+ ]
+};
\ No newline at end of file
diff --git a/packages/cli/test/cases/loaders-build.plugins.resource-page/loaders-build.plugins.resource-page.spec.js b/packages/cli/test/cases/loaders-build.plugins.resource-page/loaders-build.plugins.resource-page.spec.js
new file mode 100644
index 000000000..a34dcf983
--- /dev/null
+++ b/packages/cli/test/cases/loaders-build.plugins.resource-page/loaders-build.plugins.resource-page.spec.js
@@ -0,0 +1,114 @@
+/*
+ * Use Case
+ * Run Greenwood with a custom resource plugin and default workspace with a custom page format.
+ *
+ * User Result
+ * Should generate a bare bones Greenwood build with expected custom file (.foo) behavior.
+ *
+ * User Command
+ * greenwood build
+ *
+ * User Config
+ * class FooResource extends ResourceInterface {
+ * // see complete implementation in the greenwood.config.js file used for this spec
+ * }
+ *
+ * {
+ * plugins: [{
+ * type: 'resource',
+ * name: 'plugin-foo',
+ * provider: (compilation, options) => new FooResource(compilation, options)
+ * }]
+ * }
+ *
+ * Custom Workspace
+ * src/
+ * pages/
+ * about.foo
+ * contact.bar
+ * index.html
+ */
+import chai from 'chai';
+import fs from 'fs';
+import glob from 'glob-promise';
+import path from 'path';
+import { getSetupFiles, getOutputTeardownFiles } from '../../../../../test/utils.js';
+import { Runner } from 'gallinago';
+import { fileURLToPath, URL } from 'url';
+
+const expect = chai.expect;
+
+describe('Build Greenwood With: ', function() {
+ const LABEL = 'Custom FooResource Plugin and Default Workspace';
+ const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
+ const outputPath = fileURLToPath(new URL('.', import.meta.url));
+ let runner;
+
+ before(function() {
+ this.context = {
+ publicDir: path.join(outputPath, 'public')
+ };
+ runner = new Runner();
+ });
+
+ describe(LABEL, function() {
+ before(function() {
+ runner.setup(outputPath, getSetupFiles(outputPath));
+ runner.runCommand(cliPath, 'build');
+ });
+
+ describe('Home Page', function() {
+ let homePage;
+
+ before(async function() {
+ homePage = await glob.promise(path.join(this.context.publicDir, 'index.html'));
+ });
+
+ it('should have expected text from from my-other-custom-file.foo in the script output file', function() {
+ const contents = fs.readFileSync(homePage[0], 'utf-8');
+
+ expect(contents).to.contain('My Foo Website');
+ });
+ });
+
+ describe('Custom Format Static About Page', function() {
+ let aboutPage;
+
+ before(async function() {
+ aboutPage = await glob.promise(path.join(this.context.publicDir, '*about/index.html'));
+ });
+
+ it('should have the expected JavaScript equivalent file in the output directory', function() {
+ expect(aboutPage).to.have.lengthOf(1);
+ });
+
+ it('should have expected text from from my-other-custom-file.foo in the script output file', function() {
+ const contents = fs.readFileSync(aboutPage[0], 'utf-8');
+
+ expect(contents).to.contain('Welcome to our About page!');
+ });
+ });
+
+ xdescribe('Custom Format Dynamic Contact Page', function() {
+ let aboutPage;
+
+ before(async function() {
+ aboutPage = await glob.promise(path.join(this.context.publicDir, 'contact.html'));
+ });
+
+ it('should have the expected JavaScript equivalent file in the output directory', function() {
+ expect(aboutPage).to.have.lengthOf(1);
+ });
+
+ it('should have expected text from from my-other-custom-file.foo in the script output file', function() {
+ const contents = fs.readFileSync(aboutPage[0], 'utf-8');
+
+ expect(contents).to.contain('Welcome to our About page!');
+ });
+ });
+ });
+
+ after(function() {
+ runner.teardown(getOutputTeardownFiles(outputPath));
+ });
+});
\ No newline at end of file
diff --git a/packages/cli/test/cases/loaders-build.plugins.resource-page/src/pages/about.foo b/packages/cli/test/cases/loaders-build.plugins.resource-page/src/pages/about.foo
new file mode 100644
index 000000000..eefbaecf0
--- /dev/null
+++ b/packages/cli/test/cases/loaders-build.plugins.resource-page/src/pages/about.foo
@@ -0,0 +1,5 @@
+
+
+
Welcome to our About page!
+
+
\ No newline at end of file
diff --git a/packages/cli/test/cases/loaders-build.plugins.resource-page/src/pages/index.html b/packages/cli/test/cases/loaders-build.plugins.resource-page/src/pages/index.html
new file mode 100644
index 000000000..2129f92e7
--- /dev/null
+++ b/packages/cli/test/cases/loaders-build.plugins.resource-page/src/pages/index.html
@@ -0,0 +1,8 @@
+
+
+
+
+
My Foo Website
+
+
+
\ No newline at end of file
diff --git a/packages/cli/test/cases/loaders-develop.ssr-import-attributes/loaders-develop.ssr-import-attributes.spec.js b/packages/cli/test/cases/loaders-develop.ssr-import-attributes/loaders-develop.ssr-import-attributes.spec.js
index 4e8ba8745..35b22a8f6 100644
--- a/packages/cli/test/cases/loaders-develop.ssr-import-attributes/loaders-develop.ssr-import-attributes.spec.js
+++ b/packages/cli/test/cases/loaders-develop.ssr-import-attributes/loaders-develop.ssr-import-attributes.spec.js
@@ -13,14 +13,14 @@
*
* User Workspace
* src/
- * api/
- * fragment.js
* components/
* card/
* card.css
* card.js
* card.json
* pages/
+ * api/
+ * fragment.js
* greeting.js
*
*/
diff --git a/packages/cli/test/cases/loaders-develop.ssr-import-attributes/src/api/fragment.js b/packages/cli/test/cases/loaders-develop.ssr-import-attributes/src/pages/api/fragment.js
similarity index 87%
rename from packages/cli/test/cases/loaders-develop.ssr-import-attributes/src/api/fragment.js
rename to packages/cli/test/cases/loaders-develop.ssr-import-attributes/src/pages/api/fragment.js
index a37a035db..bf6340b9c 100644
--- a/packages/cli/test/cases/loaders-develop.ssr-import-attributes/src/api/fragment.js
+++ b/packages/cli/test/cases/loaders-develop.ssr-import-attributes/src/pages/api/fragment.js
@@ -6,7 +6,7 @@ export async function handler(request) {
const { html } = await renderFromHTML(`
`, [
- new URL('../components/card/card.js', import.meta.url)
+ new URL('../../components/card/card.js', import.meta.url)
]);
return new Response(html, {
diff --git a/packages/cli/test/cases/loaders-serve.default.ssr-import-attributes/loaders-serve.default.ssr-import-attributes.spec.js b/packages/cli/test/cases/loaders-serve.default.ssr-import-attributes/loaders-serve.default.ssr-import-attributes.spec.js
index 816e2ee91..f2b39177a 100644
--- a/packages/cli/test/cases/loaders-serve.default.ssr-import-attributes/loaders-serve.default.ssr-import-attributes.spec.js
+++ b/packages/cli/test/cases/loaders-serve.default.ssr-import-attributes/loaders-serve.default.ssr-import-attributes.spec.js
@@ -13,14 +13,14 @@
*
* User Workspace
* src/
- * api/
- * fragment.js
* components/
* card/
* card.css
* card.js
* card.json
* pages/
+ * api/
+ * fragment.js
* greeting.js
*
*/
diff --git a/packages/cli/test/cases/loaders-serve.default.ssr-import-attributes/src/api/fragment.js b/packages/cli/test/cases/loaders-serve.default.ssr-import-attributes/src/pages/api/fragment.js
similarity index 87%
rename from packages/cli/test/cases/loaders-serve.default.ssr-import-attributes/src/api/fragment.js
rename to packages/cli/test/cases/loaders-serve.default.ssr-import-attributes/src/pages/api/fragment.js
index a37a035db..bf6340b9c 100644
--- a/packages/cli/test/cases/loaders-serve.default.ssr-import-attributes/src/api/fragment.js
+++ b/packages/cli/test/cases/loaders-serve.default.ssr-import-attributes/src/pages/api/fragment.js
@@ -6,7 +6,7 @@ export async function handler(request) {
const { html } = await renderFromHTML(`
`, [
- new URL('../components/card/card.js', import.meta.url)
+ new URL('../../components/card/card.js', import.meta.url)
]);
return new Response(html, {
diff --git a/packages/cli/test/cases/serve.config.base-path/serve.config.base-path.spec.js b/packages/cli/test/cases/serve.config.base-path/serve.config.base-path.spec.js
index 74ed39f32..5782be9fd 100644
--- a/packages/cli/test/cases/serve.config.base-path/serve.config.base-path.spec.js
+++ b/packages/cli/test/cases/serve.config.base-path/serve.config.base-path.spec.js
@@ -16,13 +16,13 @@
*
* User Workspace
* src/
- * api/
- * greeting.js
* assets/
* logo.png
* components/
* card.js
* pages/
+ * api/
+ * greeting.js
* about.md
* index.html
* users.js
@@ -294,7 +294,7 @@ describe('Serve Greenwood With: ', function() {
.filter(tag => tag.getAttribute('data-gwd') === 'static-router');
expect(routerScriptTags.length).to.be.equal(1);
- expect(routerScriptTags[0].textContent.replace(/ /g, '').replace(/\n/g, '')).to.contain(`window.__greenwood=window.__greenwood||{};window.__greenwood.currentTemplate="${basePath}/"`);
+ expect(routerScriptTags[0].textContent.replace(/ /g, '').replace(/\n/g, '')).to.contain(`window.__greenwood=window.__greenwood||{};window.__greenwood.currentLayout="${basePath}/"`);
});
it('should have one tag in the for the content', function() {
@@ -316,7 +316,7 @@ describe('Serve Greenwood With: ', function() {
const dataset = aboutRouteTag[0].dataset;
expect(aboutRouteTag.length).to.be.equal(1);
- expect(dataset.template).to.be.equal('test');
+ expect(dataset.layout).to.be.equal('test');
expect(dataset.key).to.be.equal(`${basePath}/_routes/about/index.html`);
});
@@ -327,7 +327,7 @@ describe('Serve Greenwood With: ', function() {
const dataset = aboutRouteTag[0].dataset;
expect(aboutRouteTag.length).to.be.equal(1);
- expect(dataset.template).to.be.equal(`${basePath}/`);
+ expect(dataset.layout).to.be.equal(`${basePath}/`);
expect(dataset.key).to.be.equal(`${basePath}/_routes/index.html`);
});
diff --git a/packages/cli/test/cases/serve.config.base-path/src/pages/about.md b/packages/cli/test/cases/serve.config.base-path/src/pages/about.md
index b90299ace..5618aaa66 100644
--- a/packages/cli/test/cases/serve.config.base-path/src/pages/about.md
+++ b/packages/cli/test/cases/serve.config.base-path/src/pages/about.md
@@ -1,5 +1,5 @@
---
-template: test
+layout: test
---
### Greenwood
diff --git a/packages/cli/test/cases/serve.config.base-path/src/api/greeting.js b/packages/cli/test/cases/serve.config.base-path/src/pages/api/greeting.js
similarity index 100%
rename from packages/cli/test/cases/serve.config.base-path/src/api/greeting.js
rename to packages/cli/test/cases/serve.config.base-path/src/pages/api/greeting.js
diff --git a/packages/cli/test/cases/serve.config.static-router/src/pages/about.md b/packages/cli/test/cases/serve.config.static-router/src/pages/about.md
index b90299ace..5618aaa66 100644
--- a/packages/cli/test/cases/serve.config.static-router/src/pages/about.md
+++ b/packages/cli/test/cases/serve.config.static-router/src/pages/about.md
@@ -1,5 +1,5 @@
---
-template: test
+layout: test
---
### Greenwood
diff --git a/packages/cli/test/cases/serve.default.api/serve.default.api.spec.js b/packages/cli/test/cases/serve.default.api/serve.default.api.spec.js
index 979721912..440d40d0e 100644
--- a/packages/cli/test/cases/serve.default.api/serve.default.api.spec.js
+++ b/packages/cli/test/cases/serve.default.api/serve.default.api.spec.js
@@ -13,20 +13,20 @@
*
* User Workspace
* src/
- * api/
- * fragment.js (isolation mode)
- * greeting.js
- * missing.js
- * nothing.js
- * submit-form-data.js
- * submit-json.js
+ * pages/
+ * api/
+ * fragment.js (isolation mode)
+ * greeting.js
+ * missing.js
+ * nothing.js
+ * submit-form-data.js
+ * submit-json.js
* components/
* card.js
*/
import chai from 'chai';
import path from 'path';
import { getSetupFiles, getOutputTeardownFiles } from '../../../../../test/utils.js';
-import { runSmokeTest } from '../../../../../test/smoke-test.js';
import { Runner } from 'gallinago';
import { fileURLToPath, URL } from 'url';
@@ -61,8 +61,6 @@ describe('Serve Greenwood With: ', function() {
});
});
- runSmokeTest(['serve'], LABEL);
-
describe('Serve command with API specific behaviors for a JSON API', function() {
const name = 'Greenwood';
let response = {};
diff --git a/packages/cli/test/cases/serve.default.api/src/api/fragment.js b/packages/cli/test/cases/serve.default.api/src/pages/api/fragment.js
similarity index 89%
rename from packages/cli/test/cases/serve.default.api/src/api/fragment.js
rename to packages/cli/test/cases/serve.default.api/src/pages/api/fragment.js
index 992d3dd91..09159b287 100644
--- a/packages/cli/test/cases/serve.default.api/src/api/fragment.js
+++ b/packages/cli/test/cases/serve.default.api/src/pages/api/fragment.js
@@ -8,7 +8,7 @@ export async function handler(request) {
const { html } = await renderFromHTML(`
`, [
- new URL('../components/card.js', import.meta.url)
+ new URL('../../components/card.js', import.meta.url)
]);
return new Response(html, {
diff --git a/packages/cli/test/cases/serve.default.api/src/api/greeting.js b/packages/cli/test/cases/serve.default.api/src/pages/api/greeting.js
similarity index 100%
rename from packages/cli/test/cases/serve.default.api/src/api/greeting.js
rename to packages/cli/test/cases/serve.default.api/src/pages/api/greeting.js
diff --git a/packages/cli/test/cases/serve.default.api/src/api/missing.js b/packages/cli/test/cases/serve.default.api/src/pages/api/missing.js
similarity index 100%
rename from packages/cli/test/cases/serve.default.api/src/api/missing.js
rename to packages/cli/test/cases/serve.default.api/src/pages/api/missing.js
diff --git a/packages/cli/test/cases/serve.default.api/src/api/nothing.js b/packages/cli/test/cases/serve.default.api/src/pages/api/nothing.js
similarity index 100%
rename from packages/cli/test/cases/serve.default.api/src/api/nothing.js
rename to packages/cli/test/cases/serve.default.api/src/pages/api/nothing.js
diff --git a/packages/cli/test/cases/serve.default.api/src/api/submit-form-data.js b/packages/cli/test/cases/serve.default.api/src/pages/api/submit-form-data.js
similarity index 100%
rename from packages/cli/test/cases/serve.default.api/src/api/submit-form-data.js
rename to packages/cli/test/cases/serve.default.api/src/pages/api/submit-form-data.js
diff --git a/packages/cli/test/cases/serve.default.api/src/api/submit-json.js b/packages/cli/test/cases/serve.default.api/src/pages/api/submit-json.js
similarity index 100%
rename from packages/cli/test/cases/serve.default.api/src/api/submit-json.js
rename to packages/cli/test/cases/serve.default.api/src/pages/api/submit-json.js
diff --git a/packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/serve.default.ssr-prerender-api-hybrid.spec.js b/packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/serve.default.ssr-prerender-api-hybrid.spec.js
index db289fc24..2df272537 100644
--- a/packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/serve.default.ssr-prerender-api-hybrid.spec.js
+++ b/packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/serve.default.ssr-prerender-api-hybrid.spec.js
@@ -15,13 +15,13 @@
*
* User Workspace
* src/
- * api/
- * greeting.js
* components/
* footer.js
* pages/
+ * api/
+ * greeting.js
* index.js
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
diff --git a/packages/cli/test/cases/build.default.ssr-prerender/src/templates/app.html b/packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/src/layouts/app.html
similarity index 100%
rename from packages/cli/test/cases/build.default.ssr-prerender/src/templates/app.html
rename to packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/src/layouts/app.html
diff --git a/packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/src/api/greeting.js b/packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/src/pages/api/greeting.js
similarity index 100%
rename from packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/src/api/greeting.js
rename to packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/src/pages/api/greeting.js
diff --git a/packages/cli/test/cases/serve.default.ssr-prerender/serve.default.ssr-prerender.spec.js b/packages/cli/test/cases/serve.default.ssr-prerender/serve.default.ssr-prerender.spec.js
index 38c532601..eb5273a58 100644
--- a/packages/cli/test/cases/serve.default.ssr-prerender/serve.default.ssr-prerender.spec.js
+++ b/packages/cli/test/cases/serve.default.ssr-prerender/serve.default.ssr-prerender.spec.js
@@ -19,7 +19,7 @@
* footer.js
* pages/
* index.js
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
@@ -106,10 +106,10 @@ describe('Serve Greenwood With: ', function() {
expect(scriptFiles.length).to.equal(0);
});
- it('should have no _templates/ output directory for the app', async function() {
- const templateFiles = await glob.promise(path.join(this.context.publicDir, '_templates/*'));
+ it('should have no _layouts/ output directory for the app', async function() {
+ const layoutFiles = await glob.promise(path.join(this.context.publicDir, '_layouts/*'));
- expect(templateFiles.length).to.equal(0);
+ expect(layoutFiles.length).to.equal(0);
});
});
});
diff --git a/packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/src/templates/app.html b/packages/cli/test/cases/serve.default.ssr-prerender/src/layouts/app.html
similarity index 100%
rename from packages/cli/test/cases/serve.default.ssr-prerender-api-hybrid/src/templates/app.html
rename to packages/cli/test/cases/serve.default.ssr-prerender/src/layouts/app.html
diff --git a/packages/cli/test/cases/serve.default.ssr-static-export/serve.default.ssr-static-export.spec.js b/packages/cli/test/cases/serve.default.ssr-static-export/serve.default.ssr-static-export.spec.js
index 117e6ed62..094b00520 100644
--- a/packages/cli/test/cases/serve.default.ssr-static-export/serve.default.ssr-static-export.spec.js
+++ b/packages/cli/test/cases/serve.default.ssr-static-export/serve.default.ssr-static-export.spec.js
@@ -18,7 +18,7 @@
* footer.js
* pages/
* artists.js
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
@@ -175,7 +175,7 @@ describe('Serve Greenwood With: ', function() {
expect(styles.length).to.equal(1);
});
- it('should have four script tags', function() {
+ it('should have the expected number of script tags', function() {
const scripts = Array.from(dom.window.document.querySelectorAll('head script')).filter(tag => !tag.getAttribute('data-gwd'));
expect(scripts.length).to.equal(3);
diff --git a/packages/cli/test/cases/serve.default.ssr-static-export/src/templates/app.html b/packages/cli/test/cases/serve.default.ssr-static-export/src/layouts/app.html
similarity index 100%
rename from packages/cli/test/cases/serve.default.ssr-static-export/src/templates/app.html
rename to packages/cli/test/cases/serve.default.ssr-static-export/src/layouts/app.html
diff --git a/packages/cli/test/cases/serve.default.ssr-static-export/src/pages/artists.js b/packages/cli/test/cases/serve.default.ssr-static-export/src/pages/artists.js
index 47d510d6f..8a80b59ad 100644
--- a/packages/cli/test/cases/serve.default.ssr-static-export/src/pages/artists.js
+++ b/packages/cli/test/cases/serve.default.ssr-static-export/src/pages/artists.js
@@ -1,4 +1,4 @@
-async function getTemplate(compilation, { route }) {
+async function getLayout(compilation, { route }) {
return `
@@ -85,7 +85,7 @@ async function getFrontmatter() {
export const prerender = true;
export {
- getTemplate,
+ getLayout,
getBody,
getFrontmatter
};
\ No newline at end of file
diff --git a/packages/cli/test/cases/serve.default.ssr/serve.default.ssr.spec.js b/packages/cli/test/cases/serve.default.ssr/serve.default.ssr.spec.js
index 437d948ef..3fee021dc 100644
--- a/packages/cli/test/cases/serve.default.ssr/serve.default.ssr.spec.js
+++ b/packages/cli/test/cases/serve.default.ssr/serve.default.ssr.spec.js
@@ -29,7 +29,7 @@
* index.js
* post.js
* users.js (isolation = true)
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
@@ -155,7 +155,7 @@ describe('Serve Greenwood With: ', function() {
expect(scripts.length).to.equal(4);
});
- it('should have the expected tag from the app template in the ', function() {
+ it('should have the expected tag from the app layout in the ', function() {
const scripts = Array.from(dom.window.document.querySelectorAll('head > script'))
.filter(script => script.src && script.src.startsWith('/header.'));
@@ -221,7 +221,7 @@ describe('Serve Greenwood With: ', function() {
expect(imports[0]).to.equal('/components/counter.js');
});
- it('should append the expected graph resource scripts for the page from a template', function() {
+ it('should append the expected graph resource scripts for the page from a layout', function() {
const { resources } = artistsPageGraphData;
expect(resources.length).to.equal(6);
diff --git a/packages/cli/test/cases/serve.default.ssr/src/templates/app.html b/packages/cli/test/cases/serve.default.ssr/src/layouts/app.html
similarity index 100%
rename from packages/cli/test/cases/serve.default.ssr/src/templates/app.html
rename to packages/cli/test/cases/serve.default.ssr/src/layouts/app.html
diff --git a/packages/cli/test/cases/serve.default.ssr/src/pages/artists.js b/packages/cli/test/cases/serve.default.ssr/src/pages/artists.js
index 52b5981aa..d930eeb69 100644
--- a/packages/cli/test/cases/serve.default.ssr/src/pages/artists.js
+++ b/packages/cli/test/cases/serve.default.ssr/src/pages/artists.js
@@ -1,4 +1,4 @@
-async function getTemplate(compilation, { route }) {
+async function getLayout(compilation, { route }) {
return `
@@ -84,7 +84,7 @@ async function getFrontmatter(compilation, { route }) {
}
export {
- getTemplate,
+ getLayout,
getBody,
getFrontmatter
};
\ No newline at end of file
diff --git a/packages/cli/test/cases/serve.default/src/assets/router.js.map b/packages/cli/test/cases/serve.default/src/assets/router.js.map
index 59f99d8ee..4f7287179 100644
--- a/packages/cli/test/cases/serve.default/src/assets/router.js.map
+++ b/packages/cli/test/cases/serve.default/src/assets/router.js.map
@@ -1 +1 @@
-{"version":3,"file":"router.e74094cc.js","sources":["../packages/cli/src/lib/router.js"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\ndocument.addEventListener('click', function(e) {\n const href = (e.path && e.path[0]\n ? e.path[0].href // chrome + edge\n : e.originalTarget && e.originalTarget.href\n ? e.originalTarget.href // firefox\n : '') || '';\n // best case \"guess\" is that if the link originates on the current site when resolved by the browser\n // treat it as a client side route, ex: /about/, /docs/ and trigger the client side router\n // https://github.com/ProjectEvergreen/greenwood/issues/562\n const isOnCurrentDomain = href.indexOf(window.location.hostname) >= 0 || href.indexOf('localhost') >= 0;\n const canClientSideRoute = href !== '' && isOnCurrentDomain;\n\n if (canClientSideRoute) {\n e.preventDefault();\n \n const route = href.replace(window.location.origin, '');\n const routerOutlet = Array.from(document.getElementsByTagName('greenwood-route')).filter(outlet => {\n return outlet.getAttribute('data-route') === route;\n })[0];\n\n if (routerOutlet.getAttribute('data-template') === window.__greenwood.currentTemplate) {\n window.__greenwood.currentTemplate = routerOutlet.getAttribute('data-template');\n routerOutlet.loadRoute();\n } else {\n window.location.href = href;\n }\n }\n});\n\nclass RouteComponent extends HTMLElement {\n loadRoute() {\n const route = this.getAttribute('data-route');\n const key = this.getAttribute('data-key');\n \n fetch(key)\n .then(res => res.text())\n .then((response) => {\n history.pushState(response, route, route);\n document.getElementsByTagName('router-outlet')[0].innerHTML = response;\n });\n }\n}\n\nclass RouterOutletComponent extends HTMLElement { }\n\ncustomElements.define('greenwood-route', RouteComponent);\ncustomElements.define('router-outlet', RouterOutletComponent); "],"names":["document","addEventListener","e","href","path","originalTarget","isOnCurrentDomain","indexOf","window","location","hostname","preventDefault","route","replace","origin","routerOutlet","Array","from","getElementsByTagName","filter","outlet","getAttribute","__greenwood","currentTemplate","loadRoute","RouteComponent","HTMLElement","[object Object]","this","key","fetch","then","res","text","response","history","pushState","innerHTML","RouterOutletComponent","customElements","define"],"mappings":"AACAA,SAASC,iBAAiB,SAAS,SAASC,GAC1C,MAAMC,GAAQD,EAAEE,MAAQF,EAAEE,KAAK,GAC3BF,EAAEE,KAAK,GAAGD,KACVD,EAAEG,gBAAkBH,EAAEG,eAAeF,KACnCD,EAAEG,eAAeF,KACjB,KAAO,GAIPG,EAAoBH,EAAKI,QAAQC,OAAOC,SAASC,WAAa,GAAKP,EAAKI,QAAQ,cAAgB,EAGtG,GAFoC,KAATJ,GAAeG,EAElB,CACtBJ,EAAES,iBAEF,MAAMC,EAAQT,EAAKU,QAAQL,OAAOC,SAASK,OAAQ,IAC7CC,EAAeC,MAAMC,KAAKjB,SAASkB,qBAAqB,oBAAoBC,OAAOC,GAChFA,EAAOC,aAAa,gBAAkBT,GAC5C,GAECG,EAAaM,aAAa,mBAAqBb,OAAOc,YAAYC,iBACpEf,OAAOc,YAAYC,gBAAkBR,EAAaM,aAAa,iBAC/DN,EAAaS,aAEbhB,OAAOC,SAASN,KAAOA,MAK7B,MAAMsB,UAAuBC,YAC3BC,YACE,MAAMf,EAAQgB,KAAKP,aAAa,cAC1BQ,EAAMD,KAAKP,aAAa,YAE9BS,MAAMD,GACHE,KAAKC,GAAOA,EAAIC,QAChBF,KAAMG,IACLC,QAAQC,UAAUF,EAAUtB,EAAOA,GACnCZ,SAASkB,qBAAqB,iBAAiB,GAAGmB,UAAYH,KAKtE,MAAMI,UAA8BZ,aAEpCa,eAAeC,OAAO,kBAAmBf,GACzCc,eAAeC,OAAO,gBAAiBF"}
\ No newline at end of file
+{"version":3,"file":"router.e74094cc.js","sources":["../packages/cli/src/lib/router.js"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\ndocument.addEventListener('click', function(e) {\n const href = (e.path && e.path[0]\n ? e.path[0].href // chrome + edge\n : e.originalTarget && e.originalTarget.href\n ? e.originalTarget.href // firefox\n : '') || '';\n // best case \"guess\" is that if the link originates on the current site when resolved by the browser\n // treat it as a client side route, ex: /about/, /docs/ and trigger the client side router\n // https://github.com/ProjectEvergreen/greenwood/issues/562\n const isOnCurrentDomain = href.indexOf(window.location.hostname) >= 0 || href.indexOf('localhost') >= 0;\n const canClientSideRoute = href !== '' && isOnCurrentDomain;\n\n if (canClientSideRoute) {\n e.preventDefault();\n \n const route = href.replace(window.location.origin, '');\n const routerOutlet = Array.from(document.getElementsByTagName('greenwood-route')).filter(outlet => {\n return outlet.getAttribute('data-route') === route;\n })[0];\n\n if (routerOutlet.getAttribute('data-layout') === window.__greenwood.currentLayout) {\n window.__greenwood.currentLayout = routerOutlet.getAttribute('data-layout');\n routerOutlet.loadRoute();\n } else {\n window.location.href = href;\n }\n }\n});\n\nclass RouteComponent extends HTMLElement {\n loadRoute() {\n const route = this.getAttribute('data-route');\n const key = this.getAttribute('data-key');\n \n fetch(key)\n .then(res => res.text())\n .then((response) => {\n history.pushState(response, route, route);\n document.getElementsByTagName('router-outlet')[0].innerHTML = response;\n });\n }\n}\n\nclass RouterOutletComponent extends HTMLElement { }\n\ncustomElements.define('greenwood-route', RouteComponent);\ncustomElements.define('router-outlet', RouterOutletComponent); "],"names":["document","addEventListener","e","href","path","originalTarget","isOnCurrentDomain","indexOf","window","location","hostname","preventDefault","route","replace","origin","routerOutlet","Array","from","getElementsByTagName","filter","outlet","getAttribute","__greenwood","currentLayout","loadRoute","RouteComponent","HTMLElement","[object Object]","this","key","fetch","then","res","text","response","history","pushState","innerHTML","RouterOutletComponent","customElements","define"],"mappings":"AACAA,SAASC,iBAAiB,SAAS,SAASC,GAC1C,MAAMC,GAAQD,EAAEE,MAAQF,EAAEE,KAAK,GAC3BF,EAAEE,KAAK,GAAGD,KACVD,EAAEG,gBAAkBH,EAAEG,eAAeF,KACnCD,EAAEG,eAAeF,KACjB,KAAO,GAIPG,EAAoBH,EAAKI,QAAQC,OAAOC,SAASC,WAAa,GAAKP,EAAKI,QAAQ,cAAgB,EAGtG,GAFoC,KAATJ,GAAeG,EAElB,CACtBJ,EAAES,iBAEF,MAAMC,EAAQT,EAAKU,QAAQL,OAAOC,SAASK,OAAQ,IAC7CC,EAAeC,MAAMC,KAAKjB,SAASkB,qBAAqB,oBAAoBC,OAAOC,GAChFA,EAAOC,aAAa,gBAAkBT,GAC5C,GAECG,EAAaM,aAAa,mBAAqBb,OAAOc,YAAYC,iBACpEf,OAAOc,YAAYC,gBAAkBR,EAAaM,aAAa,iBAC/DN,EAAaS,aAEbhB,OAAOC,SAASN,KAAOA,MAK7B,MAAMsB,UAAuBC,YAC3BC,YACE,MAAMf,EAAQgB,KAAKP,aAAa,cAC1BQ,EAAMD,KAAKP,aAAa,YAE9BS,MAAMD,GACHE,KAAKC,GAAOA,EAAIC,QAChBF,KAAMG,IACLC,QAAQC,UAAUF,EAAUtB,EAAOA,GACnCZ,SAASkB,qBAAqB,iBAAiB,GAAGmB,UAAYH,KAKtE,MAAMI,UAA8BZ,aAEpCa,eAAeC,OAAO,kBAAmBf,GACzCc,eAAeC,OAAO,gBAAiBF"}
\ No newline at end of file
diff --git a/packages/cli/test/cases/theme-pack/my-theme-pack.js b/packages/cli/test/cases/theme-pack/my-theme-pack.js
index 745f70710..300e39c9f 100644
--- a/packages/cli/test/cases/theme-pack/my-theme-pack.js
+++ b/packages/cli/test/cases/theme-pack/my-theme-pack.js
@@ -5,13 +5,13 @@ const myThemePack = (options = {}) => [{
type: 'context',
name: `${packageJson.name}:context`,
provider: (compilation) => {
- const templateLocation = options.__isDevelopment // eslint-disable-line no-underscore-dangle
- ? new URL('./layouts/', compilation.context.userWorkspace)
- : new URL('./dist/layouts/', import.meta.url);
+ const layoutLocation = options.__isDevelopment // eslint-disable-line no-underscore-dangle
+ ? new URL('./my-layouts/', compilation.context.userWorkspace)
+ : new URL('./dist/my-layouts/', import.meta.url);
return {
- templates: [
- templateLocation
+ layouts: [
+ layoutLocation
]
};
}
diff --git a/packages/cli/test/cases/theme-pack/src/layouts/blog-post.html b/packages/cli/test/cases/theme-pack/src/my-layouts/blog-post.html
similarity index 79%
rename from packages/cli/test/cases/theme-pack/src/layouts/blog-post.html
rename to packages/cli/test/cases/theme-pack/src/my-layouts/blog-post.html
index 66790e89b..9c9f53bf1 100644
--- a/packages/cli/test/cases/theme-pack/src/layouts/blog-post.html
+++ b/packages/cli/test/cases/theme-pack/src/my-layouts/blog-post.html
@@ -8,7 +8,7 @@
-
This is the blog post template called from the layouts directory.
+
This is the blog post layout called from the layouts directory.
diff --git a/packages/cli/test/cases/theme-pack/src/pages/index.md b/packages/cli/test/cases/theme-pack/src/pages/index.md
index d740afc22..fe28153e0 100644
--- a/packages/cli/test/cases/theme-pack/src/pages/index.md
+++ b/packages/cli/test/cases/theme-pack/src/pages/index.md
@@ -1,5 +1,5 @@
---
-template: 'blog-post'
+layout: 'blog-post'
---
## Title of blog post
diff --git a/packages/cli/test/cases/theme-pack/theme-pack.build.spec.js b/packages/cli/test/cases/theme-pack/theme-pack.build.spec.js
index 81c9fce35..6dc377bec 100644
--- a/packages/cli/test/cases/theme-pack/theme-pack.build.spec.js
+++ b/packages/cli/test/cases/theme-pack/theme-pack.build.spec.js
@@ -4,7 +4,7 @@
* following the guide published on the Greenwood website. (https://www.greenwoodjs.io/guides/theme-packs/)
*
* User Result
- * Should correctly validate the develop and build / serve commands work correctly using tge expected templates
+ * Should correctly validate the develop and build / serve commands work correctly using tge expected layouts
* being resolved correctly per the known work around needs as documented in the FAQ and tracked in a discussion.
* https://github.com/ProjectEvergreen/greenwood/discussions/682
*
@@ -18,7 +18,7 @@
* src/
* components/
* header.js
- * layouts/
+ * my-layouts/
* blog-post.html
* pages/
* index.md
@@ -52,7 +52,7 @@ describe('Build Greenwood With: ', function() {
describe(LABEL, function() {
before(async function() {
- const themePacktemplates = await getDependencyFiles(
+ const themePackLayouts = await getDependencyFiles(
`${outputPath}/src/layouts/*.html`,
`${outputPath}/node_modules/my-theme-pack/dist/layouts`
);
@@ -67,7 +67,7 @@ describe('Build Greenwood With: ', function() {
runner.setup(outputPath, [
...getSetupFiles(outputPath),
- ...themePacktemplates,
+ ...themePackLayouts,
...themePackStyles,
...themePackComponents
]);
@@ -76,7 +76,7 @@ describe('Build Greenwood With: ', function() {
runSmokeTest(['public', 'index'], LABEL);
- describe('Custom Default App and Page Templates', function() {
+ describe('Custom Default App and Page Layout', function() {
let dom;
before(async function() {
@@ -84,9 +84,9 @@ describe('Build Greenwood With: ', function() {
});
it('should have expected text from layout/blog-post.html', function() {
- const pageTemplateHeading = dom.window.document.querySelectorAll('body h1')[0];
+ const pageLayoutHeading = dom.window.document.querySelectorAll('body h1')[0];
- expect(pageTemplateHeading.textContent).to.be.equal('This is the blog post template called from the layouts directory.');
+ expect(pageLayoutHeading.textContent).to.be.equal('This is the blog post layout called from the layouts directory.');
});
it('should have expected text from (test) user workspace pages/index.md', function() {
@@ -98,7 +98,7 @@ describe('Build Greenwood With: ', function() {
});
});
- describe('Custom Theme Pack theme.css in app template', function() {
+ describe('Custom Theme Pack theme.css in app layout', function() {
let dom;
before(async function() {
@@ -120,7 +120,7 @@ describe('Build Greenwood With: ', function() {
});
});
- describe('Custom Theme Pack heading.js in custom title page template', function() {
+ describe('Custom Theme Pack heading.js in custom title page layout', function() {
let dom;
before(async function() {
diff --git a/packages/cli/test/cases/theme-pack/theme-pack.develop.spec.js b/packages/cli/test/cases/theme-pack/theme-pack.develop.spec.js
index 5ad12fb19..03fcc44f5 100644
--- a/packages/cli/test/cases/theme-pack/theme-pack.develop.spec.js
+++ b/packages/cli/test/cases/theme-pack/theme-pack.develop.spec.js
@@ -4,7 +4,7 @@
* following the guide published on the Greenwood website. (https://www.greenwoodjs.io/guides/theme-packs/)
*
* User Result
- * Should correctly validate the develop and build / serve commands work correctly using tge expected templates
+ * Should correctly validate the develop and build / serve commands work correctly using tge expected layouts
* being resolved correctly per the known work around needs as documented in the FAQ and tracked in a discussion.
* https://github.com/ProjectEvergreen/greenwood/discussions/682
*
@@ -83,9 +83,9 @@ describe('Develop Greenwood With: ', function() {
});
it('should have expected text from from a mock package layouts/blog-post.html in the users workspace', function(done) {
- const pageTemplateHeading = dom.window.document.querySelectorAll('body h1')[0];
+ const pageLayoutHeading = dom.window.document.querySelectorAll('body h1')[0];
- expect(pageTemplateHeading.textContent).to.be.equal('This is the blog post template called from the layouts directory.');
+ expect(pageLayoutHeading.textContent).to.be.equal('This is the blog post layout called from the layouts directory.');
done();
});
diff --git a/packages/plugin-adapter-netlify/test/cases/build.config.base-path/build.config.base-path.spec.js b/packages/plugin-adapter-netlify/test/cases/build.config.base-path/build.config.base-path.spec.js
index 10c60f9ad..0f369a19b 100644
--- a/packages/plugin-adapter-netlify/test/cases/build.config.base-path/build.config.base-path.spec.js
+++ b/packages/plugin-adapter-netlify/test/cases/build.config.base-path/build.config.base-path.spec.js
@@ -21,9 +21,9 @@
* User Workspace
* package.json
* src/
- * api/
- * greeting.js
* pages/
+ * api/
+ * greeting.js
* users.js
*/
import chai from 'chai';
diff --git a/packages/plugin-adapter-netlify/test/cases/build.config.base-path/src/api/greeting.js b/packages/plugin-adapter-netlify/test/cases/build.config.base-path/src/pages/api/greeting.js
similarity index 100%
rename from packages/plugin-adapter-netlify/test/cases/build.config.base-path/src/api/greeting.js
rename to packages/plugin-adapter-netlify/test/cases/build.config.base-path/src/pages/api/greeting.js
diff --git a/packages/plugin-adapter-netlify/test/cases/build.default/build.default.spec.js b/packages/plugin-adapter-netlify/test/cases/build.default/build.default.spec.js
index 612b27d6d..b7d7e8142 100644
--- a/packages/plugin-adapter-netlify/test/cases/build.default/build.default.spec.js
+++ b/packages/plugin-adapter-netlify/test/cases/build.default/build.default.spec.js
@@ -20,15 +20,15 @@
* User Workspace
* package.json
* src/
- * api/
- * fragment.js
- * greeting.js
- * search.js
- * submit-form-data.js
- * submit-json.js
* components/
* card.js
* pages/
+ * api/
+ * fragment.js
+ * greeting.js
+ * search.js
+ * submit-form-data.js
+ * submit-json.js
* artists.js
* post.js
* users.js
diff --git a/packages/plugin-adapter-netlify/test/cases/build.default/src/api/fragment.js b/packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/fragment.js
similarity index 86%
rename from packages/plugin-adapter-netlify/test/cases/build.default/src/api/fragment.js
rename to packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/fragment.js
index c00251f91..77e026bdd 100644
--- a/packages/plugin-adapter-netlify/test/cases/build.default/src/api/fragment.js
+++ b/packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/fragment.js
@@ -1,5 +1,5 @@
import { renderFromHTML } from 'wc-compiler';
-import { getArtists } from '../services/artists.js';
+import { getArtists } from '../../services/artists.js';
export async function handler(request) {
const params = new URLSearchParams(request.url.slice(request.url.indexOf('?')));
@@ -20,7 +20,7 @@ export async function handler(request) {
}).join('')
}
`, [
- new URL('../components/card.js', import.meta.url)
+ new URL('../../components/card.js', import.meta.url)
]);
return new Response(html, { headers });
diff --git a/packages/plugin-adapter-vercel/test/cases/build.default/src/api/greeting.js b/packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/greeting.js
similarity index 87%
rename from packages/plugin-adapter-vercel/test/cases/build.default/src/api/greeting.js
rename to packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/greeting.js
index c5b2f9ded..9d0dbf598 100644
--- a/packages/plugin-adapter-vercel/test/cases/build.default/src/api/greeting.js
+++ b/packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/greeting.js
@@ -1,4 +1,4 @@
-import { getMessage } from '../services/message.js';
+import { getMessage } from '../../services/message.js';
export async function handler(request) {
const params = new URLSearchParams(request.url.slice(request.url.indexOf('?')));
diff --git a/packages/plugin-adapter-netlify/test/cases/build.default/src/api/search.js b/packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/search.js
similarity index 88%
rename from packages/plugin-adapter-netlify/test/cases/build.default/src/api/search.js
rename to packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/search.js
index 959eb2c22..1be8937dc 100644
--- a/packages/plugin-adapter-netlify/test/cases/build.default/src/api/search.js
+++ b/packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/search.js
@@ -1,5 +1,5 @@
import { renderFromHTML } from 'wc-compiler';
-import { getArtists } from '../services/artists.js';
+import { getArtists } from '../../services/artists.js';
export async function handler(request) {
const formData = await request.formData();
@@ -27,7 +27,7 @@ export async function handler(request) {
}).join('')
}
`, [
- new URL('../components/card.js', import.meta.url)
+ new URL('../../components/card.js', import.meta.url)
]);
body = html;
diff --git a/packages/plugin-adapter-netlify/test/cases/build.default/src/api/submit-form-data.js b/packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/submit-form-data.js
similarity index 100%
rename from packages/plugin-adapter-netlify/test/cases/build.default/src/api/submit-form-data.js
rename to packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/submit-form-data.js
diff --git a/packages/plugin-adapter-netlify/test/cases/build.default/src/api/submit-json.js b/packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/submit-json.js
similarity index 100%
rename from packages/plugin-adapter-netlify/test/cases/build.default/src/api/submit-json.js
rename to packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/submit-json.js
diff --git a/packages/plugin-adapter-vercel/test/cases/build.config.base-path/build.config.base-path.spec.js b/packages/plugin-adapter-vercel/test/cases/build.config.base-path/build.config.base-path.spec.js
index f48fd1eec..de0c1f59f 100644
--- a/packages/plugin-adapter-vercel/test/cases/build.config.base-path/build.config.base-path.spec.js
+++ b/packages/plugin-adapter-vercel/test/cases/build.config.base-path/build.config.base-path.spec.js
@@ -21,9 +21,9 @@
* User Workspace
* package.json
* src/
- * api/
- * greeting.js
* pages/
+ * api/
+ * greeting.js
* users.js
*/
import chai from 'chai';
diff --git a/packages/plugin-adapter-vercel/test/cases/build.config.base-path/src/api/greeting.js b/packages/plugin-adapter-vercel/test/cases/build.config.base-path/src/pages/api/greeting.js
similarity index 100%
rename from packages/plugin-adapter-vercel/test/cases/build.config.base-path/src/api/greeting.js
rename to packages/plugin-adapter-vercel/test/cases/build.config.base-path/src/pages/api/greeting.js
diff --git a/packages/plugin-adapter-vercel/test/cases/build.default/build.default.spec.js b/packages/plugin-adapter-vercel/test/cases/build.default/build.default.spec.js
index e4ddf27a2..328696267 100644
--- a/packages/plugin-adapter-vercel/test/cases/build.default/build.default.spec.js
+++ b/packages/plugin-adapter-vercel/test/cases/build.default/build.default.spec.js
@@ -20,15 +20,15 @@
* User Workspace
* package.json
* src/
- * api/
- * fragment.js
- * greeting.js
- * search.js
- * submit-form-data.js
- * submit-json.js
* components/
* card.js
* pages/
+ * api/
+ * fragment.js
+ * greeting.js
+ * search.js
+ * submit-form-data.js
+ * submit-json.js
* artists.js
* post.js
* users.js
diff --git a/packages/plugin-adapter-vercel/test/cases/build.default/src/api/fragment.js b/packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/fragment.js
similarity index 86%
rename from packages/plugin-adapter-vercel/test/cases/build.default/src/api/fragment.js
rename to packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/fragment.js
index c00251f91..77e026bdd 100644
--- a/packages/plugin-adapter-vercel/test/cases/build.default/src/api/fragment.js
+++ b/packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/fragment.js
@@ -1,5 +1,5 @@
import { renderFromHTML } from 'wc-compiler';
-import { getArtists } from '../services/artists.js';
+import { getArtists } from '../../services/artists.js';
export async function handler(request) {
const params = new URLSearchParams(request.url.slice(request.url.indexOf('?')));
@@ -20,7 +20,7 @@ export async function handler(request) {
}).join('')
}
`, [
- new URL('../components/card.js', import.meta.url)
+ new URL('../../components/card.js', import.meta.url)
]);
return new Response(html, { headers });
diff --git a/packages/plugin-adapter-netlify/test/cases/build.default/src/api/greeting.js b/packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/greeting.js
similarity index 87%
rename from packages/plugin-adapter-netlify/test/cases/build.default/src/api/greeting.js
rename to packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/greeting.js
index c5b2f9ded..9d0dbf598 100644
--- a/packages/plugin-adapter-netlify/test/cases/build.default/src/api/greeting.js
+++ b/packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/greeting.js
@@ -1,4 +1,4 @@
-import { getMessage } from '../services/message.js';
+import { getMessage } from '../../services/message.js';
export async function handler(request) {
const params = new URLSearchParams(request.url.slice(request.url.indexOf('?')));
diff --git a/packages/plugin-adapter-vercel/test/cases/build.default/src/api/search.js b/packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/search.js
similarity index 88%
rename from packages/plugin-adapter-vercel/test/cases/build.default/src/api/search.js
rename to packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/search.js
index 959eb2c22..1be8937dc 100644
--- a/packages/plugin-adapter-vercel/test/cases/build.default/src/api/search.js
+++ b/packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/search.js
@@ -1,5 +1,5 @@
import { renderFromHTML } from 'wc-compiler';
-import { getArtists } from '../services/artists.js';
+import { getArtists } from '../../services/artists.js';
export async function handler(request) {
const formData = await request.formData();
@@ -27,7 +27,7 @@ export async function handler(request) {
}).join('')
}
`, [
- new URL('../components/card.js', import.meta.url)
+ new URL('../../components/card.js', import.meta.url)
]);
body = html;
diff --git a/packages/plugin-adapter-vercel/test/cases/build.default/src/api/submit-form-data.js b/packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/submit-form-data.js
similarity index 100%
rename from packages/plugin-adapter-vercel/test/cases/build.default/src/api/submit-form-data.js
rename to packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/submit-form-data.js
diff --git a/packages/plugin-adapter-vercel/test/cases/build.default/src/api/submit-json.js b/packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/submit-json.js
similarity index 100%
rename from packages/plugin-adapter-vercel/test/cases/build.default/src/api/submit-json.js
rename to packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/submit-json.js
diff --git a/packages/plugin-graphql/README.md b/packages/plugin-graphql/README.md
index 243446981..290e682a9 100644
--- a/packages/plugin-graphql/README.md
+++ b/packages/plugin-graphql/README.md
@@ -67,7 +67,7 @@ class HeaderComponent extends HTMLElement {
this.root.innerHTML = this.getTemplate(navigation);
}
- getTemplate(navigation) {
+ getLayout(navigation) {
const navigationList = navigation.map((menuItem) => {
return `
diff --git a/packages/plugin-graphql/src/queries/children.gql b/packages/plugin-graphql/src/queries/children.gql
index 3336816fa..e544a0eaa 100644
--- a/packages/plugin-graphql/src/queries/children.gql
+++ b/packages/plugin-graphql/src/queries/children.gql
@@ -6,7 +6,7 @@ query($parent: String!) {
outputPath,
path,
route,
- template,
+ layout,
title
}
}
\ No newline at end of file
diff --git a/packages/plugin-graphql/src/queries/graph.gql b/packages/plugin-graphql/src/queries/graph.gql
index 57b0330d8..0b85879e7 100644
--- a/packages/plugin-graphql/src/queries/graph.gql
+++ b/packages/plugin-graphql/src/queries/graph.gql
@@ -6,7 +6,7 @@ query {
outputPath,
path,
route,
- template,
+ layout,
title
}
}
\ No newline at end of file
diff --git a/packages/plugin-graphql/src/schema/graph.js b/packages/plugin-graphql/src/schema/graph.js
index 0a7b0b616..8fbce7cab 100644
--- a/packages/plugin-graphql/src/schema/graph.js
+++ b/packages/plugin-graphql/src/schema/graph.js
@@ -112,7 +112,7 @@ const graphTypeDefs = gql`
path: String,
outputPath: String,
route: String,
- template: String,
+ layout: String,
title: String
}
diff --git a/packages/plugin-graphql/test/cases/query-graph/src/pages/blog/first-post.md b/packages/plugin-graphql/test/cases/query-graph/src/pages/blog/first-post.md
index 600ba45df..f80efd5f0 100644
--- a/packages/plugin-graphql/test/cases/query-graph/src/pages/blog/first-post.md
+++ b/packages/plugin-graphql/test/cases/query-graph/src/pages/blog/first-post.md
@@ -1,5 +1,5 @@
---
-template: 'blog'
+layout: 'blog'
date: '2020/04/05'
author: 'Lorum'
---
diff --git a/packages/plugin-graphql/test/cases/query-graph/src/pages/blog/second-post.md b/packages/plugin-graphql/test/cases/query-graph/src/pages/blog/second-post.md
index 833fe624c..adf272a15 100644
--- a/packages/plugin-graphql/test/cases/query-graph/src/pages/blog/second-post.md
+++ b/packages/plugin-graphql/test/cases/query-graph/src/pages/blog/second-post.md
@@ -1,5 +1,5 @@
---
-template: 'blog'
+layout: 'blog'
date: '2020/04/06'
author: 'Ipsum'
---
diff --git a/packages/plugin-graphql/test/cases/query-menu/query-menu.spec.js b/packages/plugin-graphql/test/cases/query-menu/query-menu.spec.js
index 0d3df4ca6..b6f5eb1af 100644
--- a/packages/plugin-graphql/test/cases/query-menu/query-menu.spec.js
+++ b/packages/plugin-graphql/test/cases/query-menu/query-menu.spec.js
@@ -21,7 +21,7 @@
* about.md
* contact.md
* index.md
- * templates/
+ * layouts/
* page.html
*/
import chai from 'chai';
diff --git a/packages/plugin-graphql/test/cases/query-menu/src/templates/page.html b/packages/plugin-graphql/test/cases/query-menu/src/layouts/page.html
similarity index 100%
rename from packages/plugin-graphql/test/cases/query-menu/src/templates/page.html
rename to packages/plugin-graphql/test/cases/query-menu/src/layouts/page.html
diff --git a/packages/plugin-graphql/test/unit/common.spec.js b/packages/plugin-graphql/test/unit/common.spec.js
index daafc6bbc..b50a96b44 100644
--- a/packages/plugin-graphql/test/unit/common.spec.js
+++ b/packages/plugin-graphql/test/unit/common.spec.js
@@ -19,14 +19,14 @@ describe('Unit Test: Data', function() {
route,
path,
filename,
- template,
+ layout,
__typename
}
}
`;
const hash = getQueryHash(query);
- expect(hash).to.be.equal('380713565');
+ expect(hash).to.be.equal('1291879437');
});
it('should return the expected hash for a custom graph query with custom data', function () {
@@ -56,7 +56,7 @@ describe('Unit Test: Data', function() {
route,
path,
filename,
- template
+ layout
}
}
`;
@@ -64,7 +64,7 @@ describe('Unit Test: Data', function() {
parent: '/docs/'
});
- expect(hash).to.be.equal('1696894039');
+ expect(hash).to.be.equal('2106154137');
});
});
diff --git a/packages/plugin-graphql/test/unit/mocks/graph.js b/packages/plugin-graphql/test/unit/mocks/graph.js
index 2b35d7489..9d15b7afb 100644
--- a/packages/plugin-graphql/test/unit/mocks/graph.js
+++ b/packages/plugin-graphql/test/unit/mocks/graph.js
@@ -12,7 +12,7 @@ const MOCK_GRAPH = {
id: "index",
label: "Index",
route: "/",
- template: "home",
+ layout: "home",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/index.md",
title: "",
@@ -73,7 +73,7 @@ const MOCK_GRAPH = {
id: "community",
label: "Community",
route: "/about/community",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/about/community.md",
title: "Community",
@@ -134,7 +134,7 @@ const MOCK_GRAPH = {
id: "features",
label: "Features",
route: "/about/features",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/about/features.md",
title: "Features",
@@ -195,7 +195,7 @@ const MOCK_GRAPH = {
id: "Goals",
label: "Goals",
route: "/about/goals",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/about/goals.md",
title: "Goals",
@@ -285,7 +285,7 @@ const MOCK_GRAPH = {
id: "how-it-works",
label: "How It Works",
route: "/about/how-it-works",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/about/how-it-works.md",
title: "How It Works",
@@ -346,7 +346,7 @@ const MOCK_GRAPH = {
id: "about",
label: "About",
route: "/about/",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/about/index.md",
title: "About",
@@ -407,7 +407,7 @@ const MOCK_GRAPH = {
id: "component-model",
label: "Component Model",
route: "/docs/component-model",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/docs/component-model.md",
title: "Component Model",
@@ -539,7 +539,7 @@ const MOCK_GRAPH = {
id: "configuration",
label: "Configuration",
route: "/docs/configuration",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/docs/configuration.md",
title: "Configuration",
@@ -643,7 +643,7 @@ const MOCK_GRAPH = {
id: "css-and-images",
label: "CSS and Images",
route: "/docs/css-and-images",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/docs/css-and-images.md",
title: "Styles and Assets",
@@ -845,7 +845,7 @@ const MOCK_GRAPH = {
id: "data-sources",
label: "Data Sources",
route: "/docs/data",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/docs/data.md",
fileName: "data",
@@ -932,8 +932,8 @@ const MOCK_GRAPH = {
seen: 1,
},
{
- content: "Template",
- slug: "template",
+ content: "Layout",
+ slug: "layout",
lvl: 3,
i: 5,
seen: 0,
@@ -979,7 +979,7 @@ const MOCK_GRAPH = {
id: "front-matter",
label: "Front Matter",
route: "/docs/front-matter",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/docs/front-matter.md",
title: "Front Matter",
@@ -1040,7 +1040,7 @@ const MOCK_GRAPH = {
id: "docs",
label: "Docs",
route: "/docs/",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/docs/index.md",
title: "Docs",
@@ -1097,22 +1097,22 @@ const MOCK_GRAPH = {
linkheadings: 3,
tableOfContents: [
{
- content: "Page Template",
- slug: "page-template",
+ content: "Page Layout",
+ slug: "page-layout",
lvl: 3,
i: 1,
seen: 0,
},
{
- content: "Template Hooks",
- slug: "template-hooks",
+ content: "Layout Hooks",
+ slug: "layout-hooks",
lvl: 4,
i: 2,
seen: 0,
},
{
- content: "App Template",
- slug: "app-template",
+ content: "App Layout",
+ slug: "app-layout",
lvl: 3,
i: 3,
seen: 0,
@@ -1127,13 +1127,13 @@ const MOCK_GRAPH = {
],
},
filename: "./docs/layouts.md",
- id: "templates",
- label: "Templates",
+ id: "layouts",
+ label: "Layouts",
route: "/docs/layouts",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/docs/layouts.md",
- title: "Templates and Pages",
+ title: "Layouts and Pages",
meta: [
{
name: "description",
@@ -1213,7 +1213,7 @@ const MOCK_GRAPH = {
id: "markdown",
label: "Markdown",
route: "/docs/markdown",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/docs/markdown.md",
title: "Markdown",
@@ -1303,7 +1303,7 @@ const MOCK_GRAPH = {
id: "menus",
label: "Menus",
route: "/docs/menus",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/docs/menus.md",
title: "Menus",
@@ -1393,7 +1393,7 @@ const MOCK_GRAPH = {
id: "tech-stack",
label: "Tech Stack",
route: "/docs/tech-stack",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/docs/tech-stack.md",
title: "Tech Stack",
@@ -1469,7 +1469,7 @@ const MOCK_GRAPH = {
id: "branding",
label: "Branding",
route: "/getting-started/branding",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/getting-started/branding.md",
title: "Styles and Web Components",
@@ -1530,7 +1530,7 @@ const MOCK_GRAPH = {
id: "build-and-deploy",
label: "Build And Deploy",
route: "/getting-started/build-and-deploy",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/getting-started/build-and-deploy.md",
title: "Build and Deploy",
@@ -1594,15 +1594,15 @@ const MOCK_GRAPH = {
seen: 0,
},
{
- content: "Home Page Template",
- slug: "home-page-template",
+ content: "Home Page Layout",
+ slug: "home-page-layout",
lvl: 3,
i: 2,
seen: 0,
},
{
- content: "Blog Posts Template",
- slug: "blog-posts-template",
+ content: "Blog Posts Layout",
+ slug: "blog-posts-layout",
lvl: 3,
i: 3,
seen: 0,
@@ -1627,7 +1627,7 @@ const MOCK_GRAPH = {
id: "creating-content",
label: "Creating Content",
route: "/getting-started/creating-content",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/getting-started/creating-content.md",
title: "Creating Content",
@@ -1688,7 +1688,7 @@ const MOCK_GRAPH = {
id: "getting-started",
label: "Getting Started",
route: "/getting-started/",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/getting-started/index.md",
title: "Getting Started",
@@ -1752,8 +1752,8 @@ const MOCK_GRAPH = {
seen: 0,
},
{
- content: "Templates",
- slug: "templates",
+ content: "Layouts",
+ slug: "layouts",
lvl: 3,
i: 2,
seen: 0,
@@ -1771,7 +1771,7 @@ const MOCK_GRAPH = {
id: "key-concepts",
label: "Key Concepts",
route: "/getting-started/key-concepts",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/getting-started/key-concepts.md",
title: "Key Concepts",
@@ -1832,7 +1832,7 @@ const MOCK_GRAPH = {
id: "next-steps",
label: "Next Steps",
route: "/getting-started/next-steps",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/getting-started/next-steps.md",
title: "Next Steps",
@@ -1915,7 +1915,7 @@ const MOCK_GRAPH = {
id: "project-setup",
label: "Project Setup",
route: "/getting-started/project-setup",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/getting-started/project-setup.md",
title: "Project Setup",
@@ -1976,7 +1976,7 @@ const MOCK_GRAPH = {
id: "quick-start",
label: "Quick Start",
route: "/getting-started/quick-start",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/getting-started/quick-start.md",
title: "Quick Start",
@@ -2037,7 +2037,7 @@ const MOCK_GRAPH = {
id: "composite-plugins",
label: "Composite Plugins",
route: "/plugins/composite-plugins",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/plugins/composite-plugins.md",
title: "Composite Plugins",
@@ -2098,7 +2098,7 @@ const MOCK_GRAPH = {
id: "index-hooks",
label: "Index Hooks",
route: "/plugins/index-hooks",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/plugins/index-hooks.md",
title: "Index Hooks",
@@ -2159,7 +2159,7 @@ const MOCK_GRAPH = {
id: "plugins",
label: "Plugins",
route: "/plugins/",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/plugins/index.md",
title: "Plugins",
@@ -2220,7 +2220,7 @@ const MOCK_GRAPH = {
id: "webpack",
label: "Webpack",
route: "/plugins/webpack",
- template: "page",
+ layout: "page",
path:
"/media/skynet/DATA/workspace/evergreen/greenwood/www/pages/plugins/webpack.md",
title: "Webpack Plugins",
diff --git a/packages/plugin-graphql/test/unit/schema/graph.menu.spec.js b/packages/plugin-graphql/test/unit/schema/graph.menu.spec.js
index 4c4dbd5c1..d1d6a2abd 100644
--- a/packages/plugin-graphql/test/unit/schema/graph.menu.spec.js
+++ b/packages/plugin-graphql/test/unit/schema/graph.menu.spec.js
@@ -118,8 +118,8 @@ describe('Unit Test: Data', function() {
it('should have the correct sub items', function() {
const subitem = shelf.children[2].children;
expect(subitem[0].item.label).to.be.equal('Objectives');
- expect(subitem[1].item.label).to.be.equal('Home Page Template');
- expect(subitem[2].item.label).to.be.equal('Blog Posts Template');
+ expect(subitem[1].item.label).to.be.equal('Home Page Layout');
+ expect(subitem[2].item.label).to.be.equal('Blog Posts Layout');
expect(subitem[3].item.label).to.be.equal('Creating Pages');
expect(subitem[4].item.label).to.be.equal('Development Server');
});
@@ -168,8 +168,8 @@ describe('Unit Test: Data', function() {
expect(subitem[0].item.label).to.be.equal('Workspace');
expect(subitem[0].item.route).to.be.equal('#workspace');
- expect(subitem[1].item.label).to.be.equal('Templates');
- expect(subitem[1].item.route).to.be.equal('#templates');
+ expect(subitem[1].item.label).to.be.equal('Layouts');
+ expect(subitem[1].item.route).to.be.equal('#layouts');
expect(subitem[2].item.label).to.be.equal('Pages');
expect(subitem[2].item.route).to.be.equal('#pages');
});
@@ -313,8 +313,8 @@ describe('Unit Test: Data', function() {
expect(subitem[0].item.label).to.be.equal('Workspace');
expect(subitem[0].item.route).to.be.equal('#workspace');
- expect(subitem[1].item.label).to.be.equal('Templates');
- expect(subitem[1].item.route).to.be.equal('#templates');
+ expect(subitem[1].item.label).to.be.equal('Layouts');
+ expect(subitem[1].item.route).to.be.equal('#layouts');
expect(subitem[2].item.label).to.be.equal('Pages');
expect(subitem[2].item.route).to.be.equal('#pages');
});
diff --git a/packages/plugin-graphql/test/unit/schema/graph.spec.js b/packages/plugin-graphql/test/unit/schema/graph.spec.js
index 2ee82467d..e387592bd 100644
--- a/packages/plugin-graphql/test/unit/schema/graph.spec.js
+++ b/packages/plugin-graphql/test/unit/schema/graph.spec.js
@@ -27,7 +27,7 @@ describe('Unit Test: Data', function() {
expect(page.id).to.exist;
expect(page.path).to.exist;
expect(page.filename).to.exist;
- expect(page.template).to.exist;
+ expect(page.layout).to.exist;
expect(page.title).to.exist;
expect(page.route).to.exist;
});
@@ -82,9 +82,9 @@ describe('Unit Test: Data', function() {
});
});
- it('should have "page" as the template for all children', function() {
+ it('should have "page" as the layout for all children', function() {
children.forEach(function(child) {
- expect(child.template).to.equal('page');
+ expect(child.layout).to.equal('page');
});
});
diff --git a/packages/plugin-import-css/test/cases/exp-build.prerender/exp-build.prerender.spec.js b/packages/plugin-import-css/test/cases/exp-build.prerender/exp-build.prerender.spec.js
index 659ffc324..6fb0dbbde 100644
--- a/packages/plugin-import-css/test/cases/exp-build.prerender/exp-build.prerender.spec.js
+++ b/packages/plugin-import-css/test/cases/exp-build.prerender/exp-build.prerender.spec.js
@@ -25,7 +25,7 @@
* footer.js
* pages/
* index.md
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
diff --git a/packages/plugin-import-css/test/cases/exp-build.prerender/src/templates/app.html b/packages/plugin-import-css/test/cases/exp-build.prerender/src/layouts/app.html
similarity index 100%
rename from packages/plugin-import-css/test/cases/exp-build.prerender/src/templates/app.html
rename to packages/plugin-import-css/test/cases/exp-build.prerender/src/layouts/app.html
diff --git a/packages/plugin-import-json/test/cases/exp-build.prerender/exp-build.prerender.spec.js b/packages/plugin-import-json/test/cases/exp-build.prerender/exp-build.prerender.spec.js
index 28bd48bff..313c57646 100644
--- a/packages/plugin-import-json/test/cases/exp-build.prerender/exp-build.prerender.spec.js
+++ b/packages/plugin-import-json/test/cases/exp-build.prerender/exp-build.prerender.spec.js
@@ -25,7 +25,7 @@
* footer.js
* pages/
* index.md
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
diff --git a/packages/plugin-import-json/test/cases/exp-build.prerender/src/templates/app.html b/packages/plugin-import-json/test/cases/exp-build.prerender/src/layouts/app.html
similarity index 100%
rename from packages/plugin-import-json/test/cases/exp-build.prerender/src/templates/app.html
rename to packages/plugin-import-json/test/cases/exp-build.prerender/src/layouts/app.html
diff --git a/packages/plugin-import-jsx/package.json b/packages/plugin-import-jsx/package.json
index 2827a7ed3..ad55ccf31 100644
--- a/packages/plugin-import-jsx/package.json
+++ b/packages/plugin-import-jsx/package.json
@@ -27,7 +27,7 @@
"@greenwood/cli": "^0.28.0-alpha.4"
},
"dependencies": {
- "wc-compiler": "~0.13.0"
+ "wc-compiler": "~0.14.0"
},
"devDependencies": {
"@greenwood/cli": "^0.30.0-alpha.2"
diff --git a/packages/plugin-import-jsx/test/cases/default/default.prerender.spec.js b/packages/plugin-import-jsx/test/cases/default/default.prerender.spec.js
index 167704f75..e9c2cc36f 100644
--- a/packages/plugin-import-jsx/test/cases/default/default.prerender.spec.js
+++ b/packages/plugin-import-jsx/test/cases/default/default.prerender.spec.js
@@ -24,7 +24,7 @@
* footer.jsx
* pages/
* index.md
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
diff --git a/packages/plugin-import-jsx/test/cases/default/src/templates/app.html b/packages/plugin-import-jsx/test/cases/default/src/layouts/app.html
similarity index 100%
rename from packages/plugin-import-jsx/test/cases/default/src/templates/app.html
rename to packages/plugin-import-jsx/test/cases/default/src/layouts/app.html
diff --git a/packages/plugin-import-jsx/test/cases/loaders-build.prerender/loaders-build.prerender.spec.js b/packages/plugin-import-jsx/test/cases/loaders-build.prerender/loaders-build.prerender.spec.js
index bcb0e615c..f821c42e0 100644
--- a/packages/plugin-import-jsx/test/cases/loaders-build.prerender/loaders-build.prerender.spec.js
+++ b/packages/plugin-import-jsx/test/cases/loaders-build.prerender/loaders-build.prerender.spec.js
@@ -25,7 +25,7 @@
* footer.jsx
* pages/
* index.md
- * templates/
+ * layouts/
* app.html
* main.js
*/
diff --git a/packages/plugin-import-jsx/test/cases/loaders-build.prerender/src/templates/app.html b/packages/plugin-import-jsx/test/cases/loaders-build.prerender/src/layouts/app.html
similarity index 100%
rename from packages/plugin-import-jsx/test/cases/loaders-build.prerender/src/templates/app.html
rename to packages/plugin-import-jsx/test/cases/loaders-build.prerender/src/layouts/app.html
diff --git a/packages/plugin-import-raw/test/cases/loaders-build.prerender/loaders-build.prerender.spec.js b/packages/plugin-import-raw/test/cases/loaders-build.prerender/loaders-build.prerender.spec.js
index ccbb5efe8..598e879fc 100644
--- a/packages/plugin-import-raw/test/cases/loaders-build.prerender/loaders-build.prerender.spec.js
+++ b/packages/plugin-import-raw/test/cases/loaders-build.prerender/loaders-build.prerender.spec.js
@@ -25,7 +25,7 @@
* footer.js
* pages/
* index.md
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
diff --git a/packages/plugin-import-raw/test/cases/loaders-build.prerender/src/templates/app.html b/packages/plugin-import-raw/test/cases/loaders-build.prerender/src/layouts/app.html
similarity index 100%
rename from packages/plugin-import-raw/test/cases/loaders-build.prerender/src/templates/app.html
rename to packages/plugin-import-raw/test/cases/loaders-build.prerender/src/layouts/app.html
diff --git a/packages/plugin-import-raw/test/cases/loaders-serve.ssr/loaders-serve.ssr.spec.js b/packages/plugin-import-raw/test/cases/loaders-serve.ssr/loaders-serve.ssr.spec.js
index 9c6c84a5e..c4465589f 100644
--- a/packages/plugin-import-raw/test/cases/loaders-serve.ssr/loaders-serve.ssr.spec.js
+++ b/packages/plugin-import-raw/test/cases/loaders-serve.ssr/loaders-serve.ssr.spec.js
@@ -17,12 +17,12 @@
*
* User Workspace
* src/
- * api/
- * fragment.js
* components/
* card.js
* card.css
* pages/
+ * api/
+ * fragment.js
* products.js
* services/
* products.js
diff --git a/packages/plugin-import-raw/test/cases/loaders-serve.ssr/src/api/fragment.js b/packages/plugin-import-raw/test/cases/loaders-serve.ssr/src/pages/api/fragment.js
similarity index 82%
rename from packages/plugin-import-raw/test/cases/loaders-serve.ssr/src/api/fragment.js
rename to packages/plugin-import-raw/test/cases/loaders-serve.ssr/src/pages/api/fragment.js
index af4ced829..8cb8aec37 100644
--- a/packages/plugin-import-raw/test/cases/loaders-serve.ssr/src/api/fragment.js
+++ b/packages/plugin-import-raw/test/cases/loaders-serve.ssr/src/pages/api/fragment.js
@@ -1,5 +1,5 @@
import { renderFromHTML } from 'wc-compiler';
-import { getProducts } from '../services/products.js';
+import { getProducts } from '../../services/products.js';
export async function handler() {
const products = await getProducts();
@@ -17,7 +17,7 @@ export async function handler() {
}).join('')
}
`, [
- new URL('../components/card.js', import.meta.url)
+ new URL('../../components/card.js', import.meta.url)
]);
return new Response(html, {
diff --git a/packages/plugin-renderer-lit/README.md b/packages/plugin-renderer-lit/README.md
index 8cb8e1ba6..d8dbe81c9 100644
--- a/packages/plugin-renderer-lit/README.md
+++ b/packages/plugin-renderer-lit/README.md
@@ -2,7 +2,7 @@
## Overview
-A Greenwood plugin for using [**Lit**'s SSR capabilities](https://github.com/lit/lit/tree/main/packages/labs/ssr) as a custom server-side renderer. Although support is experimental at this time, this plugin also gives the ability to statically render entire pages and templates to output completely static sites.
+A Greenwood plugin for using [**Lit**'s SSR capabilities](https://github.com/lit/lit/tree/main/packages/labs/ssr) as a custom server-side renderer. Although support is experimental at this time, this plugin also gives the ability to statically render entire pages and layouts to output completely static sites.
_We are still actively working on SSR features and enhancements for Greenwood [as part of our 1.0 release](https://github.com/ProjectEvergreen/greenwood/issues?q=is%3Aissue+is%3Aopen+label%3Assr+milestone%3A1.0) so please feel free to test it out and report your feedback._ 🙏
diff --git a/packages/plugin-renderer-lit/src/execute-route-module.js b/packages/plugin-renderer-lit/src/execute-route-module.js
index 4ef510635..fba4bb308 100644
--- a/packages/plugin-renderer-lit/src/execute-route-module.js
+++ b/packages/plugin-renderer-lit/src/execute-route-module.js
@@ -5,7 +5,7 @@ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
async function executeRouteModule({ moduleUrl, compilation, page, prerender, htmlContents, scripts }) {
const data = {
- template: null,
+ layout: null,
body: null,
frontmatter: null,
html: null,
@@ -23,7 +23,7 @@ async function executeRouteModule({ moduleUrl, compilation, page, prerender, htm
data.html = await collectResult(render(templateResult));
} else {
const module = await import(moduleUrl).then(module => module);
- const { getTemplate = null, getBody = null, getFrontmatter = null, isolation = true, hydration = true } = module;
+ const { getLayout = null, getBody = null, getFrontmatter = null, isolation = true, hydration = true } = module;
// TODO cant we get these from just pulling from the file during the graph phase?
// https://github.com/ProjectEvergreen/greenwood/issues/991
@@ -41,10 +41,10 @@ async function executeRouteModule({ moduleUrl, compilation, page, prerender, htm
data.body = await collectResult(render(templateResult));
}
- if (getTemplate) {
- const templateResult = await getTemplate(compilation, page);
+ if (getLayout) {
+ const templateResult = await getLayout(compilation, page);
- data.template = await collectResult(render(templateResult));
+ data.layout = await collectResult(render(templateResult));
}
if (getFrontmatter) {
diff --git a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/build.prerender.getting-started.spec.js b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/build.prerender.getting-started.spec.js
index 4c5455bcb..9fb196f3a 100644
--- a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/build.prerender.getting-started.spec.js
+++ b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/build.prerender.getting-started.spec.js
@@ -4,7 +4,7 @@
* Greenwood Getting Started repo.
*
* User Result
- * Should generate a bare bones Greenwood build with correctly templated out HTML from a LitElement.
+ * Should generate a bare bones Greenwood build with correctly layoutd out HTML from a LitElement.
*
* User Command
* greenwood build
@@ -34,7 +34,7 @@
* index.md
* styles/
* theme.css
- * templates/
+ * layouts/
* app.html
* blog.html
*/
diff --git a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/templates/blog.html b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/layouts/blog.html
similarity index 100%
rename from packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/templates/blog.html
rename to packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/layouts/blog.html
diff --git a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/templates/page.html b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/layouts/page.html
similarity index 100%
rename from packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/templates/page.html
rename to packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/layouts/page.html
diff --git a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/first-post.md b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/first-post.md
index f22e2ce8f..6b222d070 100644
--- a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/first-post.md
+++ b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/first-post.md
@@ -1,5 +1,5 @@
---
-template: 'blog'
+layout: 'blog'
---
## My First Blog Post
diff --git a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/second-post.md b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/second-post.md
index 02a7c548e..313dc1f59 100644
--- a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/second-post.md
+++ b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/second-post.md
@@ -1,5 +1,5 @@
---
-template: 'blog'
+layout: 'blog'
---
## My Second Blog Post
diff --git a/packages/plugin-renderer-lit/test/cases/serve.default/serve.default.spec.js b/packages/plugin-renderer-lit/test/cases/serve.default/serve.default.spec.js
index a43738ed2..e65bd24a9 100644
--- a/packages/plugin-renderer-lit/test/cases/serve.default/serve.default.spec.js
+++ b/packages/plugin-renderer-lit/test/cases/serve.default/serve.default.spec.js
@@ -21,16 +21,16 @@
*
* User Workspace
* src/
- * api/
- * search.js
* components/
* card.js
* footer.js
* greeting.js
* pages/
+ * api/
+ * search.js
* artists.js
* users.js (isolation = false)
- * templates/
+ * layouts/
* app.html
*/
import chai from 'chai';
@@ -195,8 +195,7 @@ describe('Serve Greenwood With: ', function() {
usersPageDom = new JSDOM(usersPageHtml);
});
- describe('Serve command with HTML route response using getBody, getTemplate and getFrontmatter for the artists page', function() {
-
+ describe('Serve command with HTML route response using getBody, getLayout and getFrontmatter for the artists page', function() {
it('should return a 200 status', function() {
expect(response.status).to.equal(200);
});
diff --git a/packages/plugin-renderer-lit/test/cases/serve.default/src/templates/app.html b/packages/plugin-renderer-lit/test/cases/serve.default/src/layouts/app.html
similarity index 100%
rename from packages/plugin-renderer-lit/test/cases/serve.default/src/templates/app.html
rename to packages/plugin-renderer-lit/test/cases/serve.default/src/layouts/app.html
diff --git a/packages/plugin-renderer-lit/test/cases/serve.default/src/api/search.js b/packages/plugin-renderer-lit/test/cases/serve.default/src/pages/api/search.js
similarity index 88%
rename from packages/plugin-renderer-lit/test/cases/serve.default/src/api/search.js
rename to packages/plugin-renderer-lit/test/cases/serve.default/src/pages/api/search.js
index 3000cc333..b46e724ac 100644
--- a/packages/plugin-renderer-lit/test/cases/serve.default/src/api/search.js
+++ b/packages/plugin-renderer-lit/test/cases/serve.default/src/pages/api/search.js
@@ -3,10 +3,10 @@ import { collectResultSync } from '@lit-labs/ssr/lib/render-result.js';
import fs from 'fs';
import { html } from 'lit';
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
-import '../components/card.js';
+import '../../components/card.js';
export async function handler(request) {
- const artists = JSON.parse(fs.readFileSync(new URL('../../artists.json', import.meta.url), 'utf-8'));
+ const artists = JSON.parse(fs.readFileSync(new URL('../../../artists.json', import.meta.url), 'utf-8'));
const formData = await request.formData();
const term = formData.has('term') ? formData.get('term') : '';
const filteredArtists = artists.filter((artist) => {
diff --git a/packages/plugin-renderer-lit/test/cases/serve.default/src/pages/artists.js b/packages/plugin-renderer-lit/test/cases/serve.default/src/pages/artists.js
index 58596191f..19c96e771 100644
--- a/packages/plugin-renderer-lit/test/cases/serve.default/src/pages/artists.js
+++ b/packages/plugin-renderer-lit/test/cases/serve.default/src/pages/artists.js
@@ -3,7 +3,7 @@ import { html } from 'lit';
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
import '../components/greeting.js';
-async function getTemplate(compilation, { route }) {
+async function getLayout(compilation, { route }) {
return html`
@@ -79,7 +79,7 @@ async function getFrontmatter(compilation, { route }) {
export const hydration = false;
export {
- getTemplate,
+ getLayout,
getBody,
getFrontmatter
};
\ No newline at end of file
diff --git a/packages/plugin-renderer-puppeteer/test/cases/build.default/build.default.spec.js b/packages/plugin-renderer-puppeteer/test/cases/build.default/build.default.spec.js
index e6876fd31..d9d1cc49c 100644
--- a/packages/plugin-renderer-puppeteer/test/cases/build.default/build.default.spec.js
+++ b/packages/plugin-renderer-puppeteer/test/cases/build.default/build.default.spec.js
@@ -246,12 +246,6 @@ describe('Build Greenwood With: ', function() {
});
});
- it('should have the expected heading text within the index page in the public directory', function() {
- const heading = dom.window.document.querySelector('body h1').textContent;
-
- expect(heading).to.equal('Welcome to Greenwood!');
- });
-
it('should contain the expected number of javascript files in the output directory', async function() {
expect(await glob.promise(path.join(this.context.publicDir, '*.js'))).to.have.lengthOf(3);
});
diff --git a/packages/plugin-typescript/README.md b/packages/plugin-typescript/README.md
index dcbce37b8..4722f84b4 100644
--- a/packages/plugin-typescript/README.md
+++ b/packages/plugin-typescript/README.md
@@ -1,15 +1,13 @@
# @greenwood/plugin-typescript
## Overview
+
A Greenwood plugin for writing [**TypeScript**](https://www.typescriptlang.org/). There is still a [little more work](https://github.com/ProjectEvergreen/greenwood/issues/658) we would like to do but this plugin should be suitable for general usage.
> This package assumes you already have `@greenwood/cli` installed.
-## Caveats
-
-As of now, this transformation is only supported for client side (browser) code and will not run correctly in NodeJS until [support for this is introduced into Greenwood](https://github.com/ProjectEvergreen/greenwood/issues/878), or natively by NodeJS. This means it will not work when using `prerender` option with WCC.
-
## Installation
+
You can use your favorite JavaScript package manager to install this package.
_examples:_
@@ -22,6 +20,7 @@ yarn add @greenwood/plugin-typescript --dev
```
## Usage
+
Add this plugin to your _greenwood.config.js_.
```javascript
@@ -36,7 +35,7 @@ export default {
};
```
-Then, you can write some TypeScript
+Then, you can write some TypeScript!
```ts
import { html, css, LitElement, customElement, property } from 'lit-element';
@@ -59,6 +58,9 @@ And use it in your project like you would use a _.js_ file!
```
## Options
+
+### Configuration
+
This plugin provides the following default `compilerOptions`.
```json
@@ -97,4 +99,22 @@ If you would like to extend / override these options:
};
```
-This will then process your JavaScript with TypeScript with the additional configuration settings you provide. This also allows you to configure the rest of _tsconfig.json_ to support your IDE and local development environment settings.
\ No newline at end of file
+This will then process your JavaScript with TypeScript with the additional configuration settings you provide. This also allows you to configure the rest of _tsconfig.json_ to support your IDE and local development environment settings.
+
+### Custom Pages
+
+By default, this plugin extends TypeScript support to processing SSR pages and API routes. If you would like to _disable_ this, set the `servePage` option to `false`
+
+```js
+import { greenwoodPluginTypeScript } from '@greenwood/plugin-typescript';
+
+export default {
+ // ...
+
+ plugins: [
+ greenwoodPluginTypeScript({
+ servePage: false
+ })
+ ]
+};
+```
\ No newline at end of file
diff --git a/packages/plugin-typescript/src/index.js b/packages/plugin-typescript/src/index.js
index 027a642c7..03290a498 100644
--- a/packages/plugin-typescript/src/index.js
+++ b/packages/plugin-typescript/src/index.js
@@ -29,6 +29,7 @@ class TypeScriptResource extends ResourceInterface {
constructor(compilation, options) {
super(compilation, options);
this.extensions = ['ts'];
+ this.servePage = options.servePage;
this.contentType = 'text/javascript';
}
@@ -54,7 +55,7 @@ class TypeScriptResource extends ResourceInterface {
}
}
-const greenwoodPluginTypeScript = (options = {}) => {
+const greenwoodPluginTypeScript = (options = { servePage: 'dynamic' }) => {
return [{
type: 'resource',
name: 'plugin-import-typescript:resource',
diff --git a/packages/plugin-typescript/test/cases/loaders-build.resource-page/greenwood.config.js b/packages/plugin-typescript/test/cases/loaders-build.resource-page/greenwood.config.js
new file mode 100644
index 000000000..efa8f4de6
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-build.resource-page/greenwood.config.js
@@ -0,0 +1,8 @@
+import { greenwoodPluginTypeScript } from '../../../src/index.js';
+
+export default {
+ prerender: true,
+ plugins: [
+ greenwoodPluginTypeScript()
+ ]
+};
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-build.resource-page/loaders-build.resource-page.spec.js b/packages/plugin-typescript/test/cases/loaders-build.resource-page/loaders-build.resource-page.spec.js
new file mode 100644
index 000000000..df3af219e
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-build.resource-page/loaders-build.resource-page.spec.js
@@ -0,0 +1,100 @@
+/*
+ * Use Case
+ * Run Greenwood with a dynamic page written in TypeScript.
+ *
+ * User Result
+ * Should generate a Greenwood build that correctly builds and bundles all assets.
+ *
+ * User Command
+ * greenwood build
+ *
+ * User Config
+ * {
+ * prerender: true,
+ * plugins: [
+ * greenwoodPluginTypeScript({
+ * servePage: 'dynamic'
+ * })
+ * ]
+ * }
+ *
+ * User Workspace
+ * src/
+ * components/
+ * greeting.ts
+ * pages/
+ * index.html
+ * about.ts
+ */
+import chai from 'chai';
+import fs from 'fs';
+import glob from 'glob-promise';
+import path from 'path';
+import { getSetupFiles, getOutputTeardownFiles } from '../../../../../test/utils.js';
+import { Runner } from 'gallinago';
+import { fileURLToPath, URL } from 'url';
+
+const expect = chai.expect;
+
+describe('Build Greenwood With: ', function() {
+ const LABEL = 'Custom TypeScript Plugin and Default Workspace serving a page';
+ const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
+ const outputPath = fileURLToPath(new URL('.', import.meta.url));
+ let runner;
+
+ before(function() {
+ this.context = {
+ publicDir: path.join(outputPath, 'public')
+ };
+ runner = new Runner(false, true);
+ });
+
+ describe(LABEL, function() {
+ before(function() {
+ runner.setup(outputPath, getSetupFiles(outputPath));
+ runner.runCommand(cliPath, 'build');
+ });
+
+ describe('Home Page', function() {
+ let homePage;
+
+ before(async function() {
+ homePage = await glob.promise(path.join(this.context.publicDir, 'index.html'));
+ });
+
+ it('should have expected text from from index.html in the script output file', function() {
+ const contents = fs.readFileSync(homePage[0], 'utf-8');
+
+ expect(contents).to.contain('My TS Website');
+ });
+ });
+
+ describe('Custom Format Dynamic About Page', function() {
+ let aboutPage;
+
+ before(async function() {
+ aboutPage = await glob.promise(path.join(this.context.publicDir, '*about/index.html'));
+ });
+
+ it('should have the expected page HTML file in the output directory', function() {
+ expect(aboutPage).to.have.lengthOf(1);
+ });
+
+ it('should have expected text from about.ts in the page output', function() {
+ const contents = fs.readFileSync(aboutPage[0], 'utf-8');
+
+ expect(contents).to.contain('Welcome to our About page!');
+ });
+
+ it('should have expected text from greeting.ts in the page output', function() {
+ const contents = fs.readFileSync(aboutPage[0], 'utf-8');
+
+ expect(contents).to.contain('
Hello About Page!
');
+ });
+ });
+ });
+
+ after(function() {
+ runner.teardown(getOutputTeardownFiles(outputPath));
+ });
+});
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-build.resource-page/src/components/greeting.ts b/packages/plugin-typescript/test/cases/loaders-build.resource-page/src/components/greeting.ts
new file mode 100644
index 000000000..54bb7609a
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-build.resource-page/src/components/greeting.ts
@@ -0,0 +1,17 @@
+interface User {
+ name: string;
+}
+
+export default class Greeting extends HTMLElement {
+ connectedCallback() {
+ const user: User = {
+ name: this.getAttribute('name') || 'World'
+ };
+
+ this.innerHTML = `
+
Hello ${user.name}!
+ `;
+ }
+}
+
+customElements.define('x-greeting', Greeting);
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-build.resource-page/src/pages/about.ts b/packages/plugin-typescript/test/cases/loaders-build.resource-page/src/pages/about.ts
new file mode 100644
index 000000000..dc93aa70e
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-build.resource-page/src/pages/about.ts
@@ -0,0 +1,10 @@
+import '../components/greeting.ts';
+
+export default class ContactPage extends HTMLElement {
+ connectedCallback() {
+ this.innerHTML = `
+
Welcome to our About page!
+
+ `;
+ }
+}
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-build.resource-page/src/pages/index.html b/packages/plugin-typescript/test/cases/loaders-build.resource-page/src/pages/index.html
new file mode 100644
index 000000000..5189eef7c
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-build.resource-page/src/pages/index.html
@@ -0,0 +1,8 @@
+
+
+
+
+
My TS Website
+
+
+
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-develop.ssr/greenwood.config.js b/packages/plugin-typescript/test/cases/loaders-develop.ssr/greenwood.config.js
new file mode 100644
index 000000000..ba7504106
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-develop.ssr/greenwood.config.js
@@ -0,0 +1,9 @@
+import { greenwoodPluginTypeScript } from '../../../src/index.js';
+
+export default {
+ plugins: [
+ greenwoodPluginTypeScript({
+ servePage: 'dynamic'
+ })
+ ]
+};
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-develop.ssr/loaders-develop.ssr.spec.js b/packages/plugin-typescript/test/cases/loaders-develop.ssr/loaders-develop.ssr.spec.js
new file mode 100644
index 000000000..9f73b52e5
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-develop.ssr/loaders-develop.ssr.spec.js
@@ -0,0 +1,140 @@
+/*
+ * Use Case
+ * Run Greenwood with an API and SSR routes that import TypeScript for development.
+ *
+ * User Result
+ * Should generate a Greenwood build that correctly runs in development mode.
+ *
+ * User Command
+ * greenwood build
+ *
+ * User Config
+ * {
+ * plugins: [
+ * greenwoodPluginTypeScript({
+ * servePages: 'dynamic'
+ * })
+ * ]
+ * }
+ *
+ * User Workspace
+ * src/
+ * components/
+ * greeting.ts
+ * pages/
+ * api/
+ * greeting.ts
+ * index.ts
+ */
+import chai from 'chai';
+import { JSDOM } from 'jsdom';
+import path from 'path';
+import { getSetupFiles, getOutputTeardownFiles } from '../../../../../test/utils.js';
+import { Runner } from 'gallinago';
+import { fileURLToPath } from 'url';
+
+const expect = chai.expect;
+
+describe('Develop Greenwood With: ', function() {
+ const LABEL = 'A Server Rendered Application (SSR) with API Routes in TypeScript';
+ const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
+ const outputPath = fileURLToPath(new URL('.', import.meta.url));
+ const hostname = 'http://127.0.0.1:1984';
+ let runner;
+
+ before(function() {
+ this.context = {
+ publicDir: path.join(outputPath, 'public'),
+ hostname
+ };
+ runner = new Runner(false, true);
+ });
+
+ describe(LABEL, function() {
+
+ before(async function() {
+ runner.setup(outputPath, getSetupFiles(outputPath));
+
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve();
+ }, 10000);
+
+ runner.runCommand(cliPath, 'develop', { async: true });
+ });
+ });
+
+ describe('Develop command for an SSR page written in TypeScript', function() {
+ let response = {};
+ let dom;
+
+ before(async function() {
+ response = await fetch(`${hostname}/`);
+ const body = await response.text();
+ dom = new JSDOM(body);
+ });
+
+ it('should return a 200 status', function() {
+ expect(response.status).to.equal(200);
+ });
+
+ it('should return a custom status message', function() {
+ expect(response.statusText).to.equal('OK');
+ });
+
+ it('should return the correct content type', function() {
+ expect(response.headers.get('content-type')).to.equal('text/html');
+ });
+
+ xit('should make sure to have the expected CSS inlined into the page for each ', function(done) {
+ const cardComponents = dom.window.document.querySelectorAll('body > app-card');
+
+ expect(cardComponents.length).to.equal(2);
+ Array.from(cardComponents).forEach((card) => {
+ expect(card.innerHTML).contain('font-size: 1.85rem');
+ });
+ done();
+ });
+ });
+
+ describe('Develop command for an API route written in TypeScript', function() {
+ const name = 'TypeScript';
+ let response = {};
+ let body;
+ let dom;
+
+ before(async function() {
+ response = await fetch(`${hostname}/api/greeting?name=${name}`);
+ body = await response.text();
+ dom = new JSDOM(body);
+ });
+
+ it('should return a 200 status', function() {
+ expect(response.status).to.equal(200);
+ });
+
+ it('should return a custom status message', function() {
+ expect(response.statusText).to.equal('OK');
+ });
+
+ it('should return the correct content type', function() {
+ expect(response.headers.get('content-type')).to.equal('text/html');
+ });
+
+ it('should make sure to have the expected CSS inlined into the page for each ', function(done) {
+ const heading = dom.window.document.querySelectorAll('body > x-greeting');
+
+ expect(heading.length).to.equal(1);
+ expect(heading[0].innerHTML).contain(`
Hello ${name}!`);
+
+ done();
+ });
+ });
+ });
+
+ after(function() {
+ runner.teardown(getOutputTeardownFiles(outputPath));
+ runner.stopCommand();
+ });
+
+});
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-develop.ssr/package.json b/packages/plugin-typescript/test/cases/loaders-develop.ssr/package.json
new file mode 100644
index 000000000..0fe34dd82
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-develop.ssr/package.json
@@ -0,0 +1,4 @@
+{
+ "name": "test-plugin-import-ts-develop-ssr",
+ "type": "module"
+}
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-develop.ssr/src/components/greeting.ts b/packages/plugin-typescript/test/cases/loaders-develop.ssr/src/components/greeting.ts
new file mode 100644
index 000000000..54bb7609a
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-develop.ssr/src/components/greeting.ts
@@ -0,0 +1,17 @@
+interface User {
+ name: string;
+}
+
+export default class Greeting extends HTMLElement {
+ connectedCallback() {
+ const user: User = {
+ name: this.getAttribute('name') || 'World'
+ };
+
+ this.innerHTML = `
+
Hello ${user.name}!
+ `;
+ }
+}
+
+customElements.define('x-greeting', Greeting);
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-develop.ssr/src/pages/api/greeting.ts b/packages/plugin-typescript/test/cases/loaders-develop.ssr/src/pages/api/greeting.ts
new file mode 100644
index 000000000..666788948
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-develop.ssr/src/pages/api/greeting.ts
@@ -0,0 +1,17 @@
+import { renderFromHTML } from 'wc-compiler';
+
+export async function handler(request: Request) {
+ const params = new URLSearchParams(request.url.slice(request.url.indexOf('?')));
+ const name = params.has('name') ? params.get('name') : 'World';
+ const { html } = await renderFromHTML(`
+
+ `, [
+ new URL('../../components/greeting.ts', import.meta.url)
+ ]);
+
+ return new Response(html, {
+ headers: {
+ 'Content-Type': 'text/html'
+ }
+ });
+}
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-develop.ssr/src/pages/index.ts b/packages/plugin-typescript/test/cases/loaders-develop.ssr/src/pages/index.ts
new file mode 100644
index 000000000..f19132bd4
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-develop.ssr/src/pages/index.ts
@@ -0,0 +1,10 @@
+import '../components/greeting.ts';
+
+export default class ContactPage extends HTMLElement {
+ connectedCallback() {
+ this.innerHTML = `
+
Welcome to our Home page!
+
+ `;
+ }
+}
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-serve.prerender-ssr/loaders-serve.prerender-ssr.spec.js b/packages/plugin-typescript/test/cases/loaders-serve.prerender-ssr/loaders-serve.prerender-ssr.spec.js
index e335cc581..b98a4bc6c 100644
--- a/packages/plugin-typescript/test/cases/loaders-serve.prerender-ssr/loaders-serve.prerender-ssr.spec.js
+++ b/packages/plugin-typescript/test/cases/loaders-serve.prerender-ssr/loaders-serve.prerender-ssr.spec.js
@@ -32,9 +32,7 @@ import { fileURLToPath } from 'url';
const expect = chai.expect;
-// TODO - this should work after this issue is resolved
-// https://github.com/ProjectEvergreen/wcc/issues/122
-xdescribe('Serve Greenwood With: ', function() {
+describe('Serve Greenwood With: ', function() {
const LABEL = 'A Prerendered Application (SSR) with an HTML page importing a TypeScript component';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = fileURLToPath(new URL('.', import.meta.url));
@@ -70,7 +68,7 @@ xdescribe('Serve Greenwood With: ', function() {
let fragmentsApiDom;
before(async function() {
- response = await fetch(`${hostname}/artists/`);
+ response = await fetch(`${hostname}/`);
body = await response.clone().text();
fragmentsApiDom = new JSDOM(body);
});
@@ -81,17 +79,18 @@ xdescribe('Serve Greenwood With: ', function() {
});
it('should return a custom status message', function(done) {
- expect(response.statusMessage).to.equal('OK');
+ expect(response.statusText).to.equal('OK');
done();
});
- it('should ...', function(done) {
- expect(fragmentsApiDom).to.not.be.undefined;
+ it('should have the expected pre-rendered app-card content', function(done) {
+ const cardComponents = fragmentsApiDom.window.document.querySelectorAll('body > app-card');
+
+ expect(cardComponents.length).to.equal(1);
+ expect(cardComponents[0].innerHTML).to.contain('
foo
');
+
done();
});
-
- // it should return the correct h1 contents
- // it should return the correct app-card contents
});
});
diff --git a/packages/plugin-typescript/test/cases/loaders-serve.ssr/greenwood.config.js b/packages/plugin-typescript/test/cases/loaders-serve.ssr/greenwood.config.js
index e0f06cfb5..4e05559a9 100644
--- a/packages/plugin-typescript/test/cases/loaders-serve.ssr/greenwood.config.js
+++ b/packages/plugin-typescript/test/cases/loaders-serve.ssr/greenwood.config.js
@@ -2,6 +2,6 @@ import { greenwoodPluginTypeScript } from '../../../src/index.js';
export default {
plugins: [
- ...greenwoodPluginTypeScript()
+ greenwoodPluginTypeScript()
]
};
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-serve.ssr/loaders-serve.ssr.spec.js b/packages/plugin-typescript/test/cases/loaders-serve.ssr/loaders-serve.ssr.spec.js
index f69a3880f..d0483a978 100644
--- a/packages/plugin-typescript/test/cases/loaders-serve.ssr/loaders-serve.ssr.spec.js
+++ b/packages/plugin-typescript/test/cases/loaders-serve.ssr/loaders-serve.ssr.spec.js
@@ -11,16 +11,22 @@
* User Config
* {
* plugins: [
- * greenwoodPluginTypeScript()
+ * greenwoodPluginTypeScript({
+ * servePages: 'dynamic'
+ * })
* ]
* }
*
* User Workspace
* src/
- * api/
- * fragment.js
* components/
* card.ts
+ * greeting.ts
+ * pages/
+ * api/
+ * fragment.js
+ * greeting.ts
+ * index.html
*/
import chai from 'chai';
import { JSDOM } from 'jsdom';
@@ -32,7 +38,7 @@ import { fileURLToPath } from 'url';
const expect = chai.expect;
describe('Serve Greenwood With: ', function() {
- const LABEL = 'A Server Rendered Application (SSR) with API Routes importing TypeScript';
+ const LABEL = 'A Server Rendered Application (SSR) with API Routes in TypeScript';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = fileURLToPath(new URL('.', import.meta.url));
const hostname = 'http://localhost:8080';
@@ -93,6 +99,40 @@ describe('Serve Greenwood With: ', function() {
done();
});
});
+
+ describe('Serve command with API specific behaviors for TypeScript authored API', function() {
+ const name = 'TypeScript';
+ let response = {};
+ let body;
+ let dom;
+
+ before(async function() {
+ response = await fetch(`${hostname}/api/greeting?name=${name}`);
+ body = await response.text();
+ dom = new JSDOM(body);
+ });
+
+ it('should return a 200 status', function() {
+ expect(response.status).to.equal(200);
+ });
+
+ it('should return a custom status message', function() {
+ expect(response.statusText).to.equal('OK');
+ });
+
+ it('should return the correct content type', function() {
+ expect(response.headers.get('content-type')).to.equal('text/html');
+ });
+
+ it('should make sure to have the expected CSS inlined into the page for each ', function(done) {
+ const heading = dom.window.document.querySelectorAll('body > x-greeting');
+
+ expect(heading.length).to.equal(1);
+ expect(heading[0].innerHTML).contain(`
+ `;
+ }
+}
+
+customElements.define('x-greeting', Greeting);
\ No newline at end of file
diff --git a/packages/plugin-typescript/test/cases/loaders-serve.ssr/src/api/fragment.js b/packages/plugin-typescript/test/cases/loaders-serve.ssr/src/pages/api/fragment.js
similarity index 91%
rename from packages/plugin-typescript/test/cases/loaders-serve.ssr/src/api/fragment.js
rename to packages/plugin-typescript/test/cases/loaders-serve.ssr/src/pages/api/fragment.js
index d03a8f3e6..096213685 100644
--- a/packages/plugin-typescript/test/cases/loaders-serve.ssr/src/api/fragment.js
+++ b/packages/plugin-typescript/test/cases/loaders-serve.ssr/src/pages/api/fragment.js
@@ -22,7 +22,7 @@ export async function handler() {
}).join('')
}
`, [
- new URL('../components/card/card.ts', import.meta.url)
+ new URL('../../components/card/card.ts', import.meta.url)
]);
return new Response(html, {
diff --git a/packages/plugin-typescript/test/cases/loaders-serve.ssr/src/pages/api/greeting.ts b/packages/plugin-typescript/test/cases/loaders-serve.ssr/src/pages/api/greeting.ts
new file mode 100644
index 000000000..666788948
--- /dev/null
+++ b/packages/plugin-typescript/test/cases/loaders-serve.ssr/src/pages/api/greeting.ts
@@ -0,0 +1,17 @@
+import { renderFromHTML } from 'wc-compiler';
+
+export async function handler(request: Request) {
+ const params = new URLSearchParams(request.url.slice(request.url.indexOf('?')));
+ const name = params.has('name') ? params.get('name') : 'World';
+ const { html } = await renderFromHTML(`
+
+ `, [
+ new URL('../../components/greeting.ts', import.meta.url)
+ ]);
+
+ return new Response(html, {
+ headers: {
+ 'Content-Type': 'text/html'
+ }
+ });
+}
\ No newline at end of file
diff --git a/www/templates/app.html b/www/layouts/app.html
similarity index 100%
rename from www/templates/app.html
rename to www/layouts/app.html
diff --git a/www/templates/blog.html b/www/layouts/blog.html
similarity index 100%
rename from www/templates/blog.html
rename to www/layouts/blog.html
diff --git a/www/templates/page.html b/www/layouts/page.html
similarity index 100%
rename from www/templates/page.html
rename to www/layouts/page.html
diff --git a/www/pages/about/features.md b/www/pages/about/features.md
index 8ebc9d99d..83b92eb47 100644
--- a/www/pages/about/features.md
+++ b/www/pages/about/features.md
@@ -9,7 +9,7 @@ linkheadings: 3
## Features
### Easy Onboarding
-We built Greenwood in the hopes that getting started would be easy. By default Greenwood will build an app for you. Just start with some HTML by adding pages and customizing templates and you're good to go! Greenwood makes as few assumptions as needed to deliver an optimal development experience with minimum configuration needed or work from you.
+We built Greenwood in the hopes that getting started would be easy. By default Greenwood will build an app for you. Just start with some HTML by adding pages and customizing layouts and you're good to go! Greenwood makes as few assumptions as needed to deliver an optimal development experience with minimum configuration needed or work from you.
We strive to provide good documentation, intuitive developer experiences, and stable workflows. Even if you don't know anything about ESM or Web Components, if you can learn a little markdown and some HTML / CSS, you can get started making a modern website right away!
diff --git a/www/pages/blog/index.md b/www/pages/blog/index.md
index fd8fb6e08..65fcb7eeb 100644
--- a/www/pages/blog/index.md
+++ b/www/pages/blog/index.md
@@ -3,7 +3,7 @@ label: 'blog'
menu: navigation
title: Blog
index: 6
-template: blog
+layout: blog
---