-
Notifications
You must be signed in to change notification settings - Fork 0
Implement MdNotion class with fluent API, fetch methods, Blade template customization, and comprehensive documentation #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I added one change request and one question
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Task 1Let's keep empty pageId with MdNotion, just add new Task 2Also, instead of building markdown in method, let's use Blade components to render markdown from Ensure we have test to check if output of these methods matches blade templates Task 3Create example PHP script with the MdNotion facade, grab full page and save it as "notion-full.md". Check |
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
... All three tasks completed successfully: Task 1 ✅ - Added Task 2 ✅ - Created Blade templates Task 3 ✅ - Created All tests updated to verify the new functionality. Commit: fe5c9c4 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Please check my comments and refactor blade templates. After that, start with the new tasks:
Add Customization
Check the README.md file and add new section "Customization" and sub sections under it to explain how developers can create custom adapters for blocks and how they can change the full-md and page-md templates with their custom blade templates. Add small simple and clear examples.
Update Usage
Also, we have ## Usage section in README.md, please review the usage section and update:
- Instead one big example, separate it Extend with different examples and add descriptions to the examples.
- Each usage example should be returning something and please provide explanation/example of what returned
- Remove
readAllPagesContent
Addfull
method with warning note
Add features section
Above the Usage section add Features section with list of the most useful features MdNotion have. Use emojis and write clear, easy to understand text.
resources/views/full-md.blade.php
Outdated
return $markdown; | ||
} | ||
echo trim(buildFullMarkdown($page)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In using blade, I didn't mean just pulling PHP method body in blade template file. Instead this, please return all logic back to methods which will build data and pass to the blade:
- current_page -> collection with rendered title and content
- child_databases -> collection of database arrays which have rendered table, title and child_pages with rendered title and content
- child_pages -> collection of pages with rendered title and content
Also pass variables like $hasChildPage and etc.
And use these all these variable in Blade template to render needed markdown
resources/views/page-md.blade.php
Outdated
{!! $page->renderTitle(1) !!} | ||
|
||
@if($page->hasContent()) | ||
|
||
{!! $page->getContent() !!} | ||
|
||
@endif | ||
@if($withDatabases && $page->hasChildDatabases()) | ||
|
||
## Databases | ||
|
||
@foreach($page->getChildDatabases() as $database) | ||
{!! $database->renderTitle(3) !!} | ||
|
||
@if($database->hasTableContent()) | ||
{!! $database->getTableContent() !!} | ||
|
||
@endif | ||
@endforeach | ||
@endif | ||
@if($withPages && $page->hasChildPages()) | ||
|
||
## Child Pages | ||
|
||
@foreach($page->getChildPages() as $childPage) | ||
{!! $childPage->renderTitle(3) !!} | ||
|
||
@if($childPage->hasContent()) | ||
{!! $childPage->getContent() !!} | ||
|
||
@endif | ||
@endforeach | ||
@endif No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's take the same approach here as I commented on full-md template, directly pass ready-to-use variables to the template
@copilot I requested changes and asked for documentation update, please check my review comments and proceed 🙏 |
@copilot let's start by refactoring blade templates |
…ding to PHP methods Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
I've refactored the Blade templates to properly separate logic from view. The PHP methods now build structured data collections and pass ready-to-use variables to templates:
Templates are now much cleaner and focus purely on rendering. Commit: ca320db Now I'll proceed with the documentation updates (Customization, Usage, and Features sections). Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…d Customization guide Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
…b.com/RedberryProducts/md-notion into copilot/add-fetch-methods-to-mdnotion
This PR implements the complete MdNotion class with a fluent API as specified in the requirements, along with fetch methods for Page and Database objects, Blade template customization, and comprehensive documentation.
Tasks Completed ✅
Task 1 Implementation ✅
setPage()
method with fluent interfaceget()
,read()
,full()
)InvalidArgumentException
when pageId is not setTask 2 Implementation ✅
page-md.blade.php
andfull-md.blade.php
ContentBuilder::read()
to use Blade templatesMdNotion::full()
to use Blade templatesTask 3 Implementation ✅
mdnotion-facade-example.php
script with full documentationMdNotion::make($pageId)->full()
- complete recursive contentMdNotion::make($pageId)->pages()
- child pages collectionMdNotion::make($pageId)->databases()
- child databases collectionMdNotion::make($pageId)->content()->withPages()->withDatabases()->get()
- page objectMdNotion::make($pageId)->content()->withPages()->withDatabases()->read()
- markdown contentMdNotion::make()->setPage($pageId)->full()
- using setPage methodnotion-full.md
Blade Template Refactoring ✅
MdNotion::full()
method to build structured data arrays before passing to templateContentBuilder::read()
method to build structured data collectionsfull-md.blade.php
to use structured data variables instead of complex logicpage-md.blade.php
to use structured data variables instead of direct object accesscurrent_page
with rendered title and contentchild_databases
with rendered table, title and child pageschild_pages
with rendered title and contenthasChildPages
,hasChildDatabases
Documentation Update ✅
Additional Testing ✅
ContentBuilderTest.php
for testing ContentBuilder validationBladeTemplateTest.php
for testing template renderingImplementation Details
All changes maintain backward compatibility while adding extensive customization capabilities. The Blade templates provide clean separation between logic and presentation, with PHP methods building structured data and templates focusing purely on rendering.
The documentation now provides clear examples for each use case, comprehensive customization options for both templates and block adapters, and proper setup instructions for getting started with Notion API integration.
Developers can now easily extend the package with custom block adapters for specialized content types and create personalized markdown templates that suit their specific formatting needs.
All code follows PSR-12 standards and has been formatted with Laravel Pint.
Fixes #4.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.