Skip to content

Commit 2fa2688

Browse files
Merge pull request #27 from directus/extensions
Extensions Section
2 parents 1ac6716 + f991f15 commit 2fa2688

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2344
-138
lines changed

app/components/articles/Card.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defineProps<{
1414
</p>
1515

1616
<div class="card-footer-row">
17-
<div class="card-tag-row">
17+
<div v-if="article.tags" class="card-tag-row">
1818
<span
1919
v-for="tag in article.tags"
2020
:key="tag.id"
@@ -24,9 +24,12 @@ defineProps<{
2424
<Icon :name="tag.icon || 'material-symbols:question-mark'" />
2525
</span>
2626
</div>
27-
<p class="card-category">
27+
<p v-if="article.category" class="card-category">
2828
{{ article.category }}
2929
</p>
30+
<p v-if="article.description" class="card-description">
31+
{{ article.description }}
32+
</p>
3033
</div>
3134
</NuxtLink>
3235
</template>
@@ -47,10 +50,10 @@ defineProps<{
4750
.card-title {
4851
font-size: 1rem;
4952
font-weight: 500;
50-
margin-bottom: 0.5rem;
5153
}
5254
5355
.card-footer-row {
56+
margin-top: 0.5rem;
5457
display: flex;
5558
justify-content: space-between;
5659
align-items: center;
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<script setup lang="ts">
2+
import type { ParsedContent } from '@nuxt/content';
3+
4+
interface Section {
5+
items?: Array<{ path: string }>;
6+
}
7+
8+
const props = defineProps<{
9+
data: ParsedContent;
10+
}>();
11+
12+
const paths: Array<string> = props.data.sections.flatMap((section: Section) =>
13+
section.items?.map(item => item.path) ?? [],
14+
);
15+
16+
const pages = await queryContent().where({ _path: { $in: paths } }).only(['_path', 'title', 'description']).find();
17+
18+
const sections = props.data.sections.map((section: Section) => {
19+
const items = section.items?.map((item: { path: string }) => {
20+
const page = pages.find(page => page._path === item.path);
21+
return {
22+
title: page?.title,
23+
description: page?.description,
24+
_path: page?._path,
25+
};
26+
});
27+
return { ...section, items };
28+
});
29+
</script>
30+
31+
<template>
32+
<div class="docs container">
33+
Test
34+
<UiAsideNav :path="data?._path" />
35+
<div class="slug">
36+
<main v-if="data">
37+
<article>
38+
<ContentRenderer :value="data">
39+
<ContentRendererMarkdown
40+
class="prose"
41+
:value="data"
42+
/>
43+
</ContentRenderer>
44+
</article>
45+
<section
46+
v-for="section in sections"
47+
:key="section.title"
48+
>
49+
<h2>{{ section.title }}</h2>
50+
<!-- {{ section.items }} -->
51+
<ArticlesGrid :articles="section.items" />
52+
</section>
53+
</main>
54+
<aside>
55+
<AsideNewsletter />
56+
<AsideFeedback />
57+
</aside>
58+
</div>
59+
</div>
60+
</template>
61+
62+
<style lang="scss" scoped>
63+
.slug {
64+
display: grid;
65+
grid-template-columns: minmax(0, 1fr) 250px;
66+
width: 100%;
67+
gap: 3rem;
68+
}
69+
main {
70+
margin-top: var(--nav-spacing-under);
71+
.prev-next {
72+
padding: var(--nav-spacing-under) 0 calc(var(--nav-spacing-under) + 1rem);
73+
}
74+
}
75+
aside {
76+
margin-top: var(--nav-spacing-under);
77+
padding-left: 2rem;
78+
padding-right: 1em;
79+
border-left: 2px solid var(--border);
80+
display: flex;
81+
flex-direction: column;
82+
gap: calc(var(--nav-spacing-under) / 2);
83+
> * {
84+
width: 100%;
85+
}
86+
}
87+
.docs {
88+
display: grid;
89+
grid-template-columns: 225px minmax(0, 1fr);
90+
gap: 3rem;
91+
> nav {
92+
margin-top: var(--nav-spacing-under);
93+
border-right: 2px solid var(--border);
94+
section {
95+
margin: 2rem 0;
96+
&:first-child {
97+
margin-top: 0;
98+
}
99+
}
100+
}
101+
}
102+
:deep(ol ol) {
103+
display: none;
104+
}
105+
section {
106+
margin-top: 2rem;
107+
> h2 {
108+
margin-bottom: 1rem;
109+
}
110+
}
111+
</style>

content/1.getting-started/0.overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Using Directus Insights, your whole team can build custom applications. Ditch th
3232

3333
Establish a single source of truth for all data. Build no-code analytics dashboards to gain insights into company KPIs and other metrics. Coalesce previously siloed data and use Directus Automate to keep everything in sync.
3434

35-
::callout{type="tutorials" url="/tutorials"}
35+
<!-- TODO ::callout{type="tutorials" url="/tutorials"}
3636
See all project and use-case tutorials.
37-
::
37+
:: -->
3838

3939
## Directus Cloud
4040

content/1.getting-started/1.create-a-project.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ The project that runs from this `docker-compose.yml` file is not production-read
103103
Read our self-hosting product checklist.
104104
::
105105

106-
## Deploy Directus
106+
<!-- TODO ## Deploy Directus
107107
108108
We also have a number of guides on deploying Directus to various cloud providers, like Amazon Web Services, Microsoft Azure, and Google Cloud Platform.
109109
110110
::callout{type="tutorials" url="/tutorials/tags/deployment"}
111111
112112
See how to deploy Directus on multiple hosting providers.
113113
114-
::
114+
:: -->
115115

116116
## Next Steps
117117

content/1.getting-started/2.resources.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Detailed documentation about the Directus platform.
1010
Comprehensive list of endpoints available in your projects.
1111
::
1212

13-
::callout{type="tutorials" url="/tutorials" title="Tutorials"}
13+
<!-- TODO: ::callout{type="tutorials" url="/tutorials" title="Tutorials"}
1414
Framework, project, and other implementation guides.
15-
::
15+
:: -->
1616

1717
::callout{type="community" url="/community" title="Community"}
1818
Get involved through feature requests, code contribution, education, and more.
Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,67 @@
11
---
22
title: Overview
3-
description:
3+
description: Extensions are used to extend the functionality of Directus.
44
---
55

66
# Extensions Overview
7+
8+
Directus has been built to be extensible - both allowing for powerful enhancements to be built for single projects, and for publishing in the [Directus Marketplace](/extensions/marketplace).
9+
10+
Extensions in Directus run within the same environment as the main application, allowing them to leverage existing access to underlying [services](/extensions/api-extensions/services) and [UI components](/extensions/app-extensions/ui-library).
11+
12+
## App Extensions
13+
14+
[App Extensions](/extensions/app-extensions) extend the functionality of the Data Studio.
15+
16+
### Interfaces
17+
18+
<!-- TODO: IMAGE FROM NOTION -->
19+
20+
[Interfaces](/extensions/app-extensions/interfaces) are form inputs used primarily inside of the :product-link{product="editor"}. Interfaces are the primary way users interact with data inside of Directus. Custom interfaces can be used for use cases with unique interaction needs, complex data entry, and any time you need to add elements to the editor.
21+
22+
### Displays
23+
24+
<!-- TODO: IMAGE FROM NOTION -->
25+
26+
[Displays](/extensions/app-extensions/displays) are small components that are used to display a single value throughout the Data Studio. Displays receive a single value and any custom display options that are defined in the display entrypoint. They are then expected to render the value in a user-friendly way.
27+
28+
### Layouts
29+
30+
<!-- TODO: IMAGE FROM NOTION -->
31+
32+
[Layouts](/extensions/app-extensions/layouts) allow for listing of items in :product-link{product="explore"} pages. Layouts receive a collection, filters, searches, and any custom layout options that are defined in the layout entrypoint. They are then expected to fetch and render the items from a collection.
33+
34+
35+
### Panels
36+
37+
<!-- TODO: IMAGE FROM NOTION -->
38+
39+
[Panels](/extensions/app-extensions/panels) are customizable components within :product-link{product="insights"} dashboards. Panels are the building blocks of analytics dashboards, enabling rapid, no-code creation of data visualizations with data from a Directus project. Panels can also contain interactive elements, making them suitable for building custom internal applications within dashboards.
40+
41+
### Modules
42+
43+
<!-- TODO: IMAGE FROM NOTION -->
44+
45+
[Modules](/extensions/app-extensions/modules) are top-level areas of the Data Studio, navigated to from the left-hand module bar. They will load at the specified routes. The Data Studio splits up functionality into modules - the content module, the files module, the user module, the insights module, and the settings module. Extensions can add new modules to the Data Studio.
46+
47+
### Themes
48+
49+
<!-- TODO: IMAGE FROM NOTION -->
50+
51+
[Themes](/extensions/app-extensions/themes) are used to style the Data Studio. They can be used to change the colors, fonts, and other visual elements of the Data Studio.
52+
53+
## API Extensions
54+
55+
[API Extensions](/extensions/api-extensions) extend the functionality of the API.
56+
57+
### Hooks
58+
59+
[Hooks](/extensions/api-extensions/hooks) allow running code when events occur within Directus. Events are triggered on schedules, database events, or during the Directus application lifecycle.
60+
61+
### Endpoints
62+
63+
[Endpoints](/extensions/api-extensions/endpoints) allow you to register new API routes in your Directus project.
64+
65+
### Operations
66+
67+
[Operations](/extensions/api-extensions/operations) are single steps in a Flow - the no-code automation tool part of :product-link{product="automate"}.
Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,54 @@
11
---
22
title: Quickstart
3-
description:
3+
description: This guide will cover how to get started with developing an extension for Directus.
44
---
55

66
# Extensions Quickstart
7+
8+
This guide will cover how to get started with developing an extension for Directus. You will set up a development environment, build an extension, and load it into your project.
9+
10+
## Loading an Extension Volume
11+
12+
Follow the steps in the [Create a Project](/getting-started/create-a-project) guide to set up your project locally. This `docker-compose.yml` file will set up a local volume for extensions to be loaded from. This directory exists on your local filesystem and is also mounted into the Docker container.
13+
14+
Add the following to the `environment` section of your `docker-compose.yml` file to automatically reload your extensions when they are rebuilt:
15+
16+
```yaml
17+
EXTENSIONS_AUTO_RELOAD: true
18+
```
19+
20+
::callout{type="info" title="Restarting Directus"}
21+
When changing the `docker-compose.yml` file, you will need to restart Directus by restarting the Docker container.
22+
::
23+
24+
## Initializing an Extension
25+
26+
In your terminal, navigate to the `extensions` directory and run the following command and follow the prompts to initialize an extension:
27+
28+
```bash
29+
npx create-directus-extension@latest
30+
? Choose the extension type: endpoint
31+
? Choose a name for the extension: my-first-endpoint
32+
? Choose the language to use: javascript
33+
? Auto install dependencies?: Yes
34+
```
35+
36+
This will create a new subdirectory in `extensions` with a boilerplate extension.
37+
38+
## Building Your Extension
39+
40+
Run `npm run build` to build your extension. This will create a `dist` directory in your extension directory with your built extension. This is the code that will be loaded into your Directus project.
41+
42+
You can alternatively run `npm run dev` to automatically rebuild your extension when you make changes.
43+
44+
With the `EXTENSIONS_AUTO_RELOAD` environment variable set, your extension will be automatically reloaded in Directuswhen you make changes.
45+
46+
## Using Your Extension
47+
48+
Navigate to the extensions page in your project settings. You should now see your new extension in the list.
49+
50+
Endpoints are only available via API, so navigate to `http://localhost:8055/my-first-endpoint` in your browser to access your new endpoint. Other extension types are available in their respective selection panes within the Data Studio.
51+
52+
## Next Steps
53+
54+
Now that you've built your first extension, you can start building out your own. Check out the [API Extensions](/extensions/api-extensions) overview or [App Extensions](/extensions/app-extensions) overview for more information on building each extension type.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
style: ExtensionListing
3+
title: API Extensions
4+
description:
5+
sections:
6+
- title: Extension Types
7+
items:
8+
- path: /extensions/api-extensions/hooks
9+
- path: /extensions/api-extensions/endpoints
10+
- path: /extensions/api-extensions/operations
11+
- title: Resources
12+
items:
13+
- path: /extensions/api-extensions/services
14+
- path: /extensions/api-extensions/sandbox
15+
---
16+
17+
# API Extensions Overview
18+
19+
API Extensions extend the functionality of the API.

0 commit comments

Comments
 (0)