wedocs-plugin icon indicating copy to clipboard operation
wedocs-plugin copied to clipboard

feat: block doc navigation

Open sapayth opened this issue 2 months ago β€’ 2 comments

fixes #167

Show Previous Doc and Next Doc links at the bottom (or top) of a doc, helping users navigate between articles within the same section.

Summary by CodeRabbit

  • New Features

    • Added Doc Navigation block: server-rendered previous/next links with rich editor controls for SEO rel, typography, colors, borders, spacing and arrow styling; responsive preview.
  • Style

    • Bundled carousel styles into main CSS and added fallback styles for Doc Navigation when Tailwind is unavailable.
  • Chores

    • Bumped build asset versions and updated bundles for cache-busting.
  • Refactor

    • Modularized data layer/storage for improved editor/data stability.

sapayth avatar Sep 19 '25 11:09 sapayth

Walkthrough

Adds a server-rendered DocNavigation Gutenberg block (editor UI, styles, PHP renderer), registers it, modularizes the JavaScript data stores, updates build artifacts (webpack scaffolding, inlined CSS), adds wp-data to block dependencies, and bumps several asset version hashes.

Changes

Cohort / File(s) Summary of Changes
DocNavigation block (source & build)
src/blocks/DocNavigation/block.json, src/blocks/DocNavigation/edit.js, src/blocks/DocNavigation/index.js, src/blocks/DocNavigation/save.js, src/blocks/DocNavigation/style.scss, src/blocks/DocNavigation/render.php, assets/build/blocks/DocNavigation/block.json, assets/build/blocks/DocNavigation/render.php, assets/build/blocks/DocNavigation/*
New dynamic block wedocs/wedocs-doc-navigation: manifest, editor component with InspectorControls, fallback SCSS, server-side render PHP, save() returns null; block registered and renderer loaded in plugin.
Plugin integration
wedocs.php
Loads and registers the new DocNavigation block and its server render callback.
Doc navigation helpers
includes/functions.php
Adds wedocs_get_doc_navigation_posts( $post ) and refactors wedocs_doc_nav() to use it for next/prev doc resolution.
Data store modularization (source & build)
src/data/*, src/data/docs/*, src/data/settings/*, src/data/store.js, assets/build/store.js, assets/build/store.asset.php
Replaces monolithic store bundle with modular docs and settings stores, exports named constants and default stores, and registers stores via a new entry; asset version bump.
Block asset dependency change
assets/build/block.asset.php
Adds wp-data to block dependencies and updates version hash.
Webpack/runtime & CSS bundling changes (build)
assets/build/frontend.js, assets/build/print.js, assets/build/frontend.css, assets/build/print.css, assets/build/index.css
Adds webpack runtime scaffolding for CSS entries, loader header comments, inlines carousel CSS into index.css, and appends sourceMap references; no runtime behavior changes beyond bundler wiring.
Asset manifest version bumps
assets/build/frontend.asset.php, assets/build/index.asset.php, assets/build/print.asset.php, assets/build/block.asset.php, assets/build/store.asset.php
Updated version hashes for multiple build manifests; dependencies mostly unchanged except block.asset.php.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • weDevsOfficial/wedocs-plugin#203 β€” Refactors the plugin data layer to modular stores; overlaps with the store modularization in this PR.
  • weDevsOfficial/wedocs-plugin#209 β€” Adds/structures settings store modules; closely related to the new src/data/settings changes.

Suggested labels

QA Approved, Ready To Merge

Suggested reviewers

  • iftakharul-islam

Poem

"I nibble code and hop with delight,
New arrows point left and right.
Blocks blossom where pages meet,
Stores split neat like fresh spring wheat.
A whiskered cheer β€” docs now glide light!" πŸ‡βœ¨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The PR includes several changes that appear outside the stated objective of adding the DocNavigation block: most notably a large modularization of the built data store (assets/build/store.js with many new public exports) and numerous broad build-artifact changes (inlined carousel CSS, webpack runtime wrappers, and multiple asset version bumps). These architectural and generated-asset changes are not described in the linked issue and increase review surface and risk of unrelated regressions, so they appear out-of-scope for this feature PR. A focused feature PR should avoid bundling such large refactors or unrelated build noise without explicit justification. Either split the store refactor and other large changes into a separate PR or add a clear justification and tests in this PR explaining why they are required for the DocNavigation block; if the build outputs are incidental, restrict the commit to source changes and include only the minimal regenerated assets necessary for the new block. Also run regression tests and document any public API changes introduced by the new store layout.
βœ… Passed checks (4 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check βœ… Passed The title "feat: block doc navigation" is concise and accurately reflects the primary change β€” adding a document navigation Gutenberg block. It uses a conventional "feat" prefix and contains no extraneous detail, making it easy to scan in history. The title is specific enough for teammates to understand the main intention of the PR.
Linked Issues Check βœ… Passed The PR implements a server-rendered block (src/blocks/DocNavigation and assets/build/blocks/DocNavigation), an Edit component with InspectorControls exposing extensive styling attributes, a save() that returns null, a PHP renderer (render_wedocs_doc_navigation) and block registration in wedocs.php, which together satisfy the linked issue's request to provide a Gutenberg block and relevant customization settings. The new wedocs_get_doc_navigation_posts() centralizes the prev/next logic and is used by the block renderer, aligning the code with the feature objective. Based on the provided diffs the block's attributes and editor controls cover the declared customization requirements from issue #167.
Docstring Coverage βœ… Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • [ ] πŸ“ Generate Docstrings
πŸ§ͺ Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Sep 19 '25 11:09 coderabbitai[bot]

Navigation block not showing at frontend. @sapayth vai

https://github.com/user-attachments/assets/e58c69de-51d4-4de1-ba4a-421b2ea1adfa

Rubaiyat-E-Mohammad avatar Sep 22 '25 04:09 Rubaiyat-E-Mohammad