diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a0efb43 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,44 @@ +version: 2 +updates: + # ------------------------------------------------------- + # 1. GitHub Actions (Universal for all your projects) + # Keeps your workflow files (checkout, setup-node) updated + # ------------------------------------------------------- + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + groups: + actions: + patterns: + - "*" + + # ------------------------------------------------------- + # 2. NPM (Specific to tree-fs / Node projects) + # ------------------------------------------------------- + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "weekly" + # Ignore major updates automatically to prevent breaking changes + # Remove this 'ignore' block if you want to see v1 -> v2 updates + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-major"] + groups: + # Group all minor/patch updates into one PR + npm-dependencies: + patterns: + - "*" + + # ------------------------------------------------------- + # 3. (Optional) Uncomment for Python projects + # ------------------------------------------------------- + # - package-ecosystem: "pip" + # directory: "/" + # schedule: + # interval: "weekly" + # groups: + # python-deps: + # patterns: + # - "*" \ No newline at end of file diff --git a/.github/workflows/deploy-docmd.yml b/.github/workflows/deploy-docmd.yml index 1650e01..a92231b 100644 --- a/.github/workflows/deploy-docmd.yml +++ b/.github/workflows/deploy-docmd.yml @@ -2,8 +2,8 @@ name: deploy docmd on: push: - branches: [main] # Your default branch - workflow_dispatch: # Allows manual triggering + branches: [main] + workflow_dispatch: permissions: contents: read @@ -18,25 +18,34 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} steps: - name: Checkout ποΈ - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Node.js βοΈ - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: '22' cache: 'npm' + - name: Update NPM to Latest π + run: npm install -g npm@latest + - name: Install Dependencies π¦ run: npm ci - + - name: Build docmd's Own Docs π οΈ run: node ./bin/docmd.js build + - name: Build Live Editor β‘ + run: node scripts/build-live.js + + - name: Inject Live Editor into Site + run: mv dist site/live + - name: Setup Pages uses: actions/configure-pages@v5 - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v4 with: path: ./site diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index ce0791e..c07ba56 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,49 +1,38 @@ -name: Publish Package to NPM and GitHub Packages +name: Publish package to npm on: release: types: [published] workflow_dispatch: +permissions: + contents: read + id-token: write + jobs: publish: runs-on: ubuntu-latest - permissions: - contents: read - packages: write + steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - - name: Set up Node.js v22 - uses: actions/setup-node@v4 + - name: Set up Node.js + uses: actions/setup-node@v6 with: node-version: '22' - cache: 'npm' + registry-url: 'https://registry.npmjs.org' + + - name: Ensure recent npm + run: npm install -g npm@latest - name: Install dependencies run: npm ci - # ------------------------------------------ - # --- Publish to NPM Registry (npmjs.com) --- - # ------------------------------------------ - - name: Configure NPM for public registry - run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc + - name: Run tests (optional) + run: npm test --if-present - - name: Publish to NPM Registry - run: npm publish --access=public + - name: Publish to npm + run: npm publish --access public # env: - # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - # ---------------------------------------- - # --- Publish to GitHub Packages (GPR) --- - # ---------------------------------------- - - name: Configure NPM for GitHub Packages registry - run: | - echo "@mgks:registry=https://npm.pkg.github.com" > ~/.npmrc - echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc - - - name: Publish to GitHub Packages - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index a2d4e80..3ca3569 100644 --- a/.gitignore +++ b/.gitignore @@ -137,3 +137,5 @@ ROADMAP.md .DS_Store genctx.json +genctx.config.json +genctx.context.md diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..7f0b8cb --- /dev/null +++ b/.npmignore @@ -0,0 +1,12 @@ +.git +.github +.DS_Store +.gitignore +.gitattributes +genctx.config.json +genctx.context.md +docs/ +assets/css/welcome.css +assets/images/preview-* +preview.gif +docmd-preview.png \ No newline at end of file diff --git a/README.md b/README.md index 0fcb9d5..7db9802 100644 --- a/README.md +++ b/README.md @@ -1,68 +1,63 @@ -
-
+
+
-
-
-
- The minimalist, zero-config documentation generator for Node.js developers.
-
- Turn Markdown into beautiful, blazing-fast websites in seconds.
-
-
+ The minimalist, zero-config documentation generator. +
+View Live Demo β’ - Documentation β’ + Read Documentation β’ + Live Editor β’ Report Bug
-
-
+
+
docmd noStyle page preview in dark mode
Error parsing markdown
'; + + const { frontmatter, htmlContent, headings } = result; + + const pageData = { + content: htmlContent, + frontmatter, + headings, + siteTitle: defaults.siteTitle, + pageTitle: frontmatter.title || 'Untitled', + description: frontmatter.description || '', + defaultMode: defaults.theme.defaultMode, + editUrl: null, + editLinkText: '', + navigationHtml: '', // Navigation is usually empty in a single-page preview + relativePathToRoot: options.relativePathToRoot || './', // Important for finding CSS in dist/assets + outputPath: 'index.html', + currentPagePath: '/index', + prevPage: null, nextPage: null, + config: defaults, + // Empty hooks + metaTagsHtml: '', faviconLinkHtml: '', themeCssLinkHtml: '', + pluginStylesHtml: '', pluginHeadScriptsHtml: '', pluginBodyScriptsHtml: '', + themeInitScript: '', + logo: defaults.logo, sidebarConfig: { collapsible: false }, theme: defaults.theme, + customCssFiles: [], customJsFiles: [], + sponsor: { enabled: false }, footer: '', footerHtml: '', + renderIcon: () => '', // Icons disabled in live preview to save weight + isActivePage: true + }; + + let templateName = frontmatter.noStyle === true ? 'no-style.ejs' : 'layout.ejs'; + const templateContent = templates[templateName]; + + if (!templateContent) return `Template ${templateName} not found`; + + const ejsOptions = { + includer: (originalPath) => { + let name = originalPath.endsWith('.ejs') ? originalPath : originalPath + '.ejs'; + if (templates[name]) return { template: templates[name] }; + return null; + } + }; + + return renderHtmlPage(templateContent, pageData, templateName, ejsOptions); +} + +module.exports = { compile }; \ No newline at end of file diff --git a/src/live/index.html b/src/live/index.html new file mode 100644 index 0000000..bf1aeef --- /dev/null +++ b/src/live/index.html @@ -0,0 +1,201 @@ + + + + + +