Skip to content

Commit 13652b5

Browse files
committed
Resolve content links from their source file after rendering.
1 parent e4095e4 commit 13652b5

45 files changed

Lines changed: 1383 additions & 498 deletions

Some content is hidden

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

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ dist
55
*.tgz
66
tsconfig.bundle.generated.json
77
PureGate
8+
purestack-setup
89
*.vsix
910
.codex/*
1011
/.tmp

‎frontend/purestack.studio/guides/_nav.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"components",
66
"purestack-cli.mdx",
77
"site-config.mdx",
8+
"links.mdx",
89
"vscode-extension.mdx",
910
"regor.mdx",
1011
"typography.mdx",

‎frontend/purestack.studio/guides/index.mdx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Guides
3-
description: Learn how to build and style a PureStack site with the CLI, site configuration, VS Code extension, Regor, typography, utility classes, semantic tones, icons, and themes.
3+
description: Learn how to build and style a PureStack site with the CLI, site configuration, links, VS Code extension, Regor, typography, utility classes, semantic tones, icons, and themes.
44
template: doc
55
layout:
66
showNav: true
@@ -26,6 +26,11 @@ These guides follow the path from a content folder to a finished interface. Star
2626
<p>Set output paths, navigation, themes, search, metadata, languages, and optional scripts.</p>
2727
<BtnLink href="/guides/site-config/" tone="accent" variant="link">Configure a site</BtnLink>
2828
</Panel>
29+
<Panel tone="neutral" bodyClass="p-3">
30+
<h2 class="mt-0">Links</h2>
31+
<p>Link pages and sections relative to your file, and let every build check them.</p>
32+
<BtnLink href="./links" tone="accent" variant="link">Write links</BtnLink>
33+
</Panel>
2934
<Panel tone="neutral" bodyClass="p-3">
3035
<h2 class="mt-0">VS Code extension</h2>
3136
<p>Find component source, complete props and frontmatter, and format markup on save.</p>
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: Links
3+
description: Link to pages, sections, and other sites. Write links relative to your file, and every build checks that they still work.
4+
template: doc
5+
layout:
6+
showNav: true
7+
showToc: true
8+
showFooter: true
9+
nav:
10+
order: 16
11+
icon: tabler:link
12+
---
13+
14+
# Links
15+
16+
Write a link the way you see your files. PureStack turns it into the right page address and checks it every time the site builds, so a renamed or deleted page never leaves a broken link behind.
17+
18+
## Link to another page
19+
20+
Start from the file you are writing in, just like in your editor's file tree. Take this content folder:
21+
22+
```text
23+
index.mdx
24+
guides/
25+
index.mdx
26+
semantic-tones.mdx
27+
themes.mdx
28+
components/
29+
index.mdx
30+
buttons.mdx
31+
```
32+
33+
From `guides/semantic-tones.mdx`, these links work:
34+
35+
| Write | Opens |
36+
| --- | --- |
37+
| `[Themes](./themes)` | `/guides/themes/`, a page in the same folder |
38+
| `[Buttons](./components/buttons)` | `/guides/components/buttons/`, a page in a subfolder |
39+
| `[Components](./components/)` | `/guides/components/`, the main page of a subfolder |
40+
| `[All guides](./)` | `/guides/`, the main page of this folder |
41+
| `[Home](../)` | `/`, the main page one folder up |
42+
43+
The file extension is optional. `./themes` and `./themes.mdx` open the same page.
44+
45+
A folder's main page is its `index.mdx`, or a file named after the folder, such as `components/components.mdx`. Link to the folder, like `./components/`, and you reach it either way.
46+
47+
## Jump to a section
48+
49+
Add `#` and the section name after the page:
50+
51+
```md
52+
[Create a skin](./themes#create-a-skin)
53+
[Back to the top](#links)
54+
```
55+
56+
A section name is its heading in lowercase, with hyphens between the words. The heading "Create a skin" becomes `#create-a-skin`. Try it: [create a skin](./themes#create-a-skin).
57+
58+
PureStack checks that the page exists, not the section, so double-check section names after you rename a heading.
59+
60+
## Links in components
61+
62+
The same rule works for `href` on any tag, including components and links they build from a value:
63+
64+
```mdx
65+
<BtnLink href="./themes" tone="accent">Read about themes</BtnLink>
66+
67+
<BtnLink :href="nextPage">Next</BtnLink>
68+
69+
<a href="../">Back to home</a>
70+
```
71+
72+
Links in a shared header or footer start from that header or footer file, so they work on every page that shows them.
73+
74+
## Link outside your content
75+
76+
Anything that starts with `/` or a protocol is used as written:
77+
78+
| Write | Use it for |
79+
| --- | --- |
80+
| `/blog/` | Pages served from the same domain but built separately |
81+
| `https://github.com/PureStackStudio/PureStack` | Other websites |
82+
| `mailto:hello@example.com` | Email |
83+
84+
PureStack doesn't check these links, because the pages behind them aren't part of your content folder.
85+
86+
You can link your own pages this way too, as in `/guides/themes/`, but a relative link is the better habit: if that page moves, the build tells you.
87+
88+
If the site lives under a base path, such as `/docs`, PureStack adds it to every link for you. Set it once in the [site configuration](./site-config).
89+
90+
## When a link is broken
91+
92+
The build stops and names the file and the link:
93+
94+
```text
95+
Content link "./themse" in "guides/semantic-tones.mdx" does not match any page.
96+
```
97+
98+
While `purestack serve` runs, only that page shows the error, and it updates as soon as you fix the link. Most fixes are one of these:
99+
100+
- **A typo or different capitals.** `./Themes` doesn't find `themes.mdx`.
101+
- **The page moved.** Write the path again, starting from your file.
102+
- **The page is built elsewhere.** Start the path at the site root, such as `/blog/`.
103+
104+
## Translated sites
105+
106+
Link pages inside your language folder as usual. If a page isn't translated yet, the link opens the default language's version, so you can translate at your own pace.
107+
108+
## Quick reference
109+
110+
| To reach | Write |
111+
| --- | --- |
112+
| A page in the same folder | `./themes` |
113+
| A page in a subfolder | `./components/buttons` |
114+
| A folder's main page | `./components/` |
115+
| The page one folder up | `../` |
116+
| A section of another page | `./themes#create-a-skin` |
117+
| A section of this page | `#quick-reference` |
118+
| A page built separately | `/blog/` |
119+
| Another website | `https://example.com` |
120+
121+
<AlertBox tone="accent" icon="tabler:bolt" title="Rule of thumb">
122+
Link your own pages relative to your file. Use a full path or address for
123+
everything else.
124+
</AlertBox>

‎frontend/purestack.studio/guides/semantic-tones.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,4 +468,4 @@ root.select('.my-action:focus-visible').css({
468468

469469
The symbolic reference keeps the style responsive to the nearest tone and theme. Apply `tone--danger` to that action and its focus ring follows the danger button role without another selector.
470470

471-
Continue with [themes and skins](/guides/themes) for palette authoring and [utility classes](/guides/utility-css-classes) for geometry and layout.
471+
Continue with [themes and skins](./themes) for palette authoring and [utility classes](./utility-css-classes) for geometry and layout.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "purestack-repo",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"packageManager": "yarn@4.18.1",
66
"type": "module",
77
"sideEffects": false,

‎packages/purestack/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "purestack",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"packageManager": "yarn@4.9.2",
55
"module": "./dist/purestack.mjs",
66
"types": "./dist/purestack.d.mts",

‎packages/purestack/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const version: string = '1.1.1'
1+
export const version: string = '1.1.2'
22

33
export * from '@purestack/ts-ssg'

‎packages/ts-common/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@purestack/ts-common",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"packageManager": "yarn@4.9.2",
55
"module": "./dist/ts-common.mjs",
66
"types": "./dist/ts-common.d.mts",

‎packages/ts-components/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@purestack/ts-components",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"packageManager": "yarn@4.9.2",
55
"module": "./dist/ts-components.mjs",
66
"types": "./dist/ts-components.d.mts",

0 commit comments

Comments
 (0)