Skip to content

Commit

Permalink
Allow same domain links to not be outbound, fixes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
Apostolique committed Dec 16, 2023
1 parent 7536391 commit 1dd87fc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
DESCRIPTION: Documentation static site generator.
BASE: apos-docs
REPO: https://github.com/Apostolique/apos-docs/tree/main/
URL: https://apostolique.github.io/apos-docs/
ANALYTICS: G-TK6SK1XJRV

jobs:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Takes in a `docs` directory along with your main `README.md`. Compiles the outpu

## Documentation

* [Getting started](./docs/getting-started.md)
* [Design choices](./docs/design-choices.md)
* [Markdown showcase](./docs/markdown.md)
* [Getting started](https://apostolique.github.io/apos-docs/getting-started/)
* [Design choices](https://apostolique.github.io/apos-docs/design-choices/)
* [Markdown showcase](https://apostolique.github.io/apos-docs/markdown/)

## Tech Stack

Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ program
.option('-d, --desc <description>', 'description for the project', 'No description.')
.option('-p, --path <path>', 'path to the markdown documentation files', 'docs')
.option('-a, --analytics <analytics>', 'code for your Google Analytics 4 property.')
.option('-u, --url <url>', 'the GitHub pages url of the generated site. For example: "https://apostolique.github.io/apos-docs/"')
.requiredOption('-b, --base <url>', 'base url for the relative links. For example: "apos-docs"')
.requiredOption('-r, --repo <url>', 'repo url for edit links. For example: "https://github.com/Apostolique/apos-docs/tree/main/"')
.parse();
Expand Down Expand Up @@ -45,5 +46,6 @@ fs.writeJsonSync('apos-docs/docs/_data/site.json', {
pathPrefix: options.base,
repo: options.repo,
docs: options.path,
analytics: options.analytics
analytics: options.analytics,
url: options.url
})
6 changes: 4 additions & 2 deletions src/_plugins/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ module.exports = (md, opts) => {
const url = hrefAttr[1]
const isOutbound = /^(?:[a-z]+:)?\/\//.test(url)
if (isOutbound) {
token.attrSet('target', '_blank')
token.attrSet('rel', 'noopener noreferrer')
if (!site.url || !url.startsWith(site.url)) {
token.attrSet('target', '_blank')
token.attrSet('rel', 'noopener noreferrer')
}
} else if (!url.startsWith('#') && !url.startsWith('mailto:')) {
normalizeHref(hrefAttr, env, token, true, false)
}
Expand Down

0 comments on commit 1dd87fc

Please sign in to comment.