optimistdigital/nova-blog
最新稳定版本:9.7.0
Composer 安装命令:
composer require optimistdigital/nova-blog
包简介
Blog manager for Laravel Nova
README 文档
README
This Laravel Nova package allows you to create a blog, manage blogposts and posts' content. The package is geared towards headless CMS's.
Installation
Install the package in a Laravel Nova project via Composer:
composer require optimistdigital/nova-blog
Publish the nova-blog configuration file and edit it to your preference:
php artisan vendor:publish --provider="OptimistDigital\NovaBlog\ToolServiceProvider" --tag="config"
Publish the database migration(s) and run migrate:
php artisan vendor:publish --provider="OptimistDigital\NovaBlog\ToolServiceProvider" --tag="migrations" php artisan migrate
Register the tool with Nova in the tools() method of the NovaServiceProvider:
// in app/Providers/NovaServiceProvider.php public function tools() { return [ // ... new \OptimistDigital\NovaBlog\NovaBlog ]; }
Defining locales
The config accepts a dictionary of locales.
// in /config/nova-blog.php // ... 'locales' => [ 'en' => 'English', 'et' => 'Estonian', ], // OR 'locales' => function () { return Locale::all()->pluck('name', 'key'); }, // if you wish to cache the configuration, pass a reference instead: 'locales' => NovaBlogConfiguration::class . '::locales', // ...
Nova Lang
This package supports optimistdigital/nova-lang for easier content localization.
After installing and setting up nova-lang package, you can use nova_lang_get_all_locales helper function in nova-blog config file
'locales' => nova_lang_get_all_locales(),
Toggling page draft feature
Draft feature allows you to create previews of resources before publishing them. By default this feature is disabled but can be enabled by installing nova-drafts package.
composer require optimistdigital/nova-drafts
Add links to front-end pages
To display a link to the actual page next to the slug, add or overwrite the closure in config/nova-blog.php for the key page_url.
// in /config/nova-blog.php // ... 'page_url' => function (Post $post) { return env('FRONTEND_URL') . '/' . $post->slug; }, // if you wish to cache the configuration, pass a reference instead: 'page_url' => NovaBlogConfiguration::class . '::pageUrl', // ...
Helper functions
nova_get_blog_structure()
The helper function nova_get_blog_structure() returns the base posts structure (titles, slugs, published at dates, content) that you can build your routes upon in the front-end.
Example response:
[
{
"id": 7,
"created_at": "2019-06-19 11:58:56",
"updated_at": "2019-06-19 11:59:23",
"title": "Test post 1",
"slug": "test-post-1",
"post_content": [
{
"layout": "text",
"key": "8965c7bfc0918086",
"attributes": {
"text-content": "Test post content."
}
},
{
"layout": "image",
"key": "56f5bbe608b68cd6",
"attributes": {
"caption": "Test post image."
}
}
],
"published_at": "2019-06-19 09:00:00",
"seo_title": null,
"seo_description": null,
"seo_image": null,
"data": null
},
{
"id": 8,
"created_at": "2019-06-19 12:00:06",
"updated_at": "2019-06-19 12:00:06",
"title": "Test post 2",
"slug": "tes-post-2",
"post_content": [
{
"layout": "text",
"key": "0e340b84bc5dec28",
"attributes": {
"text-content": "Test post content."
}
},
{
"layout": "image",
"key": "a4625050e49cf77c",
"attributes": {
"caption": "Test post image."
}
}
],
"published_at": "2019-06-19 09:00:05",
"seo_title": null,
"seo_description": null,
"seo_image": null,
"data": null
}
]
nova_get_post_by_id($postId)
The helper function nova_get_post_by_id($postId) finds and returns the post with the given ID.
Example response for querying page with ID 7 (nova_get_post_by_id(7)):
{
"id": 7,
"name": "Test post 1",
"slug": "testpost1",
"published_at": "2019-06-19T09:00:00.000000Z",
"post_content": [
{
"layout": "text",
"key": "8965c7bfc0918086",
"attributes": {
"text-content": "Test post content."
}
},
{
"layout": "image",
"key": "56f5bbe608b68cd6",
"attributes": {
"caption": "Test post image."
}
}
]
}
nova_get_post_by_slug($slug)
The helper function nova_get_post_by_slug($slug) finds and returns the post with the given slug.
Example response for querying page with slug test-post-3 (nova_get_post_by_slug('test-post-3')):
{
"id": 14,
"name": "Test post 3",
"slug": "test-post-3",
"published_at": "2019-06-25T09:00:00.000000Z",
"post_content": [
{
"layout": "text",
"key": "fc64d73f1f7508c4",
"attributes": {
"text-content": "Test post content."
}
},
{
"layout": "image",
"key": "f8c9cc65b23b862a",
"attributes": {
"caption": "Test post image."
}
}
]
}
Credits
License
Nova blog is open-sourced software licensed under the MIT license.
optimistdigital/nova-blog 适用场景与选型建议
optimistdigital/nova-blog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.57k 次下载、GitHub Stars 达 37, 最近一次更新时间为 2019 年 08 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「page」 「manager」 「nova」 「laravel」 「optimistdigital」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 optimistdigital/nova-blog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 optimistdigital/nova-blog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 optimistdigital/nova-blog 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table.
Plug-ins for DataTables
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
This package helps you use bitwise enums in PHP and Laravel.
统计信息
- 总下载量: 15.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 37
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-06