Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bangnokia committed Mar 29, 2024
1 parent 277a223 commit 15e2646
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ public/
There are some function that you can use to get content from your site.

### Get all content in a directory

```php
foreach (cf()->index('post') as $post) {
foreach (lina()->index('post') as $post) {
echo $post->title;
}
```

### Get a single content

```php
$post = cf()->get('posts/2020-11-01-hello.md');
$post = lina()->get('posts/2020-11-01-hello.md');
```

- [x] Add `lina serve` command for development
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use BangNokia\Lina\ContentFinder;

if (!function_exists('list_content')) {
function cf(): ContentFinder
function lina(): ContentFinder
{
return app(ContentFinder::class);
}
Expand Down
6 changes: 4 additions & 2 deletions skeleton/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ public/
There are some function that you can use to get content from your site.

### Get all content in a directory

```php
foreach (cf()->index('post') as $post) {
foreach (lina()->index('post') as $post) {
echo $post->title;
}
```

### Get a single content

```php
$post = cf()->get('posts/2020-11-01-hello.md');
$post = lina()->get('posts/2020-11-01-hello.md');
```
5 changes: 3 additions & 2 deletions skeleton/resources/views/home.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@extends('app')

@php
$posts = collect(cf()->index('posts'))->sort(fn($a, $b) => $b->createdAt <=> $a->createdAt);
$posts = collect(lina()->index('posts'))->sort(fn($a, $b) => $b->createdAt <=> $a->createdAt);
@endphp

@section('content')
Expand All @@ -16,7 +16,8 @@
@foreach($posts as $post)
<li>
<x-date>{{ $post->createdAt }}</x-date>
<a href="{{ $post->url() }}" class="block" style="padding: 0.25rem 0;">{{ $post->title }} {{ $post->createdAt }}</a>
<a href="{{ $post->url() }}" class="block"
style="padding: 0.25rem 0;">{{ $post->title }} {{ $post->createdAt }}</a>
</li>
@endforeach
</ul>
Expand Down

0 comments on commit 15e2646

Please sign in to comment.