optimistdigital / nova-blog
Laravel Nova 的博客管理器
Requires
- php: >=7.1.0
- digital-creative/conditional-container: ^1.3
- doctrine/dbal: ^2.9
- optimistdigital/nova-locale-field: ^2.0
- optimistdigital/nova-multiselect-field: >=1.8.1
- optimistdigital/nova-sortable: ^2.3.4
- whitecube/nova-flexible-content: ^0.2.4
- dev-master
- 9.7.0
- 9.6.1
- 9.6.0
- 9.5.1
- 9.5.0
- 9.4.0
- 9.3.0
- 9.2.3
- 9.2.2
- 9.2.1
- 9.2.0
- 9.1.1
- 9.1.0
- 9.0.2
- 9.0.1
- 9.0.0
- 8.0.0
- 7.4.1
- 7.4.0
- 7.3.0
- 7.2.0
- 7.1.1
- 7.1.0
- 7.0.x-dev
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.2.0
- 6.1.1
- 6.1.0
- 6.0.1
- 6.0.0
- 5.6.0
- 5.5.0
- 5.4.0
- 5.3.0
- 5.2.0
- 5.1.0
- 5.0.1
- 5.0.0
- 4.1.0
- 4.0.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.0
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/npm_and_yarn/json5-1.0.2
- dev-dependabot/npm_and_yarn/express-4.18.2
- dev-dependabot/npm_and_yarn/qs-and-express-6.11.0
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/loader-utils-1.4.2
- dev-dependabot/npm_and_yarn/eventsource-1.1.1
- dev-dependabot/npm_and_yarn/async-2.6.4
- dev-dependabot/npm_and_yarn/minimist-1.2.6
- dev-dependabot/npm_and_yarn/url-parse-1.5.10
- dev-dependabot/npm_and_yarn/follow-redirects-1.14.8
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/npm_and_yarn/color-string-1.6.0
- dev-dependabot/npm_and_yarn/ws-6.2.2
- dev-dependabot/npm_and_yarn/dns-packet-1.3.4
- dev-dependabot/npm_and_yarn/browserslist-4.16.6
- dev-dependabot/npm_and_yarn/lodash-4.17.21
- dev-dependabot/npm_and_yarn/ssri-6.0.2
- dev-dependabot/npm_and_yarn/y18n-4.0.1
- dev-dependabot/npm_and_yarn/elliptic-6.5.4
- dev-dependabot/npm_and_yarn/axios-0.21.1
- dev-dependabot/npm_and_yarn/ini-1.3.8
This package is auto-updated.
Last update: 2023-06-06 09:57:37 UTC
README
此 Laravel Nova 软件包允许您创建博客,管理博客文章和内容。该软件包面向无头 CMS。
安装
使用 Composer 在 Laravel Nova 项目中安装该软件包
composer require optimistdigital/nova-blog
发布 nova-blog
配置文件,并根据您的喜好进行编辑
php artisan vendor:publish --provider="OptimistDigital\NovaBlog\ToolServiceProvider" --tag="config"
发布数据库迁移文件并运行迁移
php artisan vendor:publish --provider="OptimistDigital\NovaBlog\ToolServiceProvider" --tag="migrations" php artisan migrate
在 NovaServiceProvider
的 tools()
方法中注册此工具
// in app/Providers/NovaServiceProvider.php public function tools() { return [ // ... new \OptimistDigital\NovaBlog\NovaBlog ]; }
定义区域设置
配置接受区域设置的字典。
// 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
此软件包支持 optimistdigital/nova-lang,以简化内容本地化。安装并设置 nova-lang
软件包后,您可以在 nova-blog
配置文件中使用 nova_lang_get_all_locales
辅助函数。
'locales' => nova_lang_get_all_locales(),
切换页面草稿功能
草稿功能允许您在发布资源之前创建资源的预览。默认情况下,此功能已禁用,但可以通过安装 nova-drafts 软件包来启用。
composer require optimistdigital/nova-drafts
添加前端页面链接
要在 slug 旁边显示实际页面的链接,请在 config/nova-blog.php
中添加或覆盖 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', // ...
辅助函数
nova_get_blog_structure()
辅助函数 nova_get_blog_structure()
返回基本文章结构(标题、slug、发布日期、内容),您可以在前端根据这些结构构建路由。
示例响应
[ { "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)
辅助函数 nova_get_post_by_id($postId)
找到并返回具有给定 ID 的文章。
查询 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)
辅助函数 nova_get_post_by_slug($slug)
找到并返回具有给定 slug 的文章。
查询 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." } } ] }
致谢
许可
Nova blog 是开源软件,根据 MIT 许可 许可。