diff --git a/greenwood.config.js b/greenwood.config.js index 465cbd070..8fcd54697 100644 --- a/greenwood.config.js +++ b/greenwood.config.js @@ -4,6 +4,7 @@ import { greenwoodPluginPolyfills } from "@greenwood/plugin-polyfills"; import { greenwoodPluginPostCss } from "@greenwood/plugin-postcss"; import { greenwoodPluginImportRaw } from "@greenwood/plugin-import-raw"; import { greenwoodPluginRendererPuppeteer } from "@greenwood/plugin-renderer-puppeteer"; +import { greenwoodPluginMarkdown } from "@greenwood/plugin-markdown"; import rollupPluginAnalyzer from "rollup-plugin-analyzer"; /** @type {import('@greenwood/cli').Config} */ @@ -14,6 +15,9 @@ export default { activeContent: true, prerender: true, plugins: [ + greenwoodPluginMarkdown({ + plugins: ["@mapbox/rehype-prism", "rehype-slug", "rehype-autolink-headings", "remark-github"], + }), greenwoodPluginGraphQL(), greenwoodPluginPolyfills({ lit: true, @@ -39,7 +43,4 @@ export default { }, }, ], - markdown: { - plugins: ["@mapbox/rehype-prism", "rehype-slug", "rehype-autolink-headings", "remark-github"], - }, }; diff --git a/greenwood.config.test-types.ts b/greenwood.config.test-types.ts index e360a53f1..dce02b5a5 100644 --- a/greenwood.config.test-types.ts +++ b/greenwood.config.test-types.ts @@ -10,6 +10,7 @@ import { greenwoodPluginImportCommonJs } from "@greenwood/plugin-import-commonjs import { greenwoodPluginImportJsx } from "@greenwood/plugin-import-jsx"; import { greenwoodPluginImportRaw } from "@greenwood/plugin-import-raw"; import { greenwoodPluginIncludeHTML } from "@greenwood/plugin-include-html"; +import { greenwoodPluginMarkdown } from "@greenwood/plugin-markdown"; import { greenwoodPluginPolyfills } from "@greenwood/plugin-polyfills"; import { greenwoodPluginPostCss } from "@greenwood/plugin-postcss"; import { greenwoodPluginRendererLit } from "@greenwood/plugin-renderer-lit"; @@ -46,15 +47,6 @@ const config: Config = { isolation: true, layoutsDirectory: "/my-layouts", optimization: "default", - markdown: { - plugins: [ - "@mapbox/rehype-prism", - { - name: "rehype-autolink-headings", - options: { behavior: "append" }, - }, - ], - }, pagesDirectory: "/my-pages", plugins: [ greenwoodPluginAdapterAws(), @@ -68,6 +60,15 @@ const config: Config = { greenwoodPluginImportJsx(), greenwoodPluginImportRaw, greenwoodPluginIncludeHTML(), + greenwoodPluginMarkdown({ + plugins: [ + "@mapbox/rehype-prism", + { + name: "rehype-autolink-headings", + options: { behavior: "append" }, + }, + ], + }), greenwoodPluginPolyfills(), greenwoodPluginPostCss(), greenwoodPluginRendererLit(), diff --git a/packages/cli/package.json b/packages/cli/package.json index aacd9843e..457778e73 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -59,21 +59,13 @@ "koa": "^3.0.1", "koa-body": "^6.0.1", "livereload": "^0.9.1", - "markdown-toc": "^1.2.0", "node-html-parser": "^7.0.1", - "rehype-raw": "^7.0.0", - "rehype-stringify": "^10.0.1", - "remark-frontmatter": "^5.0.0", - "remark-parse": "^11.0.0", - "remark-rehype": "^11.1.1", "rollup": "^4.26.0", - "unified": "^11.0.5", "wc-compiler": "~0.17.0" }, "devDependencies": { "@aws-sdk/client-cloudfront": "^3.726.0", "@beforesemicolon/markup": "^1.14.1", - "@mapbox/rehype-prism": "^0.5.0", "@shoelace-style/shoelace": "^2.18.0", "@spectrum-css/card": "^9.3.0", "@spectrum-web-components/action-menu": "^1.0.1", @@ -92,8 +84,6 @@ "pwa-helpers": "^0.9.1", "redux": "^5.0.1", "redux-thunk": "^3.1.0", - "rehype-autolink-headings": "^4.0.0", - "rehype-slug": "^3.0.0", "signal-utils": "^0.21.1", "simpledotcss": "^1.0.0", "tslib": "^2.8.1" diff --git a/packages/cli/src/lib/layout-utils.js b/packages/cli/src/lib/layout-utils.js index 42fd9e892..8dd051d7c 100644 --- a/packages/cli/src/lib/layout-utils.js +++ b/packages/cli/src/lib/layout-utils.js @@ -229,7 +229,9 @@ async function mergeContentIntoLayout( : childRoot.querySelector("html") && childBody ? childBody : !childRoot.querySelector("html") - ? childContents + ? childRoot.querySelector("body") + ? childBody + : childContents : ""; // we wrap SSR content in comments so we can extract it during prerendering to avoid double pre-rendering diff --git a/packages/cli/src/lifecycles/config.js b/packages/cli/src/lifecycles/config.js index fa74e5a3f..3d34e3125 100644 --- a/packages/cli/src/lifecycles/config.js +++ b/packages/cli/src/lifecycles/config.js @@ -66,7 +66,6 @@ const defaultConfig = { }, isolation: false, layoutsDirectory: "layouts", - markdown: { plugins: [] }, optimization: optimizations[0], pagesDirectory: "pages", plugins: greenwoodPlugins, diff --git a/packages/cli/src/lifecycles/graph.js b/packages/cli/src/lifecycles/graph.js index d6bdf9082..90d4c1630 100644 --- a/packages/cli/src/lifecycles/graph.js +++ b/packages/cli/src/lifecycles/graph.js @@ -3,7 +3,6 @@ import fs from "node:fs/promises"; import fm from "front-matter"; import { checkResourceExists, requestAsObject } from "../lib/resource-utils.js"; import { activeFrontmatterKeys } from "../lib/content-utils.js"; -import toc from "markdown-toc"; import { Worker } from "node:worker_threads"; function getLabelFromRoute(_route) { @@ -27,7 +26,7 @@ function getLabelFromRoute(_route) { } function getIdFromRelativePathPath(relativePathPath, extension) { - return relativePathPath.replace(extension, "").replace("./", "").replace(/\//g, "-"); + return relativePathPath.replace(`.${extension}`, "").replace("./", "").replace(/\//g, "-"); } function trackCollectionsForPage(page, collections) { @@ -79,29 +78,26 @@ const generateGraph = async (compilation) => { pages = nextPages.pages; apiRoutes = nextPages.apiRoutes; } else { - const extension = `.${filenameUrl.pathname.split(".").pop()}`; + const extension = `${filenameUrl.pathname.split(".").pop()}`; const relativePagePath = filenameUrl.pathname.replace(pagesDir.pathname, "./"); const isApiRoute = relativePagePath.startsWith("./api"); - const req = isApiRoute - ? new Request(filenameUrl, { headers: { Accept: "text/javascript" } }) - : new Request(filenameUrl, { headers: { Accept: "text/html" } }); let isCustom = null; for (const plugin of customPageFormatPlugins) { - if (plugin.shouldServe && (await plugin.shouldServe(filenameUrl, req))) { + if (plugin.servePage && plugin.extensions.includes(extension)) { isCustom = plugin.servePage; break; } } - const isStatic = isCustom === "static" || extension === ".md" || extension === ".html"; - const isDynamic = isCustom === "dynamic" || extension === ".js" || extension === ".ts"; + const isStatic = isCustom === "static" || extension === "html"; + const isDynamic = isCustom === "dynamic" || extension === "js" || extension === "ts"; const isPage = isStatic || isDynamic; - let route = `${relativePagePath.replace(".", "").replace(`${extension}`, "")}`; + let route = `${relativePagePath.replace(".", "").replace(`.${extension}`, "")}`; let fileContents; if (isApiRoute) { - if (extension !== ".js" && extension !== ".ts" && !isCustom) { + if (extension !== "js" && extension !== "ts" && !isCustom) { console.warn(`${filenameUrl} is not a supported API file extension, skipping...`); return; } @@ -123,12 +119,14 @@ const generateGraph = async (compilation) => { getIdFromRelativePathPath(relativePagePath, extension).replace("api-", ""), ), pageHref: new URL(relativePagePath, pagesDir).href, - outputHref: new URL(relativePagePath, outputDir).href.replace(extension, ".js"), + outputHref: new URL(relativePagePath, outputDir).href.replace(`.${extension}`, ".js"), route: `${basePath}${route}`, isolation, }); } else if (isPage) { - let root = filename.split("/")[filename.split("/").length - 1].replace(extension, ""); + let root = filename + .split("/") + [filename.split("/").length - 1].replace(`.${extension}`, ""); // should we even have a default page layout? // https://github.com/ProjectEvergreen/greenwood/issues/1271 let layout = "page"; @@ -223,36 +221,11 @@ const generateGraph = async (compilation) => { } } - /* - * Custom front matter - Variable Definitions - * -------------------------------------------------- - * collection: the name of the collection for the page (as a string or array) - * order: the order of this item within the collection - * tocHeading: heading size to use a Table of Contents for a page - * tableOfContents: json object containing page's table of contents (list of headings) - */ - - // prune "reserved" attributes that are supported by Greenwood + // prune "reserved" frontmatter that are supported by Greenwood [...activeFrontmatterKeys, "layout"].forEach((key) => { delete customData[key]; }); - // set flag whether to gather a list of headings on a page as menu items - customData.tocHeading = customData.tocHeading || 0; - customData.tableOfContents = []; - - if (fileContents && customData.tocHeading > 0 && customData.tocHeading <= 6) { - // parse markdown for table of contents and output to json - customData.tableOfContents = toc(fileContents).json; - - // parse table of contents for only the pages user wants linked - if (customData.tableOfContents.length > 0 && customData.tocHeading > 0) { - customData.tableOfContents = customData.tableOfContents.filter( - (item) => item.lvl === customData.tocHeading, - ); - } - } - /* * Page Properties *---------------------- diff --git a/packages/cli/src/lifecycles/serve.js b/packages/cli/src/lifecycles/serve.js index ea5a1711d..60e0aaf4d 100644 --- a/packages/cli/src/lifecycles/serve.js +++ b/packages/cli/src/lifecycles/serve.js @@ -16,21 +16,13 @@ async function getDevServer(compilation) { const app = new Koa(); const compilationCopy = Object.assign({}, compilation); const resourcePlugins = [ - // Greenwood default standard resource and import plugins ...compilation.config.plugins .filter((plugin) => { - return plugin.type === "resource" && plugin.isGreenwoodDefaultPlugin; + return plugin.type === "resource"; }) .map((plugin) => { return plugin.provider(compilationCopy); }), - - // custom user resource plugins - ...compilation.config.plugins - .filter((plugin) => { - return plugin.type === "resource" && !plugin.isGreenwoodDefaultPlugin; - }) - .map((plugin) => plugin.provider(compilationCopy)), ]; app.use(koaBody()); @@ -57,7 +49,7 @@ async function getDevServer(compilation) { await next(); }); - // handle creating responses from urls + // handle serving responses from urls app.use(async (ctx, next) => { try { const url = new URL(ctx.url); @@ -67,7 +59,7 @@ async function getDevServer(compilation) { let response = new Response(null, { status }); for (const plugin of resourcePlugins) { - if (plugin.shouldServe && (await plugin.shouldServe(url, request))) { + if (!plugin.servePage && plugin.shouldServe && (await plugin.shouldServe(url, request))) { const current = await plugin.serve(url, request); const merged = mergeResponse(response.clone(), current.clone()); @@ -101,17 +93,26 @@ async function getDevServer(compilation) { headers: new Headers(header), }); - let response = initResponse; - for (const plugin of resourcePlugins) { + // we explicitly use "async" reduce here to avoid race conditions / Body consumed errors + // when looping through and sharing responses between plugins + const response = await resourcePlugins.reduce(async (responsePromise, plugin) => { + const intermediateResponse = await responsePromise; if ( plugin.shouldPreIntercept && - (await plugin.shouldPreIntercept(url, request, response.clone())) + (await plugin.shouldPreIntercept(url, request, intermediateResponse.clone())) ) { - const current = await plugin.preIntercept(url, request, response.clone()); - - response = mergeResponse(response.clone(), current.clone()); + const current = await plugin.preIntercept( + url, + request, + await intermediateResponse.clone(), + ); + const merged = mergeResponse(intermediateResponse.clone(), current); + + return Promise.resolve(merged); + } else { + return Promise.resolve(await responsePromise); } - } + }, Promise.resolve(initResponse.clone())); ctx.body = response.body ? Readable.from(response.body) : ""; ctx.message = response.statusText; @@ -138,17 +139,22 @@ async function getDevServer(compilation) { headers: new Headers(header), }); - let response = initResponse; - for (const plugin of resourcePlugins) { + // we explicitly use "async" reduce here to avoid race conditions / Body consumed errors + // when looping through and sharing responses between plugins + const response = await resourcePlugins.reduce(async (responsePromise, plugin) => { + const intermediateResponse = await responsePromise; if ( plugin.shouldIntercept && - (await plugin.shouldIntercept(url, request, response.clone())) + (await plugin.shouldIntercept(url, request, intermediateResponse.clone())) ) { - const current = await plugin.intercept(url, request, response.clone()); + const current = await plugin.intercept(url, request, await intermediateResponse.clone()); + const merged = mergeResponse(intermediateResponse.clone(), current); - response = mergeResponse(response.clone(), current.clone()); + return Promise.resolve(merged); + } else { + return Promise.resolve(await responsePromise); } - } + }, Promise.resolve(initResponse.clone())); ctx.body = response.body ? Readable.from(response.body) : ""; ctx.message = response.statusText; @@ -250,6 +256,7 @@ async function getStaticServer(compilation, composable) { } } else { ctx.body = "Not Found"; + ctx.message = "Not Found"; ctx.status = 404; ctx.set("Content-Type", "text/plain"); } @@ -323,6 +330,7 @@ async function getStaticServer(compilation, composable) { ctx.body = body; ctx.status = 200; + ctx.message = "OK"; ctx.set("Content-Type", "text/html"); } } catch (e) { @@ -392,6 +400,7 @@ async function getHybridServer(compilation) { } ctx.body = html; + ctx.message = "OK"; ctx.set("Content-Type", "text/html"); ctx.status = 200; } else if (isApiRoute) { diff --git a/packages/cli/src/plugins/resource/plugin-standard-html.js b/packages/cli/src/plugins/resource/plugin-standard-html.js index 7eeca5fee..f1d1153df 100644 --- a/packages/cli/src/plugins/resource/plugin-standard-html.js +++ b/packages/cli/src/plugins/resource/plugin-standard-html.js @@ -5,21 +5,15 @@ * */ import fs from "node:fs/promises"; -import rehypeStringify from "rehype-stringify"; -import rehypeRaw from "rehype-raw"; -import remarkFrontmatter from "remark-frontmatter"; -import remarkParse from "remark-parse"; -import remarkRehype from "remark-rehype"; import { getPageLayout, getAppLayout, getGreenwoodScripts } from "../../lib/layout-utils.js"; import { requestAsObject } from "../../lib/resource-utils.js"; -import { unified } from "unified"; import { Worker } from "node:worker_threads"; import { parse } from "node-html-parser"; class StandardHtmlResource { constructor(compilation) { this.compilation = compilation; - this.extensions = [".html", ".md"]; + this.extensions = [".html"]; this.contentType = "text/html"; } @@ -45,56 +39,35 @@ class StandardHtmlResource { !matchingRoute.external && pageHref ? new URL(pageHref).pathname.replace(userWorkspace.pathname, "./") : ""; - const isMarkdownContent = (filePath || "").split(".").pop() === "md"; const isHtmlContent = (filePath || "").split(".").pop() === "html"; let body = ""; let ssrBody; - let processedMarkdown = null; // final contents to return from the plugin let html = ""; - const customPageFormatPlugins = config.plugins - .filter((plugin) => plugin.type === "resource" && !plugin.isGreenwoodDefaultPlugin) - .map((plugin) => plugin.provider(this.compilation)); - const isCustomStaticPage = - customPageFormatPlugins[0] && - customPageFormatPlugins[0].servePage === "static" && - customPageFormatPlugins[0].shouldServe && - (await customPageFormatPlugins[0].shouldServe(new URL(pageHref))); - - if (isMarkdownContent) { - const markdownContents = await fs.readFile(new URL(pageHref), "utf-8"); - const rehypePlugins = []; - const remarkPlugins = []; - - for (const plugin of config.markdown.plugins) { - const name = typeof plugin === "string" ? plugin : plugin.name; - const options = plugin?.options ?? null; - const pluginTypeArray = name.indexOf("rehype-") >= 0 ? rehypePlugins : remarkPlugins; - const pluginImport = (await import(name)).default; - - if (options) { - pluginTypeArray.push([pluginImport, options]); - } else { - pluginTypeArray.push(pluginImport); - } + if (isHtmlContent) { + body = await fs.readFile(new URL(pageHref), "utf-8"); + + // purge frontmatter data from HTML files that only have a `
` tag + // frontmatter outside of an tag will get ignored by node-html-parser + if (body.trim().startsWith("---")) { + body = body.replace(/---(.*)---/s, ""); } + } else if (matchingRoute.servePage === "static") { + const customStaticPageFormatPlugins = config.plugins + .filter((plugin) => plugin.type === "resource" && !plugin.isGreenwoodDefaultPlugin) + .map((plugin) => plugin.provider(this.compilation)) + .filter((plugin) => plugin.servePage === "static"); - processedMarkdown = await unified() - .use(remarkParse) // parse markdown into AST - .use(remarkFrontmatter) // extract frontmatter from AST - .use(remarkPlugins) // apply userland remark plugins - .use(remarkRehype, { allowDangerousHtml: true }) // convert from markdown to HTML AST - .use(rehypeRaw) // support mixed HTML in markdown - .use(rehypePlugins) // apply userland rehype plugins - .use(rehypeStringify) // convert AST to HTML string - .process(markdownContents); - } else if (isHtmlContent) { - body = await fs.readFile(new URL(pageHref), "utf-8"); - } else if (isCustomStaticPage) { - const transformed = await customPageFormatPlugins[0].serve(new URL(pageHref)); + for (const plugin of customStaticPageFormatPlugins) { + if (await plugin.shouldServe(url, request)) { + const response = await plugin.serve(url, request); - body = await transformed.text(); + body = await response.text(); + + break; + } + } } else if (matchingRoute.isSSR) { const routeModuleLocationUrl = new URL(pageHref); const routeWorkerUrl = this.compilation.config.plugins @@ -132,24 +105,7 @@ class StandardHtmlResource { }); } - if (processedMarkdown) { - const wrappedCustomElementRegex = - /<[a-zA-Z]*-[a-zA-Z](.*)>(.*)<\/[a-zA-Z]*-[a-zA-Z](.*)><\/p>/g; - const ceTest = wrappedCustomElementRegex.test(processedMarkdown.value); - - if (ceTest) { - const ceMatches = processedMarkdown.value.match(wrappedCustomElementRegex); - - ceMatches.forEach((match) => { - const stripWrappingTags = match.replace("
", "").replace("
", ""); - - processedMarkdown.value = processedMarkdown.value.replace(match, stripWrappingTags); - }); - } - - // https://github.com/ProjectEvergreen/greenwood/issues/1126 - body = processedMarkdown.value.replace(/\$/g, "$$$"); - } else if (matchingRoute.external) { + if (matchingRoute.external) { body = matchingRoute.body; } else if (ssrBody) { body = ssrBody; diff --git a/packages/cli/src/plugins/resource/plugin-static-router.js b/packages/cli/src/plugins/resource/plugin-static-router.js index 4522fe9d8..dc75fc27d 100644 --- a/packages/cli/src/plugins/resource/plugin-static-router.js +++ b/packages/cli/src/plugins/resource/plugin-static-router.js @@ -85,20 +85,15 @@ class StaticRouterResource { const routeTags = this.compilation.graph .filter((page) => !page.isSSR && !page.route.endsWith("/404/")) .map((page) => { - const layout = - page.pageHref && page.pageHref.split(".").pop() === this.extensions[0] - ? page.route - : page.layout; + const { layout, route } = page; const key = - page.route === "/" - ? "" - : page.route.slice(0, page.route.lastIndexOf("/")).replace(basePath, ""); + route === "/" ? "" : route.slice(0, route.lastIndexOf("/")).replace(basePath, ""); - if (pathname === page.route) { + if (pathname === route) { currentLayout = layout; } return ` -A page using a page layout from a custom layout directory.
+ 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 deleted file mode 100644 index 3332d3216..000000000 --- a/packages/cli/test/cases/build.config.layouts-directory/src/pages/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# 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.markdown-custom.plugins/greenwood.config.js b/packages/cli/test/cases/build.config.markdown-custom.plugins/greenwood.config.js deleted file mode 100644 index e45abd2f9..000000000 --- a/packages/cli/test/cases/build.config.markdown-custom.plugins/greenwood.config.js +++ /dev/null @@ -1,12 +0,0 @@ -export default { - markdown: { - plugins: [ - "@mapbox/rehype-prism", - "rehype-slug", - { - name: "rehype-autolink-headings", - options: { behavior: "append" }, - }, - ], - }, -}; diff --git a/packages/cli/test/cases/build.config.pages-directory/build.config.pages-directory.spec.js b/packages/cli/test/cases/build.config.pages-directory/build.config.pages-directory.spec.js index 028ca90e8..c85b64a9d 100644 --- a/packages/cli/test/cases/build.config.pages-directory/build.config.pages-directory.spec.js +++ b/packages/cli/test/cases/build.config.pages-directory/build.config.pages-directory.spec.js @@ -17,7 +17,7 @@ * Greenwood default * src/ * docs/ - * index.md + * index.html */ import fs from "node:fs"; import { JSDOM } from "jsdom"; diff --git a/packages/cli/test/cases/build.config.pages-directory/src/docs/index.html b/packages/cli/test/cases/build.config.pages-directory/src/docs/index.html new file mode 100644 index 000000000..9d50c5e42 --- /dev/null +++ b/packages/cli/test/cases/build.config.pages-directory/src/docs/index.html @@ -0,0 +1,6 @@ + + +This is the home page built by Greenwood. Make your own pages in src/pages/index.js!
+ + diff --git a/packages/cli/test/cases/build.config.pages-directory/src/docs/index.md b/packages/cli/test/cases/build.config.pages-directory/src/docs/index.md deleted file mode 100644 index 1c1a50fbb..000000000 --- a/packages/cli/test/cases/build.config.pages-directory/src/docs/index.md +++ /dev/null @@ -1,3 +0,0 @@ -### Greenwood - -This is the home page built by Greenwood. Make your own pages in src/pages/index.js! \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.prerender-collections/build.config.prerender-collections.spec.js b/packages/cli/test/cases/build.config.prerender-collections/build.config.prerender-collections.spec.js index 842c81a9d..40244a8d7 100644 --- a/packages/cli/test/cases/build.config.prerender-collections/build.config.prerender-collections.spec.js +++ b/packages/cli/test/cases/build.config.prerender-collections/build.config.prerender-collections.spec.js @@ -23,8 +23,8 @@ * toc.js * pages/ * blog/ - * first-post.md - * second-post.md + * first-post.html + * second-post.html * index.html * index.html * toc.html diff --git a/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/first-post.html b/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/first-post.html new file mode 100644 index 000000000..12c4bdc81 --- /dev/null +++ b/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/first-post.html @@ -0,0 +1,6 @@ + + +Lorum Ipsum
+ + diff --git a/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/first-post.md b/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/first-post.md deleted file mode 100644 index 2f41b6873..000000000 --- a/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/first-post.md +++ /dev/null @@ -1,3 +0,0 @@ -# First Post - -Lorum Ipsum \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/second-post.html b/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/second-post.html new file mode 100644 index 000000000..2b633a11e --- /dev/null +++ b/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/second-post.html @@ -0,0 +1,6 @@ + + +Lorum Ipsum
+ + diff --git a/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/second-post.md b/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/second-post.md deleted file mode 100644 index ba4dc1e04..000000000 --- a/packages/cli/test/cases/build.config.prerender-collections/src/pages/blog/second-post.md +++ /dev/null @@ -1,3 +0,0 @@ -# Second Post - -Lorum Ipsum \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.prerender-markdown/greenwood.config.js b/packages/cli/test/cases/build.config.prerender-markdown/greenwood.config.js deleted file mode 100644 index 1d1aad744..000000000 --- a/packages/cli/test/cases/build.config.prerender-markdown/greenwood.config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - prerender: true, -}; 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 b8fc08113..83cf8b677 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 @@ -16,9 +16,9 @@ * User Workspace * src/ * pages/ - * about.md + * about.html * artists.js - * index.md + * index.html * regex-test.html */ import chai from "chai"; @@ -146,7 +146,9 @@ describe("Build Greenwood With: ", function () { const aboutRouterOutlet = aboutDom.window.document.querySelectorAll("body > router-outlet")[0]; - expect(aboutRouterOutlet.innerHTML).to.contain(aboutPartial); + expect(aboutRouterOutlet.innerHTML.replace(/\n/g, "").trim()).to.contain( + aboutPartial.replace("", "").replace("", "").replace(/\n/g, "").trim(), + ); }); it("should have the expected partial output to match the contents of the about page in theThis is the about page built by Greenwood.
+ 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 deleted file mode 100644 index 5618aaa66..000000000 --- a/packages/cli/test/cases/build.config.static-router/src/pages/about.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: test ---- - -### Greenwood - -This is the about page built by Greenwood. \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.static-router/src/pages/index.html b/packages/cli/test/cases/build.config.static-router/src/pages/index.html new file mode 100644 index 000000000..6f19a3be8 --- /dev/null +++ b/packages/cli/test/cases/build.config.static-router/src/pages/index.html @@ -0,0 +1,8 @@ +--- +author: Greenwood +--- + + +This is the home page built by Greenwood.
+ diff --git a/packages/cli/test/cases/build.config.workspace-custom/build.config.workspace-custom.spec.js b/packages/cli/test/cases/build.config.workspace-custom/build.config.workspace-custom.spec.js index 0dae1f764..9b510fa89 100644 --- a/packages/cli/test/cases/build.config.workspace-custom/build.config.workspace-custom.spec.js +++ b/packages/cli/test/cases/build.config.workspace-custom/build.config.workspace-custom.spec.js @@ -16,8 +16,8 @@ * User Workspace * www/ * pages/ - * about.md - * index.md + * about.html + * index.html */ import chai from "chai"; import fs from "node:fs"; @@ -66,7 +66,7 @@ describe("Build Greenwood With: ", function () { it("should have the expected heading text within the custom about page in the about directory", function () { const heading = dom.window.document.querySelector("h3").textContent; - expect(heading).to.equal("Nested Custom About Page"); + expect(heading).to.equal("Custom About Page"); }); it("should have the expected paragraph text within the custom about page in the about directory", function () { diff --git a/packages/cli/test/cases/build.config.workspace-custom/www/pages/about.html b/packages/cli/test/cases/build.config.workspace-custom/www/pages/about.html new file mode 100644 index 000000000..c96d1d4f7 --- /dev/null +++ b/packages/cli/test/cases/build.config.workspace-custom/www/pages/about.html @@ -0,0 +1,6 @@ + + +This is a custom about page built by Greenwood.
+ + diff --git a/packages/cli/test/cases/build.config.workspace-custom/www/pages/about.md b/packages/cli/test/cases/build.config.workspace-custom/www/pages/about.md deleted file mode 100644 index e228c1606..000000000 --- a/packages/cli/test/cases/build.config.workspace-custom/www/pages/about.md +++ /dev/null @@ -1,3 +0,0 @@ -### Nested Custom About Page - -This is a custom about page built by Greenwood. \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.workspace-custom/www/pages/index.html b/packages/cli/test/cases/build.config.workspace-custom/www/pages/index.html new file mode 100644 index 000000000..2c52eaba0 --- /dev/null +++ b/packages/cli/test/cases/build.config.workspace-custom/www/pages/index.html @@ -0,0 +1,6 @@ + + +This is the home page built by Greenwood. Make your own pages in www/pages/index.html!
+ + diff --git a/packages/cli/test/cases/build.config.workspace-custom/www/pages/index.md b/packages/cli/test/cases/build.config.workspace-custom/www/pages/index.md deleted file mode 100644 index 1c1a50fbb..000000000 --- a/packages/cli/test/cases/build.config.workspace-custom/www/pages/index.md +++ /dev/null @@ -1,3 +0,0 @@ -### Greenwood - -This is the home page built by Greenwood. Make your own pages in src/pages/index.js! \ 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 336e09dd9..2a0064a84 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 @@ -16,9 +16,9 @@ * src/ * pages/ * about/ - * index.md - * hello.md - * index.md + * index.html + * hello.html + * index.html * layout/ * app.html * page.html diff --git a/packages/cli/test/cases/build.default.meta/src/pages/about/index.md b/packages/cli/test/cases/build.default.meta/src/pages/about/index.html similarity index 100% rename from packages/cli/test/cases/build.default.meta/src/pages/about/index.md rename to packages/cli/test/cases/build.default.meta/src/pages/about/index.html diff --git a/packages/cli/test/cases/build.default.meta/src/pages/hello.html b/packages/cli/test/cases/build.default.meta/src/pages/hello.html new file mode 100644 index 000000000..5df6eba24 --- /dev/null +++ b/packages/cli/test/cases/build.default.meta/src/pages/hello.html @@ -0,0 +1,9 @@ + + +This is an example page built by Greenwood. Make your own in _src/pages_!
+ + diff --git a/packages/cli/test/cases/build.default.meta/src/pages/index.html b/packages/cli/test/cases/build.default.meta/src/pages/index.html new file mode 100644 index 000000000..ee673a5eb --- /dev/null +++ b/packages/cli/test/cases/build.default.meta/src/pages/index.html @@ -0,0 +1,4 @@ + +This is the home page built by Greenwood. Make your own pages in src/pages/index.js!
+ diff --git a/packages/cli/test/cases/build.default.quick-start-npx/build.default.quick-start-npx.spec.js b/packages/cli/test/cases/build.default.quick-start-npx/build.default.quick-start-npx.spec.js deleted file mode 100644 index 20f6a9b47..000000000 --- a/packages/cli/test/cases/build.default.quick-start-npx/build.default.quick-start-npx.spec.js +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Use Case - * Run Greenwood build command with no config and emulating being run with npx - * - * User Result - * Should generate a bare bones Greenwood build with no errors for missing files - * by specifically not scaffolding node_modules/ needed for es-modules-shims and webcomponents-bundle. - * https://github.com/ProjectEvergreen/greenwood/issues/505 - * - * User Command - * greenwood build - * - * User Config - * None (Greenwood Default) - * - * User Workspace - * src/ - * components/ - * header.js - * pages/ - * index.md - * layouts/ - * page.html - */ -import chai from "chai"; -import { JSDOM } from "jsdom"; -import path from "node:path"; -import { getOutputTeardownFiles } from "../../../../../test/utils.js"; -import { runSmokeTest } from "../../../../../test/smoke-test.js"; -import { Runner } from "gallinago"; -import { fileURLToPath } from "node:url"; - -const expect = chai.expect; - -describe("Build Greenwood With: ", function () { - const LABEL = "Default Greenwood Configuration and Workspace and emulating npx"; - const cliPath = path.join(process.cwd(), "packages/cli/src/bin.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); - runner.runCommand(cliPath, "build"); - }); - - runSmokeTest(["public", "index"], LABEL); - - describe("Default output for index.html", function () { - let dom; - - before(async function () { - dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, "./index.html")); - }); - - describe("head section tags", function () { - it("should have aLorum Ipsum.
+ diff --git a/packages/cli/test/cases/build.default.ssr-static-export/src/pages/index.md b/packages/cli/test/cases/build.default.ssr-static-export/src/pages/index.md deleted file mode 100644 index 5fa8f5c5d..000000000 --- a/packages/cli/test/cases/build.default.ssr-static-export/src/pages/index.md +++ /dev/null @@ -1,3 +0,0 @@ -## Hello SSR - -Lorum Ipsum. \ 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 89292b01f..7710f9124 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 @@ -15,8 +15,8 @@ * Greenwood default * src/ * pages/ - * index.md - * hello.md + * index.html + * hello.html * layouts/ * page.html */ diff --git a/packages/cli/test/cases/build.default.title/src/pages/about.html b/packages/cli/test/cases/build.default.title/src/pages/about.html new file mode 100644 index 000000000..f27a9e60f --- /dev/null +++ b/packages/cli/test/cases/build.default.title/src/pages/about.html @@ -0,0 +1,9 @@ +--- +label: "about" +title: "About Page" +--- + + +This is an example page built by Greenwood. Make your own in _src/pages_!
+ diff --git a/packages/cli/test/cases/build.default.title/src/pages/about.md b/packages/cli/test/cases/build.default.title/src/pages/about.md deleted file mode 100644 index afd78bcbc..000000000 --- a/packages/cli/test/cases/build.default.title/src/pages/about.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -label: 'about' -title: 'About Page' ---- - -### About - -This is an example page built by Greenwood. Make your own in _src/pages_! \ No newline at end of file diff --git a/packages/cli/test/cases/build.default.title/src/pages/index.html b/packages/cli/test/cases/build.default.title/src/pages/index.html new file mode 100644 index 000000000..8a40c3c3f --- /dev/null +++ b/packages/cli/test/cases/build.default.title/src/pages/index.html @@ -0,0 +1,9 @@ +--- +author: Greenwood +--- + + +This is just a test.
+ diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/build.default.workspace-layouts-page-and-app-dynamic.spec.js b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/build.default.workspace-layouts-page-and-app-dynamic.spec.js index 615f8f8d8..0fe3797f9 100644 --- a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/build.default.workspace-layouts-page-and-app-dynamic.spec.js +++ b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/build.default.workspace-layouts-page-and-app-dynamic.spec.js @@ -14,7 +14,7 @@ * User Workspace * src/ * pages/ - * about.md + * about.html * index.html * layouts/ * app.js diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/src/pages/about.html b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/src/pages/about.html new file mode 100644 index 000000000..a2a70fd4b --- /dev/null +++ b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/src/pages/about.html @@ -0,0 +1,4 @@ + +Learn more about us
+ diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/src/pages/about.md b/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/src/pages/about.md deleted file mode 100644 index 3eb3f6d59..000000000 --- a/packages/cli/test/cases/build.default.workspace-layouts-page-and-app-dynamic/src/pages/about.md +++ /dev/null @@ -1,3 +0,0 @@ -### About Page - -Learn more about us \ No newline at end of file diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/build.default.workspace-layouts-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 index 46975e0b1..b7f996396 100644 --- a/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/build.default.workspace-layouts-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 @@ -14,7 +14,7 @@ * User Workspace * src/ * pages/ - * index.md + * index.html * layouts/ * page.html */ diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/pages/index.html b/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/pages/index.html new file mode 100644 index 000000000..0bae863de --- /dev/null +++ b/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/pages/index.html @@ -0,0 +1,4 @@ + +This is a test.
+ diff --git a/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/pages/index.md b/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/pages/index.md deleted file mode 100644 index 062a1c311..000000000 --- a/packages/cli/test/cases/build.default.workspace-layouts-page-bare-merging/src/pages/index.md +++ /dev/null @@ -1,3 +0,0 @@ -## Quick Start - -This is a test. \ No newline at end of file diff --git a/packages/cli/test/cases/build.default.workspace-layouts-relative-paths/build.default.workspace-layouts-relative-paths.spec.js b/packages/cli/test/cases/build.default.workspace-layouts-relative-paths/build.default.workspace-layouts-relative-paths.spec.js index ac048b3fc..097bed332 100644 --- a/packages/cli/test/cases/build.default.workspace-layouts-relative-paths/build.default.workspace-layouts-relative-paths.spec.js +++ b/packages/cli/test/cases/build.default.workspace-layouts-relative-paths/build.default.workspace-layouts-relative-paths.spec.js @@ -25,7 +25,7 @@ * one/ * two/ * three/ - * index.md + * index.html * index.html * layouts/ * app.html diff --git a/packages/cli/test/cases/build.default.workspace-layouts-relative-paths/src/pages/one/two/three/index.html b/packages/cli/test/cases/build.default.workspace-layouts-relative-paths/src/pages/one/two/three/index.html new file mode 100644 index 000000000..c6fb2e13d --- /dev/null +++ b/packages/cli/test/cases/build.default.workspace-layouts-relative-paths/src/pages/one/two/three/index.html @@ -0,0 +1,10 @@ +--- +imports: + - ../../../components/greeting.js +--- + + +We made it!
+Thanks for contacting us.
+ diff --git a/packages/cli/test/cases/build.default.workspace-top-level-pages/src/pages/contact.md b/packages/cli/test/cases/build.default.workspace-top-level-pages/src/pages/contact.md deleted file mode 100644 index f6d45df3c..000000000 --- a/packages/cli/test/cases/build.default.workspace-top-level-pages/src/pages/contact.md +++ /dev/null @@ -1,3 +0,0 @@ -### Contact Page - -Thanks for contacting us. \ 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 e4187a52d..04dfd7795 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 @@ -19,10 +19,10 @@ * header.js * pages/ * plugins/ - * index-hooks.md - * index.md - * index.md - * pages.md + * index-hooks.html + * index.html + * index.html + * pages.html * services/ * pages/ * pages.js diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/index.html b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/index.html new file mode 100644 index 000000000..ee673a5eb --- /dev/null +++ b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/index.html @@ -0,0 +1,4 @@ + +This is the home page built by Greenwood. Make your own pages in src/pages/index.js!
+ diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/index.md b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/index.md deleted file mode 100644 index 1c1a50fbb..000000000 --- a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/index.md +++ /dev/null @@ -1,3 +0,0 @@ -### Greenwood - -This is the home page built by Greenwood. Make your own pages in src/pages/index.js! \ No newline at end of file diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/pages.html b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/pages.html new file mode 100644 index 000000000..3ce44d830 --- /dev/null +++ b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/pages.html @@ -0,0 +1,4 @@ + +This is a custom about page built by Greenwood.
+ diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/pages.md b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/pages.md deleted file mode 100644 index 2682ce0bb..000000000 --- a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/pages.md +++ /dev/null @@ -1,3 +0,0 @@ -## Pages page - -This is a custom about page built by Greenwood. \ No newline at end of file diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index-hooks.html b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index-hooks.html new file mode 100644 index 000000000..b7bd12a98 --- /dev/null +++ b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index-hooks.html @@ -0,0 +1,4 @@ + +Some more Lorum Ipsum.
+ diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index-hooks.md b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index-hooks.md deleted file mode 100644 index 82aa3bb6b..000000000 --- a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index-hooks.md +++ /dev/null @@ -1,3 +0,0 @@ -## Index Hooks - -Some more Lorum Ipsum. \ No newline at end of file diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index.html b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index.html new file mode 100644 index 000000000..d45e64699 --- /dev/null +++ b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index.html @@ -0,0 +1,4 @@ + +Lorum Ipsum
+ diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index.md b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index.md deleted file mode 100644 index 01e43c002..000000000 --- a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/src/pages/plugins/index.md +++ /dev/null @@ -1,3 +0,0 @@ -## Plugins - -Lorum Ipsum \ No newline at end of file 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 ff84f0d3c..acf342220 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 @@ -15,9 +15,9 @@ * src/ * pages/ * slides/ - * index.md - * about-me.md - * index.md + * index.html + * about-me.html + * index.html */ import chai from "chai"; import glob from "glob-promise"; @@ -126,7 +126,7 @@ describe("Build Greenwood With: ", function () { ); }); - it("should have expected text from user workspace pages/index.md", function () { + it("should have expected text from user workspace about-me.md", function () { const pageHeadingPrimary = dom.window.document.querySelectorAll("body h3")[0]; const pageHeadingSecondary = dom.window.document.querySelectorAll("body p")[0]; @@ -158,12 +158,14 @@ describe("Build Greenwood With: ", function () { ); }); - it("should have expected text from user workspace pages/index.md", function () { + it("should have expected text from user workspace slides/index.html", function () { const pageHeadingPrimary = dom.window.document.querySelectorAll("body h3")[0]; const pageHeadingSecondary = dom.window.document.querySelectorAll("body h4")[0]; expect(pageHeadingPrimary.textContent).to.be.equal("Title Page"); - expect(pageHeadingSecondary.textContent).to.be.equal("Some content from title.md."); + expect(pageHeadingSecondary.textContent).to.be.equal( + "Some content from slides/index.html.", + ); }); }); diff --git a/packages/cli/test/cases/build.plugins.context/src/pages/about-me.html b/packages/cli/test/cases/build.plugins.context/src/pages/about-me.html new file mode 100644 index 000000000..1a0a9bd46 --- /dev/null +++ b/packages/cli/test/cases/build.plugins.context/src/pages/about-me.html @@ -0,0 +1,4 @@ + +Hello from me!
+ diff --git a/packages/cli/test/cases/build.plugins.context/src/pages/about-me.md b/packages/cli/test/cases/build.plugins.context/src/pages/about-me.md deleted file mode 100644 index 143b70633..000000000 --- a/packages/cli/test/cases/build.plugins.context/src/pages/about-me.md +++ /dev/null @@ -1,3 +0,0 @@ -### About Me - -Hello from me! \ No newline at end of file diff --git a/packages/cli/test/cases/build.plugins.context/src/pages/index.html b/packages/cli/test/cases/build.plugins.context/src/pages/index.html new file mode 100644 index 000000000..f6f4e0175 --- /dev/null +++ b/packages/cli/test/cases/build.plugins.context/src/pages/index.html @@ -0,0 +1,8 @@ +--- +layout: index +--- + + +Lorem ipsum.
+ diff --git a/packages/cli/test/cases/build.plugins.source/src/pages/about.md b/packages/cli/test/cases/build.plugins.source/src/pages/about.md deleted file mode 100644 index 4093eb641..000000000 --- a/packages/cli/test/cases/build.plugins.source/src/pages/about.md +++ /dev/null @@ -1,3 +0,0 @@ -# About Us - -Lorem ipsum. \ No newline at end of file diff --git a/packages/cli/test/cases/build.plugins.source/src/pages/index.html b/packages/cli/test/cases/build.plugins.source/src/pages/index.html new file mode 100644 index 000000000..07673d6e2 --- /dev/null +++ b/packages/cli/test/cases/build.plugins.source/src/pages/index.html @@ -0,0 +1,4 @@ + +Welcome!
+ diff --git a/packages/cli/test/cases/build.plugins.source/src/pages/index.md b/packages/cli/test/cases/build.plugins.source/src/pages/index.md deleted file mode 100644 index 46c5f357e..000000000 --- a/packages/cli/test/cases/build.plugins.source/src/pages/index.md +++ /dev/null @@ -1,3 +0,0 @@ -## Home Page - -Welcome! \ No newline at end of file diff --git a/packages/cli/test/cases/build.typescript.default/build.typescript.default.spec.js b/packages/cli/test/cases/build.typescript.default/build.typescript.default.spec.js index f959c6c2a..6bbcb2ad1 100644 --- a/packages/cli/test/cases/build.typescript.default/build.typescript.default.spec.js +++ b/packages/cli/test/cases/build.typescript.default/build.typescript.default.spec.js @@ -16,6 +16,9 @@ * layouts/ * app.ts * pages/ + * blog/ + * index.html + *. contact.html * index.html * scripts/ * main.ts diff --git a/packages/cli/test/cases/build.typescript.default/src/pages/blog/index.html b/packages/cli/test/cases/build.typescript.default/src/pages/blog/index.html new file mode 100644 index 000000000..5c65ebba5 --- /dev/null +++ b/packages/cli/test/cases/build.typescript.default/src/pages/blog/index.html @@ -0,0 +1,8 @@ +--- +layout: "blog" +--- + + +Lorum Ipsum
+ diff --git a/packages/cli/test/cases/build.typescript.default/src/pages/blog/index.md b/packages/cli/test/cases/build.typescript.default/src/pages/blog/index.md deleted file mode 100644 index e59242fcf..000000000 --- a/packages/cli/test/cases/build.typescript.default/src/pages/blog/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: "blog" ---- - -### My Blog Posts - -Lorum Ipsum diff --git a/packages/cli/test/cases/build.typescript.default/src/pages/contact.html b/packages/cli/test/cases/build.typescript.default/src/pages/contact.html new file mode 100644 index 000000000..d56ddf7a9 --- /dev/null +++ b/packages/cli/test/cases/build.typescript.default/src/pages/contact.html @@ -0,0 +1,4 @@ + +Please reach out!
+ diff --git a/packages/cli/test/cases/build.typescript.default/src/pages/contact.md b/packages/cli/test/cases/build.typescript.default/src/pages/contact.md deleted file mode 100644 index b86349628..000000000 --- a/packages/cli/test/cases/build.typescript.default/src/pages/contact.md +++ /dev/null @@ -1,3 +0,0 @@ -### Contact Page - -Please reach out! diff --git a/packages/cli/test/cases/develop.config.active-content/develop.config.active-content.spec.js b/packages/cli/test/cases/develop.config.active-content/develop.config.active-content.spec.js index 809385176..97dab8273 100644 --- a/packages/cli/test/cases/develop.config.active-content/develop.config.active-content.spec.js +++ b/packages/cli/test/cases/develop.config.active-content/develop.config.active-content.spec.js @@ -21,8 +21,8 @@ * toc.js * pages/ * blog/ - * first-post.md - * second-post.md + * first-post.html + * second-post.html * index.html * contact.html * index.html diff --git a/packages/cli/test/cases/develop.config.active-content/src/pages/blog/first-post.html b/packages/cli/test/cases/develop.config.active-content/src/pages/blog/first-post.html new file mode 100644 index 000000000..2c7a8c989 --- /dev/null +++ b/packages/cli/test/cases/develop.config.active-content/src/pages/blog/first-post.html @@ -0,0 +1,4 @@ + +Lorum Ipsum
+ diff --git a/packages/cli/test/cases/develop.config.active-content/src/pages/blog/first-post.md b/packages/cli/test/cases/develop.config.active-content/src/pages/blog/first-post.md deleted file mode 100644 index 2f41b6873..000000000 --- a/packages/cli/test/cases/develop.config.active-content/src/pages/blog/first-post.md +++ /dev/null @@ -1,3 +0,0 @@ -# First Post - -Lorum Ipsum \ No newline at end of file diff --git a/packages/cli/test/cases/develop.config.active-content/src/pages/blog/second-post.html b/packages/cli/test/cases/develop.config.active-content/src/pages/blog/second-post.html new file mode 100644 index 000000000..c7654d899 --- /dev/null +++ b/packages/cli/test/cases/develop.config.active-content/src/pages/blog/second-post.html @@ -0,0 +1,4 @@ + +Lorum Ipsum
+ diff --git a/packages/cli/test/cases/develop.config.active-content/src/pages/blog/second-post.md b/packages/cli/test/cases/develop.config.active-content/src/pages/blog/second-post.md deleted file mode 100644 index ba4dc1e04..000000000 --- a/packages/cli/test/cases/develop.config.active-content/src/pages/blog/second-post.md +++ /dev/null @@ -1,3 +0,0 @@ -# Second Post - -Lorum Ipsum \ No newline at end of file diff --git a/packages/cli/test/cases/develop.default/import-map.snapshot.json b/packages/cli/test/cases/develop.default/import-map.snapshot.json index 1c071c95f..2d2c3e902 100644 --- a/packages/cli/test/cases/develop.default/import-map.snapshot.json +++ b/packages/cli/test/cases/develop.default/import-map.snapshot.json @@ -4213,8 +4213,7 @@ "robust-predicates": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/robust-predicates/index.js", "d3-dsv/umd": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/d3-dsv/dist/d3-dsv.min.js", "d3-dsv": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/d3-dsv/src/index.js", - "commander": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/commander/esm.mjs", - "commander/esm.mjs": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/commander/esm.mjs", + "commander": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/commander/index", "iconv-lite": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/iconv-lite/lib/index.js", "safer-buffer": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/safer-buffer/safer.js", "rw": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rw/index.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 106b576c8..ffd20dfd2 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 @@ -15,8 +15,8 @@ * src/ * pages/ * slides/ - * index.md - * index.md + * index.html + * index.html */ import chai from "chai"; import fs from "node:fs"; @@ -94,12 +94,14 @@ describe("Develop Greenwood With: ", function () { done(); }); - it("should have expected text from user workspace pages/index.md", function (done) { + it("should have expected text from user workspace pages/index.html", function (done) { const pageHeadingPrimary = dom.window.document.querySelectorAll("body h3")[0]; const pageHeadingSecondary = dom.window.document.querySelectorAll("body h4")[0]; expect(pageHeadingPrimary.textContent).to.be.equal("Context Plugin Theme Pack Test"); - expect(pageHeadingSecondary.textContent).to.be.equal("From user workspace pages/index.md"); + expect(pageHeadingSecondary.textContent).to.be.equal( + "From user workspace pages/index.html", + ); done(); }); }); diff --git a/packages/cli/test/cases/develop.plugins.context/src/pages/index.html b/packages/cli/test/cases/develop.plugins.context/src/pages/index.html new file mode 100644 index 000000000..b453c7611 --- /dev/null +++ b/packages/cli/test/cases/develop.plugins.context/src/pages/index.html @@ -0,0 +1,4 @@ + +This is the about page built by Greenwood.
+ diff --git a/packages/cli/test/cases/serve.config.static-router/serve.config.static-router.spec.js b/packages/cli/test/cases/serve.config.static-router/serve.config.static-router.spec.js index d705e2237..8c63676de 100644 --- a/packages/cli/test/cases/serve.config.static-router/serve.config.static-router.spec.js +++ b/packages/cli/test/cases/serve.config.static-router/serve.config.static-router.spec.js @@ -17,9 +17,9 @@ * User Workspace * src/ * pages/ - * about.md + * about.html * artists.js - * index.md + * index.html */ import chai from "chai"; import path from "node:path"; diff --git a/packages/cli/test/cases/serve.config.static-router/src/pages/about.html b/packages/cli/test/cases/serve.config.static-router/src/pages/about.html new file mode 100644 index 000000000..e77143df8 --- /dev/null +++ b/packages/cli/test/cases/serve.config.static-router/src/pages/about.html @@ -0,0 +1,10 @@ +--- +layout: test +--- + + + +This is the about page built by Greenwood.
+ + 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 deleted file mode 100644 index 5618aaa66..000000000 --- a/packages/cli/test/cases/serve.config.static-router/src/pages/about.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: test ---- - -### Greenwood - -This is the about page built by Greenwood. \ No newline at end of file diff --git a/packages/cli/test/cases/serve.config.static-router/src/pages/index.html b/packages/cli/test/cases/serve.config.static-router/src/pages/index.html new file mode 100644 index 000000000..36ec8b7f6 --- /dev/null +++ b/packages/cli/test/cases/serve.config.static-router/src/pages/index.html @@ -0,0 +1,6 @@ + + +This is the home page built by Greenwood.
+ + diff --git a/packages/cli/test/cases/serve.config.static-router/src/pages/index.md b/packages/cli/test/cases/serve.config.static-router/src/pages/index.md deleted file mode 100644 index b17b38a67..000000000 --- a/packages/cli/test/cases/serve.config.static-router/src/pages/index.md +++ /dev/null @@ -1,3 +0,0 @@ -### Greenwood - -This is the home page built by Greenwood. \ No newline at end of file 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 13e1b8bd2..3ec7f2cf1 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,6 +18,7 @@ * footer.js * pages/ * artists.js + * index.html * layouts/ * app.html */ diff --git a/packages/cli/test/cases/serve.default.ssr-static-export/src/pages/index.html b/packages/cli/test/cases/serve.default.ssr-static-export/src/pages/index.html new file mode 100644 index 000000000..f992333dd --- /dev/null +++ b/packages/cli/test/cases/serve.default.ssr-static-export/src/pages/index.html @@ -0,0 +1,6 @@ + + +Lorum Ipsum.
+ + diff --git a/packages/cli/test/cases/serve.default.ssr-static-export/src/pages/index.md b/packages/cli/test/cases/serve.default.ssr-static-export/src/pages/index.md deleted file mode 100644 index 5fa8f5c5d..000000000 --- a/packages/cli/test/cases/serve.default.ssr-static-export/src/pages/index.md +++ /dev/null @@ -1,3 +0,0 @@ -## Hello SSR - -Lorum Ipsum. \ 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 0c2628728..e7638de22 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 @@ -21,7 +21,7 @@ * images/ * logo.svg * pages/ - * about.md + * about.html * artists.js * blog/ * first-post.js diff --git a/packages/cli/test/cases/serve.default.ssr/src/pages/about.md b/packages/cli/test/cases/serve.default.ssr/src/pages/about.html similarity index 70% rename from packages/cli/test/cases/serve.default.ssr/src/pages/about.md rename to packages/cli/test/cases/serve.default.ssr/src/pages/about.html index 2a1e84a6f..f8551a27f 100644 --- a/packages/cli/test/cases/serve.default.ssr/src/pages/about.md +++ b/packages/cli/test/cases/serve.default.ssr/src/pages/about.html @@ -7,4 +7,6 @@ order: 1 --- -# Welcome to the about page! \ No newline at end of file + +Lorum Ipsum, this is a test.
+ diff --git a/packages/cli/test/cases/theme-pack/src/pages/index.md b/packages/cli/test/cases/theme-pack/src/pages/index.md deleted file mode 100644 index fe28153e0..000000000 --- a/packages/cli/test/cases/theme-pack/src/pages/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: 'blog-post' ---- - -## Title of blog post - -Lorum Ipsum, this is a test. \ No newline at end of file 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 ddef5d564..793bb1463 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 @@ -21,7 +21,7 @@ * my-layouts/ * blog-post.html * pages/ - * index.md + * index.html * styles/ * theme.css */ 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 2f1ab2dfb..b71121725 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 @@ -21,7 +21,7 @@ * layouts/ * blog-post.html * pages/ - * index.md + * index.html * styles/ * theme.css */ diff --git a/packages/plugin-graphql/README.md b/packages/plugin-graphql/README.md index abff706ab..1417936da 100644 --- a/packages/plugin-graphql/README.md +++ b/packages/plugin-graphql/README.md @@ -12,6 +12,8 @@ As of now, this plugin requires some form of [prerendering](https://www.greenwoo 1. Enabling [custom imports](https://www.greenwoodjs.dev/docs/pages/server-rendering/#custom-imports), or 1. Installing the [Puppeteer renderer plugin](https://github.com/ProjectEvergreen/greenwood/tree/master/packages/plugin-renderer-puppeteer) +It will also require setting [`activeContent`](https://greenwoodjs.dev/docs/reference/configuration/#active-content) to `true`. + ## Installation You can use your favorite JavaScript package manager to install this package. @@ -36,6 +38,7 @@ import { greenwoodPluginGraphQL } from '@greenwood/plugin-graphql'; import { greenwoodPluginRendererPuppeteer } from '@greenwood/plugin-renderer-puppeteer'; export default { + activeContent: true, prerender: true, plugins: [ greenwoodPluginGraphQL(), diff --git a/packages/plugin-graphql/src/schema/graph.js b/packages/plugin-graphql/src/schema/graph.js index 29bca1707..78995eb5d 100644 --- a/packages/plugin-graphql/src/schema/graph.js +++ b/packages/plugin-graphql/src/schema/graph.js @@ -1,21 +1,24 @@ import gql from "graphql-tag"; +import { + filterContentByCollection, + filterContentByRoute, +} from "@greenwood/cli/src/lib/content-utils.js"; -const getCollection = (root, { name, orderBy }, context) => { +const getCollection = async (root, { name, orderBy }, context) => { const { graph } = context; + const content = filterContentByCollection(graph, name); let items = []; - graph.forEach((page) => { + content.forEach((page) => { const { data, label, title } = page; - const { collection, tableOfContents, tocHeading } = data; + const { tableOfContents, tocHeading } = data; const toc = getParsedHeadingsFromPage(tableOfContents, tocHeading); - if (collection === name) { - items.push({ ...page, title: title || label, tableOfContents: toc }); - } + items.push({ ...page, title: title || label, tableOfContents: toc }); }); if (orderBy) { - items = sortCollection(items, orderBy); + return sortCollection(items, orderBy); } return items; @@ -50,41 +53,24 @@ const sortCollection = (collection, orderBy) => { return collection.sort(compare); }; -const getParsedHeadingsFromPage = (tableOfContents = [], headingLevel) => { +const getParsedHeadingsFromPage = (tableOfContents = []) => { let children = []; - if (tableOfContents.length > 0 && headingLevel > 0) { - tableOfContents.forEach(({ content, slug, lvl }) => { - // make sure we only add heading elements of the same level (h1, h2, h3) - if (lvl === headingLevel) { - children.push({ label: content, route: "#" + slug }); - } - }); - } + tableOfContents.forEach(({ content, slug }) => { + children.push({ label: content, route: "#" + slug }); + }); return children; }; const getPagesFromGraph = async (root, query, context) => { - return Promise.resolve(context.graph); + return context.graph; }; const getChildrenFromParentRoute = async (root, query, context) => { - const pages = []; const { parent } = query; - const { graph } = context; - // TODO handle base path - // const { basePath } = context.config; - - graph.forEach((page) => { - const { route } = page; - - if (`${parent}/` !== route && route.startsWith(parent)) { - pages.push(page); - } - }); - return Promise.resolve(pages); + return filterContentByRoute(context.graph, parent); }; const graphTypeDefs = gql` diff --git a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/greenwood.config.js b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/greenwood.config.js index 8886ba3ee..c607bb446 100644 --- a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/greenwood.config.js +++ b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/greenwood.config.js @@ -1,6 +1,7 @@ import { greenwoodPluginGraphQL } from "../../../src/index.js"; export default { + activeContent: true, prerender: true, plugins: [greenwoodPluginGraphQL()], }; diff --git a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/loaders-prerender.query-children.spec.js b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/loaders-prerender.query-children.spec.js index 5f6403fa7..b54a08483 100644 --- a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/loaders-prerender.query-children.spec.js +++ b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/loaders-prerender.query-children.spec.js @@ -56,7 +56,7 @@ describe("Build Greenwood With: ", function () { runner.runCommand(cliPath, "build"); }); - runSmokeTest(["public", "index"], LABEL); + runSmokeTest(["public"], LABEL); describe("Home Page output w/ ChildrenQuery", function () { let dom; diff --git a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/components/posts-list.js b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/components/posts-list.js index 477b0e36e..d6665bfea 100644 --- a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/components/posts-list.js +++ b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/components/posts-list.js @@ -1,14 +1,16 @@ import client from "@greenwood/plugin-graphql/src/core/client.js"; -import ChildrenQuery from "@greenwood/plugin-graphql/src/queries/children.gql" with { type: "gql" }; +import ChildrenQuery from "@greenwood/plugin-graphql/src/queries/children.gql"; export default class PostsList extends HTMLElement { async connectedCallback() { const response = await client.query({ query: ChildrenQuery, variables: { - parent: "/blog", + parent: "/blog/", }, }); + console.log({ response }); + console.log(response.errors); const posts = response.data.children; this.innerHTML = ` diff --git a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/first-post/index.html b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/first-post/index.html new file mode 100644 index 000000000..eb706d979 --- /dev/null +++ b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/first-post/index.html @@ -0,0 +1,12 @@ +--- +title: "First" +--- + + + +Lorem Ipsum
+ + back + + diff --git a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/first-post/index.md b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/first-post/index.md deleted file mode 100644 index 8af878ee7..000000000 --- a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/first-post/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: 'First' ---- - -## My First Blog Post -Lorem Ipsum - -[back](/) \ No newline at end of file diff --git a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/second-post/index.html b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/second-post/index.html new file mode 100644 index 000000000..8426ef9bb --- /dev/null +++ b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/second-post/index.html @@ -0,0 +1,12 @@ +--- +title: "Second" +--- + + + +Lorem Ipsum
+ + back + + diff --git a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/second-post/index.md b/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/second-post/index.md deleted file mode 100644 index d64aad85e..000000000 --- a/packages/plugin-graphql/test/cases/loaders-prerender.query-children/src/pages/blog/second-post/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: 'Second' ---- - -## My Second Blog Post -Lorem Ipsum - -[back](/) \ No newline at end of file diff --git a/packages/plugin-graphql/test/cases/qraphql-server/greenwood.config.js b/packages/plugin-graphql/test/cases/qraphql-server/greenwood.config.js index 2bb86279c..d24c4396b 100644 --- a/packages/plugin-graphql/test/cases/qraphql-server/greenwood.config.js +++ b/packages/plugin-graphql/test/cases/qraphql-server/greenwood.config.js @@ -1,5 +1,6 @@ import { greenwoodPluginGraphQL } from "../../../src/index.js"; export default { + activeContent: true, plugins: [...greenwoodPluginGraphQL()], }; diff --git a/packages/plugin-graphql/test/cases/query-children/greenwood.config.js b/packages/plugin-graphql/test/cases/query-children/greenwood.config.js index 751886e48..0b673d5e3 100644 --- a/packages/plugin-graphql/test/cases/query-children/greenwood.config.js +++ b/packages/plugin-graphql/test/cases/query-children/greenwood.config.js @@ -2,6 +2,7 @@ import { greenwoodPluginGraphQL } from "../../../src/index.js"; import { greenwoodPluginRendererPuppeteer } from "@greenwood/plugin-renderer-puppeteer"; export default { + activeContent: true, prerender: true, plugins: [greenwoodPluginGraphQL(), greenwoodPluginRendererPuppeteer()], }; diff --git a/packages/plugin-graphql/test/cases/query-children/query-children.spec.js b/packages/plugin-graphql/test/cases/query-children/query-children.spec.js deleted file mode 100644 index 3dbb36cc8..000000000 --- a/packages/plugin-graphql/test/cases/query-children/query-children.spec.js +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Use Case - * Run Greenwood build command with GraphQL calls to get data about the projects graph using ChildrenQuery. - * - * Needs prerender to be true to get SSR and client side GQL fetching. - * - * User Result - * Should generate a Greenwood build that tests basic output from the ChildrenQuery. - * - * User Command - * greenwood build - * - * Default Config (+ plugin-graphql and prerender) - * - * Custom Workspace - * src/ - * components/ - * posts-list.js - * pages/ - * blog/ - * first-post/ - * index.md - * second-post/ - * index.md - * index.html - */ -import chai from "chai"; -import fs from "node:fs"; -import glob from "glob-promise"; -import { JSDOM } from "jsdom"; -import path from "node:path"; -import { runSmokeTest } from "../../../../../test/smoke-test.js"; -import { getOutputTeardownFiles } from "../../../../../test/utils.js"; -import { Runner } from "gallinago"; -import { fileURLToPath } from "node:url"; - -const expect = chai.expect; - -describe("Build Greenwood With: ", function () { - const LABEL = "Children from GraphQL"; - const apolloStateRegex = /window.__APOLLO_STATE__ = true/; - const cliPath = path.join(process.cwd(), "packages/cli/src/bin.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); - runner.runCommand(cliPath, "build"); - }); - - runSmokeTest(["public", "index"], LABEL); - - describe("Home Page output w/ ChildrenQuery", function () { - let dom; - - before(async function () { - dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, "index.html")); - }); - - it("should have one window.__APOLLO_STATE__ + + +Hello from me!
+ diff --git a/packages/plugin-markdown/test/cases/build.plugins.context/src/pages/index.html b/packages/plugin-markdown/test/cases/build.plugins.context/src/pages/index.html new file mode 100644 index 000000000..bd8107441 --- /dev/null +++ b/packages/plugin-markdown/test/cases/build.plugins.context/src/pages/index.html @@ -0,0 +1,8 @@ +--- +layout: index +--- + + +Hello from the greeting component!
+`; + +class GreetingComponent extends HTMLElement { + constructor() { + super(); + this.attachShadow({ mode: "open" }); + } + + async connectedCallback() { + this.shadowRoot.appendChild(template.content.cloneNode(true)); + } +} + +customElements.define("x-greeting", GreetingComponent); diff --git a/packages/cli/test/cases/build.default.markdown/src/layouts/app.html b/packages/plugin-markdown/test/cases/develop.plugins.context/fixtures/my-layouts/app.html similarity index 56% rename from packages/cli/test/cases/build.default.markdown/src/layouts/app.html rename to packages/plugin-markdown/test/cases/develop.plugins.context/fixtures/my-layouts/app.html index 618531563..d8c9551d8 100644 --- a/packages/cli/test/cases/build.default.markdown/src/layouts/app.html +++ b/packages/plugin-markdown/test/cases/develop.plugins.context/fixtures/my-layouts/app.html @@ -1,10 +1,14 @@ +Lorem Ipsum
+ + back + + 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 deleted file mode 100644 index 6b222d070..000000000 --- a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/first-post.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -layout: 'blog' ---- - -## My First Blog Post -Lorem Ipsum - -[back](/) \ No newline at end of file diff --git a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/second-post.html b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/second-post.html new file mode 100644 index 000000000..bd47739de --- /dev/null +++ b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/second-post.html @@ -0,0 +1,12 @@ +--- +layout: "blog" +--- + + + +Lorem Ipsum
+ + back + + 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 deleted file mode 100644 index 313dc1f59..000000000 --- a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/blog/second-post.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -layout: 'blog' ---- - -## My Second Blog Post -Lorem Ipsum - -[back](/) \ No newline at end of file diff --git a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/index.html b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/index.html new file mode 100644 index 000000000..9f2e58a72 --- /dev/null +++ b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/src/pages/index.html @@ -0,0 +1,16 @@ + + +This is the Getting Started home page!
+ +