|
35 | 35 | ]);
|
36 | 36 | }
|
37 | 37 | ],
|
| 38 | + [ |
| 39 | + 'pattern' => '/second', |
| 40 | + 'method' => 'get', |
| 41 | + 'action' => function () { |
| 42 | + return Page::factory([ |
| 43 | + 'slug' => 'second', |
| 44 | + 'template' => 'search', |
| 45 | + 'content' => [ |
| 46 | + 'title' => 'Andrea\'s search information', |
| 47 | + 'subtitle' => 'Andrea\'s search information', |
| 48 | + 'published_at' => '2025-03-11', |
| 49 | + ] |
| 50 | + ]); |
| 51 | + } |
| 52 | + ], |
38 | 53 | [
|
39 | 54 | 'pattern' => '/andrea/url/(:any)',
|
40 | 55 | 'method' => 'get',
|
41 |
| - 'action' => function ($slug) { |
42 |
| - // Define el ID de la página de Notion que deseas recuperar |
43 |
| - $notionPageId = 'Ciclo-de-vida-de-software-1754e2b34628803b9557cd1d9d07370a'; |
44 |
| - |
45 |
| - // Configura los encabezados necesarios para la API de Notion |
46 |
| - $headers = [ |
47 |
| - 'Authorization' => 'Bearer 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', |
48 |
| - 'Notion-Version' => '2021-08-16', |
49 |
| - ]; |
50 |
| - |
51 |
| - // Realiza la solicitud GET a la API de Notion |
52 |
| - $response = Remote::get("https://api.notion.com/v1/pages/{$notionPageId}", [ |
53 |
| - 'headers' => $headers |
| 56 | + 'action' => function () { |
| 57 | + $mock = Remote::get('https://jsonplaceholder.typicode.com/posts/1'); |
| 58 | + |
| 59 | + $content = (object) json_decode($mock->content(), true); |
| 60 | + return Page::factory([ |
| 61 | + 'slug' => 'first', |
| 62 | + 'template' => 'article', |
| 63 | + 'content' => [ |
| 64 | + 'title' => $content->title, |
| 65 | + 'subtitle' => $content->title, |
| 66 | + 'published_at' => '2025-03-11', |
| 67 | + 'blocks' => $content->body, |
| 68 | + ] |
54 | 69 | ]);
|
55 |
| - |
56 |
| - // Verifica si la respuesta es exitosa |
57 |
| - if ($response->code() === 200) { |
58 |
| - $content = json_decode($response->content(), true); |
59 |
| - |
60 |
| - // Procesa el contenido según la estructura de tu página en Notion |
61 |
| - return Page::factory([ |
62 |
| - 'slug' => $slug, |
63 |
| - 'template' => 'article', |
64 |
| - 'content' => [ |
65 |
| - 'title' => $content['properties']['title']['title'][0]['text']['content'], |
66 |
| - 'subtitle' => $content['properties']['subtitle']['rich_text'][0]['text']['content'], |
67 |
| - 'published_at' => $content['properties']['published_at']['date']['start'], |
68 |
| - 'blocks' => $content['properties']['content']['rich_text'][0]['text']['content'], |
69 |
| - ] |
70 |
| - ]); |
71 |
| - } else { |
72 |
| - // Maneja el error en caso de que la solicitud falle |
73 |
| - return 'Error al obtener datos de Notion'; |
74 |
| - } |
75 | 70 | }
|
76 |
| - ], |
| 71 | + ], |
77 | 72 | [
|
78 | 73 | 'pattern' => '/search',
|
79 | 74 | 'method' => 'get',
|
|
0 commit comments