Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add article creation #72

Merged
merged 3 commits into from
Aug 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 59 additions & 33 deletions template/content/articles/3.write-articles.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,97 @@
---
cover: /articles/write-articles.png
date: 2022-08-23
description: Writing Markdown articles in Alpine is straightforward.
---

# Write Articles

Write Markdown articles in Alpine is straightforward.

## Create a blog

Open a terminal an run the following command:
## Create an articles list

Create a new file in the `content/` directory:

```bash
npx nuxi create alpine my-blog
touch content/2.articles.md
```

## Dependencies
The numbered prefix determines the order of the menu items.

Next, go to to `my-blog/` directory and install the dependencies:
In this file, use the `articles-list` component to display the list of articles:

```md [2.articles.md]
---
title: 'Articles'
layout: 'page'
---

::articles-list
---
path: articles
---
::

```bash
npm install
```

## Development
The `path` prop corresponds to the directory where the articles are stored.

## Display an article in the list

Start the development server on port 3000:
Create a new file in the `/content/articles` directory:

```bash
npm run dev
mkdir content/articles
touch content/articles/1.my-new-article.md
```

Next, you can start creating your content in Markdown in the `content/` directory.
For your article to be correctly displayed in the [articles list](/articles), define a `cover` and `date` property in the frontmatter:

```yaml [content/articles/1.my-new-article.md]
---
cover: path/to/cover
date: 2022-08-23
---
```

## Deploy
The `cover` property can be a local path relative to the `/public` directory or an external URL.

### Static hosting
Your article will now be displayed in the list with its filename as a default title.

You can deploy Alpine to any static hosting by running the following command:
## Edit your article

```bash
npm run generate
```
Under the frontmatter block, enter a Markdown `h1` tag and a line of text:

This command will create a `dist/` directory with the compiled files ready to be uploaded to any static hosting.
```md [content/articles/1.my-new-article.md]
---
cover: path/to/cover
date: 2022-08-23
---

### Edge platforms
# An awesome article

Alpine supports deploying to the following platforms with **zero configuration**:
This article is little by size but big by heart.
```

- [Vercel](https://vercel.com)
- [Netlify](https://netlify.com)
- [and more...](https://v3.nuxtjs.org/guide/deploy/presets#supported-hosting-providers)
Your article will now be displayed in the list with the title and description you wrote in Markdown.

### Node server
## Override title and description

You can deploy Alpine to a Node server by running the following command:
If you want to change the title and description displayed on the list and in the meta tags of the article, add the `title` and `description` property to your frontmatter:

```bash
npm run build
```md[content/articles/1.my-new-article.md]
---
cover: path/to/cover
date: 2022-08-23
title: Another title
description: Another description
---
```

This command will create a `.output/` directory with the compiled files ready to be uploaded to any Node server.
You are now ready to edit your article and create new ones!

To start the production server, run the following command:
## Read more

```bash
node .output/server/index.mjs
```
Alpine is a Nuxt theme using the Content module in `documentDriven` mode.

👉 Learn more in the [Nuxt Content documentation](https://content.nuxtjs.org/).