diff --git a/package-lock.json b/package-lock.json index 4a910357f8..0f03eeb1e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4714,6 +4714,66 @@ "@octokit/openapi-types": "^16.0.0" } }, + "node_modules/@pagefind/darwin-arm64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/darwin-arm64/-/darwin-arm64-1.0.4.tgz", + "integrity": "sha512-2OcthvceX2xhm5XbgOmW+lT45oLuHqCmvFeFtxh1gsuP5cO8vcD8ZH8Laj4pXQFCcK6eAdSShx+Ztx/LsQWZFQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@pagefind/darwin-x64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/darwin-x64/-/darwin-x64-1.0.4.tgz", + "integrity": "sha512-xkdvp0D9Ld/ZKsjo/y1bgfhTEU72ITimd2PMMQtts7jf6JPIOJbsiErCvm37m/qMFuPGEq/8d+fZ4pydOj08HQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@pagefind/linux-arm64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/linux-arm64/-/linux-arm64-1.0.4.tgz", + "integrity": "sha512-jGBrcCzIrMnNxLKVtogaQyajVfTAXM59KlBEwg6vTn8NW4fQ6nuFbbhlG4dTIsaamjEM5e8ZBEAKZfTB/qd9xw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@pagefind/linux-x64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/linux-x64/-/linux-x64-1.0.4.tgz", + "integrity": "sha512-LIn/QcvcEtLEBqKe5vpSbSC2O3fvqbRCWOTIklslqSORisCsvzsWbP6j+LYxE9q0oWIfkdMoWV1vrE/oCKRxHg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@pagefind/windows-x64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/windows-x64/-/windows-x64-1.0.4.tgz", + "integrity": "sha512-QlBCVeZfj9fc9sbUgdOz76ZDbeK4xZihOBAFqGuRJeChfM8pnVeH9iqSnXgO3+m9oITugTf7PicyRUFAG76xeQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@parcel/watcher": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.0.4.tgz", @@ -17845,6 +17905,21 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/pagefind": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/pagefind/-/pagefind-1.0.4.tgz", + "integrity": "sha512-oRIizYe+zSI2Jw4zcMU0ebDZm27751hRFiSOBLwc1OIYMrsZKk+3m8p9EVaOmc6zZdtqwwdilNUNxXvBeHcP9w==", + "bin": { + "pagefind": "lib/runner/bin.cjs" + }, + "optionalDependencies": { + "@pagefind/darwin-arm64": "1.0.4", + "@pagefind/darwin-x64": "1.0.4", + "@pagefind/linux-arm64": "1.0.4", + "@pagefind/linux-x64": "1.0.4", + "@pagefind/windows-x64": "1.0.4" + } + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -23833,6 +23908,7 @@ "fs-extra": "^9.0.1", "live-server": "1.2.1", "lodash": "^4.17.15", + "pagefind": "^1.0.4", "url-parse": "^1.5.10", "winston": "^2.4.4", "winston-daily-rotate-file": "^3.10.0" @@ -23902,6 +23978,7 @@ "material-icons": "^1.9.1", "moment": "^2.29.4", "nunjucks": "3.2.4", + "pagefind": "^1.0.4", "path-is-inside": "^1.0.2", "simple-git": "^3.22.0", "url-parse": "^1.5.10", @@ -26620,6 +26697,7 @@ "memfs": "^3.0.1", "moment": "^2.29.4", "nunjucks": "3.2.4", + "pagefind": "^1.0.4", "path-is-inside": "^1.0.2", "simple-git": "^3.22.0", "ts-jest": "^27.1.4", @@ -27901,6 +27979,36 @@ "@octokit/openapi-types": "^16.0.0" } }, + "@pagefind/darwin-arm64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/darwin-arm64/-/darwin-arm64-1.0.4.tgz", + "integrity": "sha512-2OcthvceX2xhm5XbgOmW+lT45oLuHqCmvFeFtxh1gsuP5cO8vcD8ZH8Laj4pXQFCcK6eAdSShx+Ztx/LsQWZFQ==", + "optional": true + }, + "@pagefind/darwin-x64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/darwin-x64/-/darwin-x64-1.0.4.tgz", + "integrity": "sha512-xkdvp0D9Ld/ZKsjo/y1bgfhTEU72ITimd2PMMQtts7jf6JPIOJbsiErCvm37m/qMFuPGEq/8d+fZ4pydOj08HQ==", + "optional": true + }, + "@pagefind/linux-arm64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/linux-arm64/-/linux-arm64-1.0.4.tgz", + "integrity": "sha512-jGBrcCzIrMnNxLKVtogaQyajVfTAXM59KlBEwg6vTn8NW4fQ6nuFbbhlG4dTIsaamjEM5e8ZBEAKZfTB/qd9xw==", + "optional": true + }, + "@pagefind/linux-x64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/linux-x64/-/linux-x64-1.0.4.tgz", + "integrity": "sha512-LIn/QcvcEtLEBqKe5vpSbSC2O3fvqbRCWOTIklslqSORisCsvzsWbP6j+LYxE9q0oWIfkdMoWV1vrE/oCKRxHg==", + "optional": true + }, + "@pagefind/windows-x64": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pagefind/windows-x64/-/windows-x64-1.0.4.tgz", + "integrity": "sha512-QlBCVeZfj9fc9sbUgdOz76ZDbeK4xZihOBAFqGuRJeChfM8pnVeH9iqSnXgO3+m9oITugTf7PicyRUFAG76xeQ==", + "optional": true + }, "@parcel/watcher": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.0.4.tgz", @@ -36028,6 +36136,7 @@ "live-server": "1.2.1", "lodash": "^4.17.15", "memfs": "^3.0.1", + "pagefind": "^1.0.4", "url-parse": "^1.5.10", "walk-sync": "^2.0.2", "winston": "^2.4.4", @@ -38098,6 +38207,18 @@ } } }, + "pagefind": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/pagefind/-/pagefind-1.0.4.tgz", + "integrity": "sha512-oRIizYe+zSI2Jw4zcMU0ebDZm27751hRFiSOBLwc1OIYMrsZKk+3m8p9EVaOmc6zZdtqwwdilNUNxXvBeHcP9w==", + "requires": { + "@pagefind/darwin-arm64": "1.0.4", + "@pagefind/darwin-x64": "1.0.4", + "@pagefind/linux-arm64": "1.0.4", + "@pagefind/linux-x64": "1.0.4", + "@pagefind/windows-x64": "1.0.4" + } + }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", diff --git a/packages/cli/package.json b/packages/cli/package.json index ce13dad804..8b11ec39ae 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -38,6 +38,7 @@ "fs-extra": "^9.0.1", "live-server": "1.2.1", "lodash": "^4.17.15", + "pagefind": "^1.0.4", "url-parse": "^1.5.10", "winston": "^2.4.4", "winston-daily-rotate-file": "^3.10.0" diff --git a/packages/cli/test/functional/test_site_pagefind/.gitignore b/packages/cli/test/functional/test_site_pagefind/.gitignore new file mode 100644 index 0000000000..3b8cd63a6d --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/.gitignore @@ -0,0 +1,23 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +_markbind/logs/ + +# Dependency directories +node_modules/ + +# Production +_site/ + +# Env +.env +.env.local + +# IDE configs +.vscode/ +.idea/* +*.iml diff --git a/packages/cli/test/functional/test_site_pagefind/404.md b/packages/cli/test/functional/test_site_pagefind/404.md new file mode 100644 index 0000000000..019786884d --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/404.md @@ -0,0 +1,7 @@ + + title: Page not found + layout: 404.md + + +->

404

<- +->

File not found
Click here to go back to the home page.

<- \ No newline at end of file diff --git a/packages/cli/test/functional/test_site_pagefind/_markbind/layouts/404.md b/packages/cli/test/functional/test_site_pagefind/_markbind/layouts/404.md new file mode 100644 index 0000000000..f5e54988e8 --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/_markbind/layouts/404.md @@ -0,0 +1 @@ +
{{ content }}
\ No newline at end of file diff --git a/packages/cli/test/functional/test_site_pagefind/_markbind/layouts/default.md b/packages/cli/test/functional/test_site_pagefind/_markbind/layouts/default.md new file mode 100644 index 0000000000..2507ae479e --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/_markbind/layouts/default.md @@ -0,0 +1,55 @@ + + + + +
+ + Your Logo +
  • Topic 1
  • +
  • Topic 2
  • + +
  • Topic 3a
  • +
  • Topic 3b
  • +
    +
  • + +
  • +
    +
    + +
    + +
    + + {{ content }} +
    + + +
    + + diff --git a/packages/cli/test/functional/test_site_pagefind/_markbind/variables.json b/packages/cli/test/functional/test_site_pagefind/_markbind/variables.json new file mode 100644 index 0000000000..04d0b977d3 --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/_markbind/variables.json @@ -0,0 +1,3 @@ +{ + "jsonVariableExample": "Your variables can be defined here as well" +} \ No newline at end of file diff --git a/packages/cli/test/functional/test_site_pagefind/_markbind/variables.md b/packages/cli/test/functional/test_site_pagefind/_markbind/variables.md new file mode 100644 index 0000000000..4a19d29999 --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/_markbind/variables.md @@ -0,0 +1,4 @@ + +To inject this HTML segment in your MarkBind files, use {{ example }} where you want to place it. +More generally, surround the segment's id with double curly braces. + \ No newline at end of file diff --git a/packages/cli/test/functional/test_site_pagefind/contents/topic1.md b/packages/cli/test/functional/test_site_pagefind/contents/topic1.md new file mode 100644 index 0000000000..3f28f03594 --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/contents/topic1.md @@ -0,0 +1,9 @@ + + title: Topic 1 + + +
    + +# Topic 1 + +> This is a placeholder page - more content to be added. diff --git a/packages/cli/test/functional/test_site_pagefind/contents/topic2.md b/packages/cli/test/functional/test_site_pagefind/contents/topic2.md new file mode 100644 index 0000000000..f86f7be568 --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/contents/topic2.md @@ -0,0 +1,9 @@ + + title: Topic 2 + + +
    + +# Topic 2 + +> This is a placeholder page - more content to be added. diff --git a/packages/cli/test/functional/test_site_pagefind/contents/topic3a.md b/packages/cli/test/functional/test_site_pagefind/contents/topic3a.md new file mode 100644 index 0000000000..90194da60a --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/contents/topic3a.md @@ -0,0 +1,9 @@ + + title: Topic 3a + + +
    + +# Topic 3a + +> This is a placeholder page - more content to be added. diff --git a/packages/cli/test/functional/test_site_pagefind/contents/topic3b.md b/packages/cli/test/functional/test_site_pagefind/contents/topic3b.md new file mode 100644 index 0000000000..db7ba8e857 --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/contents/topic3b.md @@ -0,0 +1,9 @@ + + title: Topic 3b + + +
    + +# Topic 3b + +> This is a placeholder page - more content to be added. diff --git a/packages/cli/test/functional/test_site_pagefind/index.md b/packages/cli/test/functional/test_site_pagefind/index.md new file mode 100755 index 0000000000..09177b769c --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/index.md @@ -0,0 +1,77 @@ + + title: Home Page + layout: default.md + pageNav: 4 + pageNavTitle: "Topics" + + +
    + +
    +
    +

    Great!
    You've just initialized a MarkBind site.

    +

    Let's get started...

    +
    +
    + +--- + +## What just happened? + +You have just initialized a _default_ MarkBind site! It is equipped with a set of core features, including site and page navigation. Additionally, we have included some convenient links to our User Guide, to help you get started quickly and easily. + + + +If you were intending to convert an existing GitHub wiki or a docs folder into MarkBind, use the `--convert` flag instead. See User Guide: MarkBind in the Project Workflow for more information. + +If you want to start with a _minimal_ template instead, use the `--template` flag with the "minimal" option to initialize a minimal site instead of the default. See User Guide: Templates for more information. + + + +--- + +## Navigating this site + +This _default_ site comes pre-configured with the core Navigation components: a **siteNav**, a **pageNav**, a **NavBar**, and a **Search Bar**. To help you get started with the **siteNav**, we have included five dummy placeholder pages. The **NavBar** also comes with a placeholder slot for your custom Logo. + +--- + +## Guide to MarkBind + +To see the capability of MarkBind in action, feel free to take a look at some of the websites built using MarkBind on our Showcase page. + +For more information on how to work with MarkBind sites and to add content, refer to our comprehensive User Guide. + + + +If you are interested in contributing to MarkBind, you can refer to our Developer Guide as well! + + + + + +##### **User Guide: Authoring Contents** + +> Learn about the variety of syntax schemes, formats, and custom MarkBind components that you can use in your MarkBind site. + +More info in: _User Guide → Authoring Contents_ + +--- + +##### **User Guide: Working with Sites** + +> Learn how to modify site properties, apply themes, and enable/disable plugins for your MarkBind site. + +More info in: _User Guide → Working with Sites_ + +--- + +##### **User Guide: Full Syntax Reference** + +> Refer to our Full Syntax Reference page to find a specific feature or component that you want to use in your MarkBind site. + +More info in: _User Guide → Full Syntax Reference_ + + + +--- diff --git a/packages/cli/test/functional/test_site_pagefind/site.json b/packages/cli/test/functional/test_site_pagefind/site.json new file mode 100755 index 0000000000..eb1d757851 --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/site.json @@ -0,0 +1,28 @@ +{ + "baseUrl": "", + "titlePrefix": "", + "titleSuffix": "", + "ignore": [ + "_markbind/layouts/*", + "_markbind/logs/*", + "_site/*", + "site.json", + "*.md", + "*.njk", + ".git/*", + ".gitignore", + "node_modules/*" + ], + "pagesExclude": ["node_modules/*"], + "pages": [ + { + "src": "index.md" + }, + { + "glob": ["**/index.md", "**/*.md"] + } + ], + "deploy": { + "message": "Site Update." + } +} diff --git a/packages/cli/test/functional/test_site_pagefind/stylesheets/main.css b/packages/cli/test/functional/test_site_pagefind/stylesheets/main.css new file mode 100644 index 0000000000..a380ffd4c2 --- /dev/null +++ b/packages/cli/test/functional/test_site_pagefind/stylesheets/main.css @@ -0,0 +1,135 @@ +mark { + background-color: #ff0; + border-radius: 5px; + padding-top: 0; + padding-bottom: 0; +} + +.indented { + padding-left: 20px; +} + +.theme-card img { + width: 100%; +} + +/* Scrollbar */ + +.slim-scroll::-webkit-scrollbar { + width: 5px; +} + +.slim-scroll::-webkit-scrollbar-thumb { + background: #808080; + border-radius: 20px; +} + +.slim-scroll::-webkit-scrollbar-track { + background: transparent; + border-radius: 20px; +} + +.slim-scroll-blue::-webkit-scrollbar { + width: 5px; +} + +.slim-scroll-blue::-webkit-scrollbar-thumb { + background: #00b0ef; + border-radius: 20px; +} + +.slim-scroll-blue::-webkit-scrollbar-track { + background: transparent; + border-radius: 20px; +} + +/* Layout containers */ + +#flex-body { + display: flex; + flex: 1; + align-items: start; +} + +#content-wrapper { + flex: 1; + margin: 0 auto; + min-width: 0; + max-width: 1000px; + overflow-x: auto; + padding: 0.8rem 20px 0; + transition: 0.4s; +} + +#site-nav, +#page-nav { + display: flex; + flex-direction: column; + position: sticky; + top: var(--sticky-header-height); + flex: 0 0 auto; + max-width: 300px; + max-height: calc(100vh - var(--sticky-header-height)); + width: 300px; +} + +#site-nav { + border-right: 1px solid lightgrey; + padding-bottom: 20px; + z-index: 999; +} + +.site-nav-top { + margin: 0.8rem 0; + padding: 0 12px 12px; +} + +.nav-component { + overflow-y: auto; +} + +#page-nav { + border-left: 1px solid lightgrey; +} + +@media screen and (width <= 1299.98px) { + #page-nav { + display: none; + } +} + +/* Bootstrap medium(md) responsive breakpoint */ +@media screen and (width <= 991.98px) { + #site-nav { + display: none; + } +} + +/* Bootstrap small(sm) responsive breakpoint */ +@media (width <= 767.98px) { + .indented { + padding-left: 10px; + } + + #content-wrapper { + padding: 0 10px; + } +} + +/* Bootstrap extra small(xs) responsive breakpoint */ +@media screen and (width <= 575.98px) { + #site-nav { + display: none; + } +} + +/* Hide site navigation when printing */ +@media print { + #site-nav { + display: none; + } + + #page-nav { + display: none; + } +} diff --git a/packages/core/package.json b/packages/core/package.json index 29bab65283..e15b65e2e5 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -63,6 +63,7 @@ "material-icons": "^1.9.1", "moment": "^2.29.4", "nunjucks": "3.2.4", + "pagefind": "^1.0.4", "path-is-inside": "^1.0.2", "simple-git": "^3.22.0", "url-parse": "^1.5.10", diff --git a/packages/core/src/Site/index.ts b/packages/core/src/Site/index.ts index 6f2ff4f220..6ee9d3e06b 100644 --- a/packages/core/src/Site/index.ts +++ b/packages/core/src/Site/index.ts @@ -529,6 +529,7 @@ export class Site { await this.copyOcticonsAsset(); await this.copyMaterialIconsAsset(); await this.writeSiteData(); + // await this.indexSiteWithPagefind(); this.calculateBuildTimeForGenerate(startTime, lazyWebsiteGenerationString); if (this.backgroundBuildMode) { this.backgroundBuildNotViewedFiles(); @@ -569,6 +570,23 @@ export class Site { } } + /** + * Indexes all the pages of the site using pagefind + async indexSiteWithPagefind() { + const { createIndex, close } = await import('pagefind'); //eslint-disable-line + const newIndex = await createIndex({ + keepIndexUrl: true, + verbose: true, + logfile: 'debug.log', + }); + const { index } = newIndex; + if (index) { + await index.addDirectory({ path: this.outputPath }); + await index.writeFiles({ outputPath: `${this.outputPath}/pagefind` }); + } + await close(); + } */ + /** * Adds all pages except the viewed pages to toRebuild, flagging them for lazy building later. */ diff --git a/packages/core/src/plugins/pageFind.ts b/packages/core/src/plugins/pageFind.ts new file mode 100644 index 0000000000..eeaebbfff2 --- /dev/null +++ b/packages/core/src/plugins/pageFind.ts @@ -0,0 +1,32 @@ +import cheerio from 'cheerio'; +import { PluginContext } from './Plugin'; + +const DEFAULT_UI = 'https://cdn.jsdelivr.net/npm/@pagefind/default-ui@1.0.4/+esm'; + +function addPagefindUI() { + return ` + + + +`; +} + +export = { + tagConfig: { + pagefind: { + isSpecial: true, + }, + }, + postRender: (pluginContext: PluginContext, content: string) => { + const $ = cheerio.load(content); + $('header').append(addPagefindUI()); + }, +};