Skip to content

Commit 3bbfd93

Browse files
committed
Resolve relative image and file URLs from their source file and resolve config paths from the content root.
1 parent 9780777 commit 3bbfd93

17 files changed

Lines changed: 714 additions & 276 deletions

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

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
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.
3+
description: Link to pages, sections, images, files, and other sites. Write links relative to your file, and every build checks that they still work.
44
template: doc
55
layout:
66
showNav: true
@@ -13,7 +13,7 @@ nav:
1313

1414
# Links
1515

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.
16+
Write a link the way you see your files. PureStack turns it into the right address and checks it every time the site builds, so a renamed or deleted page or image never leaves a broken link behind.
1717

1818
## Link to another page
1919

@@ -71,6 +71,26 @@ The same rule works for `href` on any tag, including components and links they b
7171

7272
Links in a shared header or footer start from that header or footer file, so they work on every page that shows them.
7373

74+
## Images and files
75+
76+
Images, videos, downloads, and other files in your content folder follow the same rule:
77+
78+
```md
79+
![Palette diagram](./images/palette.svg)
80+
81+
[Download the checklist](./checklist.pdf)
82+
```
83+
84+
```html
85+
<img src="./images/logo.png" srcset="./images/logo.png 1x, ./images/logo@2x.png 2x" alt="PureStack">
86+
87+
<video src="./intro.mp4" poster="./intro.jpg" controls></video>
88+
```
89+
90+
Write a file's full name, with its extension and the same capitals, so it works on any host.
91+
92+
Files that a build step writes straight into the output aren't in your content folder, so PureStack can't check them. Link them from the site root, such as `/previews/demo.html`.
93+
7494
## Link outside your content
7595

7696
Anything that starts with `/` or a protocol is used as written:
@@ -92,13 +112,13 @@ If the site lives under a base path, such as `/docs`, PureStack adds it to every
92112
The build stops and names the file and the link:
93113

94114
```text
95-
Content link "./themse" in "guides/semantic-tones.mdx" does not match any page.
115+
Content link "./themse" in "guides/semantic-tones.mdx" does not match any page or file.
96116
```
97117

98118
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:
99119

100-
- **A typo or different capitals.** `./Themes` doesn't find `themes.mdx`.
101-
- **The page moved.** Write the path again, starting from your file.
120+
- **A typo or different capitals.** `./Themes` doesn't find `themes.mdx`, and `./Logo.png` doesn't find `logo.png`.
121+
- **The page or file moved.** Write the path again, starting from your file.
102122
- **The page is built elsewhere.** Start the path at the site root, such as `/blog/`.
103123

104124
## Translated sites
@@ -115,10 +135,11 @@ Link pages inside your language folder as usual. If a page isn't translated yet,
115135
| The page one folder up | `../` |
116136
| A section of another page | `./themes#create-a-skin` |
117137
| A section of this page | `#quick-reference` |
138+
| An image in a subfolder | `./images/palette.svg` |
118139
| A page built separately | `/blog/` |
119140
| Another website | `https://example.com` |
120141

121142
<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.
143+
Link your own pages and files relative to your file. Use a full path or
144+
address for everything else.
124145
</AlertBox>

‎frontend/purestack.studio/guides/site-config.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ The `--content` CLI option chooses the content directory. A custom runner can se
9595

9696
The logo can use `imageSrc` and `imageSrcDark` instead of an icon, or a `monogram` mark. `imageSrc` takes priority over `icon`. `subtitle`, `appearance`, `wordmarkStyle`, `shape`, `tone`, colors, and size fields let you tune the mark and wordmark. Set `logo.href` to `null` or `""` for a noninteractive logo. For the full set of presentation fields, use the [schema](https://github.com/PureStackStudio/PureStack/blob/main/packages/ts-ssg/schema/siteConfig.schema.json) alongside the [SiteLogo component](/components/site/site-logo/).
9797

98+
Relative paths in `siteConfig.json`, such as `imageSrc`, `style.href`, or `privacyPolicyUrl`, start at the content directory, where the file lives. `assets/logo.svg` becomes `/assets/logo.svg` on every page.
99+
98100
## Styles and themes
99101

100102
PureStack generates a stylesheet for each configured theme. `light` and `dark` are required, and are the defaults. With the default filename, the generated files are `assets/site.css` and `assets/site.dark.css`.

‎packages/ts-ssg/src/build/content-hrefs.ts‎

Lines changed: 0 additions & 182 deletions
This file was deleted.

0 commit comments

Comments
 (0)