
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
astro-relative-links
Advanced tools
This Astro integration builds Astro with relative links.
The astro add
command-line tool automates the installation for you. Run one of the following commands in a new terminal window. (If you aren't sure which package manager you're using, run the first command.) Then, follow the prompts, and type "y" in the terminal (meaning "yes") for each one.
# Using NPM
npx astro add astro-relative-links
# Using Yarn
yarn astro add astro-relative-links
# Using PNPM
pnpm astro add astro-relative-links
If you run into any issues, feel free to report them to me on GitHub and try the manual installation steps below.
First, install the astro-relative-links
packages using your package manager. If you're using npm or aren't sure, run this in the terminal:
npm install astro-relative-links
Then, apply this integration to your astro.config.*
file using the integrations
property:
astro.config.mjs
import { defineConfig } from 'astro/config';
import relativeLinks from 'astro-relative-links';
export default defineConfig({
// ...
integrations: [relativeLinks()],
});
Build as usual with npm run build
etc. All links in the project will be generated as relative paths.
dist/index.html
<link rel="stylesheet" href="./_astro/index.*.css" />
<script type="module" src="./_astro/hoisted.*.js"></script>
dist/sub/index.html
<link rel="stylesheet" href="../_astro/index.*.css" />
<script type="module" src="../_astro/hoisted.*.js"></script>
src/components/Header.astro
<a href="/">Home</a>
<a href="/apple/">
<img src="/images/apple.png" alt="" />
Apple
</a>
<a href="/banana/">
<img src="/images/banana.png" alt="" />
Banana
</a>
The above components will be generated as follows.
dist/index.html
<a href="./">Home</a>
<a href="./apple/">
<img src="./images/apple.png" alt="" />
Apple
</a>
<a href="./banana/">
<img src="./images/banana.png" alt="" />
Banana
</a>
dist/apple/index.html
<a href="../">Home</a>
<a href="../apple/">
<img src="../images/apple.png" alt="" />
Apple
</a>
<a href="../banana/">
<img src="../images/banana.png" alt="" />
Banana
</a>
dist/banana/index.html
<a href="../">Home</a>
<a href="../apple/">
<img src="../images/apple.png" alt="" />
Apple
</a>
<a href="../banana/">
<img src="../images/banana.png" alt="" />
Banana
</a>
base
configastro.config.mjs
import { defineConfig } from 'astro/config';
import relativeLinks from 'astro-relative-links';
export default defineConfig({
base: 'fruits',
integrations: [relativeLinks()],
});
src/components/Header.astro
<a href="/">Home</a>
<a href="/fruits/">Fruits</a>
<a href="/fruits/apple/">
<img src="/fruits/images/apple.png" alt="" />
Apple
</a>
<a href="/fruits/banana/">
<img src="/fruits/images/banana.png" alt="" />
Banana
</a>
The above components will be generated as follows.
dist/index.html
<a href="/">Home</a>
<a href="./">Fruits</a>
<a href="./apple/">
<img src="./images/apple.png" alt="" />
Apple
</a>
<a href="./banana/">
<img src="./images/banana.png" alt="" />
Banana
</a>
dist/apple/index.html
<a href="/">Home</a>
<a href="../">Fruits</a>
<a href="../apple/">
<img src="../images/apple.png" alt="" />
Apple
</a>
<a href="../banana/">
<img src="../images/banana.png" alt="" />
Banana
</a>
dist/banana/index.html
<a href="/">Home</a>
<a href="../">Fruits</a>
<a href="../apple/">
<img src="../images/apple.png" alt="" />
Apple
</a>
<a href="../banana/">
<img src="../images/banana.png" alt="" />
Banana
</a>
FAQs
Build Astro with relative links.
The npm package astro-relative-links receives a total of 704 weekly downloads. As such, astro-relative-links popularity was classified as not popular.
We found that astro-relative-links demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.