-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ANNE Etienne
authored and
ANNE Etienne
committed
Nov 25, 2024
1 parent
a0743b5
commit 31e6255
Showing
6 changed files
with
271 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
manual/docs/04-cli/042-apis-to-business-website/06-style-your-apis-page.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import APIStyling from '@site/static/img/apis-styling.png'; | ||
|
||
# 6 - Style your APIs page | ||
|
||
# Style an individual page | ||
|
||
Using HTML’s own <style></style> tags, you can style items on your page. Adding attributes and directives to these tags gives you even more ways to style. | ||
|
||
Copy the following code and paste it into src/pages/apis/page.html: | ||
|
||
```html title="src/pages/apis/page.html" | ||
_exact: true | ||
|
||
--- | ||
// addition | ||
<head> | ||
// addition | ||
<link href="styles/api.css" rel="stylesheet" type="text/css" /> | ||
// addition | ||
</head> | ||
|
||
<body> | ||
<h1>My apis</h1> | ||
{{#daikoku-apis}} | ||
<div class="api"> | ||
<p>Api : {{api.name}}</p> | ||
<p>{{api.smallDescription}}</p> | ||
</div> | ||
{{/daikoku-apis}} | ||
</body> | ||
``` | ||
|
||
Add the following code a new file called `src/styles/api.css`: | ||
|
||
```css title="src/styles/api.css" | ||
.api { | ||
border-radius: 1rem; | ||
box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px; | ||
max-width: 32rem; | ||
padding: 1rem; | ||
} | ||
``` | ||
|
||
# Add external CSS component library | ||
|
||
:::tip | ||
Writing a Daikoku template is very much like writing HTML, so you can use all HTML tags and import evertything, including external CSS external librairies. | ||
::: | ||
|
||
```html title="src/pages/apis/page.html" | ||
|
||
<head> | ||
// deletion | ||
<link href="styles/api.css" rel="stylesheet" type="text/css" /> | ||
// addition | ||
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.14/dist/full.min.css" rel="stylesheet" type="text/css" /> | ||
// addition | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
</head> | ||
|
||
<body class="m-5"> | ||
//addition | ||
<h1 class="text-5xl font-bold">My apis</h1> | ||
// addition | ||
<div class="flex gap-5 m-5"> | ||
{{#daikoku-apis}} | ||
// deletion | ||
<div class="api"> | ||
//deletion | ||
<p>Api : {{api.name}}</p> | ||
//deletion | ||
<p>{{api.smallDescription}}</p> | ||
//deletion | ||
</div> | ||
// addition | ||
<div class="card bg-base-100 w-96 shadow-xl"> | ||
// addition | ||
<figure> | ||
// addition | ||
<img | ||
src="https://images.pexels.com/photos/1148820/pexels-photo-1148820.jpeg" | ||
alt="Shoes" /> | ||
// addition | ||
</figure> | ||
// addition | ||
<div class="card-body"> | ||
// addition | ||
<h2 class="card-title"> | ||
// addition | ||
{{api.name}} | ||
// addition | ||
<div class="badge badge-secondary">{{api.version}}</div> | ||
// addition | ||
</h2> | ||
// addition | ||
<p>{{api.description}}</p> | ||
</div> | ||
</div> | ||
{{/daikoku-apis}} | ||
</div> | ||
</body> | ||
``` | ||
|
||
Visit your APIs page in your browser again. | ||
|
||
<div style={{textAlign: 'center', width: 500, border: '1px solid #eee', borderRadius: '.25rem' }}> | ||
<img | ||
src={APIStyling} | ||
alt="result" | ||
/> | ||
</div> |
66 changes: 66 additions & 0 deletions
66
manual/docs/04-cli/042-apis-to-business-website/07-build-your-first-layout.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# 7 - Build your first layout | ||
|
||
You still have some links and components repeatedly rendered on every page. It’s time to refactor again to create a shared page layout! | ||
|
||
# Create your first layout component | ||
|
||
Create a new file at the location `src/layouts/base.html`. (You will need to create a new layouts folder first.) | ||
|
||
Copy the entire contents of `src/pages/page.html` into your new file, `base.html`. | ||
|
||
```html title="src/layout/base.html" | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>My CMS</title> | ||
|
||
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.14/dist/full.min.css" rel="stylesheet" type="text/css" /> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
</head> | ||
|
||
<body> | ||
// deletion | ||
<main> | ||
// deletion | ||
<h1>Welcome to your CMS</h1> | ||
// deletion | ||
</main> | ||
// addition | ||
{{children}} | ||
</body> | ||
</html> | ||
``` | ||
|
||
# Use your layout on a page | ||
|
||
Replace the code at `src/pages/apis/page.html` with the following: | ||
|
||
```html title="src/pages/apis/page.html" | ||
{{#daikoku-template-wrapper "/layouts/base.html"}} | ||
<h1 class="text-5xl font-bold">My apis</h1> | ||
<div class="flex gap-5 m-5"> | ||
{{#daikoku-apis}} | ||
<div class="card bg-base-100 w-96 shadow-xl"> | ||
<figure> | ||
<img | ||
src="https://images.pexels.com/photos/1148820/pexels-photo-1148820.jpeg" | ||
alt="Shoes" /> | ||
</figure> | ||
<div class="card-body"> | ||
<h2 class="card-title"> | ||
{{api.name}} | ||
<div class="badge badge-secondary">{{api.version}}</div> | ||
</h2> | ||
<p>{{api.description}}</p> | ||
</div> | ||
</div> | ||
{{/daikoku-apis}} | ||
</div> | ||
{{/daikoku-template-wrapper}} | ||
``` | ||
|
||
Check the browser preview again to notice what did (or, spoiler alert: did not!) change. |
54 changes: 54 additions & 0 deletions
54
manual/docs/04-cli/042-apis-to-business-website/08-define-and-use-a-variable.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# 8 - Define and use a variable | ||
|
||
Any HTML file is valid Daikoku language. But, you can do more with Daikoku than just regular HTML! | ||
|
||
# Create your first layout component | ||
|
||
Open `src/apis/page.html`, which should look like this: | ||
|
||
```html title="src/apis/page.html" | ||
{{#daikoku-template-wrapper "/layouts/base.html"}} | ||
<h1 class="text-5xl font-bold">My apis</h1> | ||
<div class="flex gap-5 m-5"> | ||
{{#daikoku-apis}} | ||
<div class="card bg-base-100 w-96 shadow-xl"> | ||
<figure> | ||
<img | ||
src="https://images.pexels.com/photos/1148820/pexels-photo-1148820.jpeg" | ||
alt="Shoes" /> | ||
</figure> | ||
<div class="card-body"> | ||
<h2 class="card-title"> | ||
{{api.name}} | ||
<div class="badge badge-secondary">{{api.version}}</div> | ||
</h2> | ||
<p>{{api.description}}</p> | ||
</div> | ||
</div> | ||
{{/daikoku-apis}} | ||
</div> | ||
{{/daikoku-template-wrapper}} | ||
``` | ||
|
||
Add the following line at the top of your file, between the *code fences*: | ||
|
||
```html title="src/apis/page.html" | ||
// addition | ||
pageTitle: "APIs" | ||
--- | ||
``` | ||
|
||
Replace both the static `My CMS` title heading in your HTML with the dynamic variable `{pageTitle}`. | ||
|
||
```html title="src/layout/base.html" | ||
//deletion | ||
<title>My CMS</title> | ||
//addition | ||
<title>{{pageTitle}}</title> | ||
``` | ||
|
||
Refresh the live preview of your `/apis` page. | ||
|
||
Your page text should look the same, and your page title displayed in your browser tab should now read `APIs` instead of `My CMS` | ||
|
||
Instead of typing text directly into HTML tags, you just defined and then used a variable in the two sections of your .html file, respectively. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.