Skip to content

[Docs] Added an "Aliases" page under Guides. [En] - #1042

Merged
FredKSchott merged 11 commits into
withastro:mainfrom
vtinev:docs/additions/aliases
Aug 6, 2021
Merged

FredKSchott merged 11 commits into
withastro:mainfrom
vtinev:docs/additions/aliases

Conversation

@vtinev

@vtinev vtinev commented Aug 6, 2021

Copy link
Copy Markdown
Contributor

Addressed issue #893.

Changes

Added a page that explains what aliases are, how to define them and how to use them in a project.

Testing

yarn start

Docs

@vercel

vercel Bot commented Aug 6, 2021 •

Copy link
Copy Markdown

@changeset-bot

changeset-bot Bot commented Aug 6, 2021 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3288e89

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment thread docs/src/pages/guides/aliases.md Resolved
Co-authored-by: Peter Singh <[email protected]>

@aFuzzyBear aFuzzyBear left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey man, good stuff, I do think that this information is warranted and valuable for those wanting to apply it in astro. I dont however feel that it merits itself as a guide, where as the information presented can help augment the config api page. I feel it would be better placed alongside that body of content.

Comment thread docs/src/pages/guides/aliases.md Outdated

## Adding a custom alias

If you navigate to the root directory of your project and open the `snowpack.config.mjs` file you will notice that there are some pre-defined aliases already.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add custom aliases to your project, located in the root of your project is the snowpack.config.mjs file. This configuration file contains the instructions for Astro's build tool, Snowpack, on how to build out your Astro project. Inside the file you will notice that there are already some predefined aliases.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that some projects don't have this file! mention to create one if you don't have it yet.

Comment thread docs/src/pages/guides/aliases.md Outdated
title: Aliases
---

Aliasing is an integral part when it comes to clean and readable code, that's why Astro comes with support for custom aliases out of the box.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Aliasing is an integral part when it comes to clean and readable code, that's why Astro comes with support for custom aliases out of the box.
Aliasing is an integral part when it comes to clean and readable code. Astro comes with support for custom aliases out of the box. Allowing you to maintain a clean and organised project.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'd remove the first line entirely as too opinionated :) Some people think that aliases are Bad™️, and our project doesn't really take a stance one way or the other.

Instead, maybe use the first sentence to explain what an alias is and why you might want to use it.

Love that you make the point early that Astro supports aliases "out of the box".

Comment thread docs/src/config.ts
{ text: 'Data Fetching', link: 'guides/data-fetching' },
{ text: 'Markdown', link: 'guides/markdown-content' },
{ text: 'Supported Imports', link: 'guides/imports' },
{ text: 'Aliases', link: 'guides/aliases' },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this should be its own page, having reviewed it I believe this is a better fit to help as an appendix to the references/configuration-reference file, places under the content that is already there.

@vtinev vtinev Aug 6, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd pretty much be copy/pasting it from the Snowpack documentation and there's already a link for the whole thing there. If we add this we might as well add everything regarding snowpack.config, that wouldn't be very nice because in my opinion Astro and Snowpack are advertised as two separate things.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given how common this question is I kind of like it as a top-level page, at least for now. +1 for keeping as-is for now (top-level page), and we can do a big docs review before a v1 release and move around if needed then.

@FredKSchott FredKSchott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Adding some comments but overall +1 on getting this merged. Thanks for tackling!

Comment thread docs/src/config.ts
{ text: 'Data Fetching', link: 'guides/data-fetching' },
{ text: 'Markdown', link: 'guides/markdown-content' },
{ text: 'Supported Imports', link: 'guides/imports' },
{ text: 'Aliases', link: 'guides/aliases' },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given how common this question is I kind of like it as a top-level page, at least for now. +1 for keeping as-is for now (top-level page), and we can do a big docs review before a v1 release and move around if needed then.

Comment thread docs/src/pages/guides/aliases.md Outdated
title: Aliases
---

Aliasing is an integral part when it comes to clean and readable code, that's why Astro comes with support for custom aliases out of the box.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'd remove the first line entirely as too opinionated :) Some people think that aliases are Bad™️, and our project doesn't really take a stance one way or the other.

Instead, maybe use the first sentence to explain what an alias is and why you might want to use it.

Love that you make the point early that Astro supports aliases "out of the box".

Comment thread docs/src/pages/guides/aliases.md Outdated

## What are aliases?

Aliases are _keywords_ you can use instead of paths.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider removing this header, since the start of every page gets an automatic "Overview" header which these two lines feel like they could fall under.

Comment thread docs/src/pages/guides/aliases.md Outdated

## Adding a custom alias

If you navigate to the root directory of your project and open the `snowpack.config.mjs` file you will notice that there are some pre-defined aliases already.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that some projects don't have this file! mention to create one if you don't have it yet.

Comment thread docs/src/pages/guides/aliases.md Outdated
```ts
// snowpack.config.mjs

alias: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since some people copy-paste these directly, I'd use the full file format (at least for the first example):

// snowpack.config.mjs
export default {

@FredKSchott FredKSchott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with two comments! If you're okay to accept those, then I think this is ready to merge

Comment thread docs/src/pages/guides/aliases.md Resolved
Comment thread docs/src/pages/guides/aliases.md Resolved
@FredKSchott

Copy link
Copy Markdown
Member

LGTM!

@FredKSchott
FredKSchott merged commit 2da7078 into withastro:main Aug 6, 2021
@FredKSchott

Copy link
Copy Markdown
Member

fyi I took another pass on the docs and made some additional edits: 73020fa

This branch was successfully deployed

2 active deployments
Preview – astro-docs — 3288e89a Deployed Aug 6, 2021 by vercel[bot]
Preview – astro-www — 3288e89a Deployed Aug 6, 2021 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants