Skip to content

Commit

Permalink
fix: add an option to disable new tabs in modern template (#8718)
Browse files Browse the repository at this point in the history
* fix: add an option to disable new tabs in modern template

* test(snapshot): update snapshots for 0a19fd4

---------

Co-authored-by: yufeih <[email protected]>
  • Loading branch information
yufeih and yufeih authored May 4, 2023
1 parent e2c800a commit 6d80b63
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/docs/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ Name | Type | Description
`_appLogoPath` | string | App logo URL path.
`_appFaviconPath` | string | Favicon URL path.
`_enableSearch` | bool | Whether to show the search box.
`_enableNewTab` | bool | Whether to open external links in a new tab.
`_noindex` | bool | Whether to include in search results
`_noindex` | bool | Whether to include in search results
`_disableContribution` | bool | Whether to show the _"Edit this page"_ button.
`_gitContribute` | object | Defines the `repo` and `branch` property of git links.
`_gitUrlPattern` | string | URL pattern of git links.
`_disableNewTab` | bool | Whether to render external link indicator icons and open external links in a new tab.
`_disableNextArticle` | bool | Whether to show the previous and next article link.
`lang` | string | Primary language of the page. If unset, the `<html>` tag will not have `lang` property.
`layout` | string | Determines the layout of the page. Supported values are `landing` and `chromeless`.
Expand Down
1 change: 1 addition & 0 deletions samples/seed/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
layout: landing
lang: zh-CN
_disableNewTab: true
---

# docfx-seed
Expand Down
1 change: 1 addition & 0 deletions templates/modern/layout/_master.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<meta name="docfx:tocrel" content="{{_tocRel}}">
{{#_noindex}}<meta name="searchOption" content="noindex">{{/_noindex}}
{{#_enableSearch}}<meta name="docfx:rel" content="{{_rel}}">{{/_enableSearch}}
{{#_disableNewTab}}<meta name="docfx:disablenewtab" content="true">{{/_disableNewTab}}
{{#docurl}}<meta name="docfx:docurl" content="{{docurl}}">{{/docurl}}

<script type="module">
Expand Down
6 changes: 5 additions & 1 deletion templates/modern/src/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import { breakWord } from './helper'
import { breakWord, meta } from './helper'
import AnchorJs from 'anchor-js'
import { html, render } from 'lit-html'
import mermaid from 'mermaid'
Expand Down Expand Up @@ -118,6 +118,10 @@ function renderAlerts() {
* Open external links to different host in a new window.
*/
function renderLinks() {
if (meta('docfx:disablenewtab') === 'true') {
return
}

document.querySelectorAll<HTMLAnchorElement>('article a[href]').forEach(a => {
if (a.hostname !== window.location.hostname && a.innerText.trim() !== '') {
a.target = '_blank'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"conceptual": "\n<h2 id=\"description\" sourcefile=\"index.md\" sourcestartlinenumber=\"7\">Description</h2>\n<p sourcefile=\"index.md\" sourcestartlinenumber=\"8\">This is a sample docfx documentation project. It contains .NET source code and markdown files.\n<code sourcefile=\"index.md\" sourcestartlinenumber=\"9\">docfx.json</code> is the configuration file for running <code sourcefile=\"index.md\" sourcestartlinenumber=\"9\">docfx</code>.\n<code sourcefile=\"index.md\" sourcestartlinenumber=\"10\">docfx</code> will generate a static website as similar to <a href=\"http://docascode.github.io/docfx-seed/index.html\" sourcefile=\"index.md\" sourcestartlinenumber=\"10\">http://docascode.github.io/docfx-seed</a>.</p>\n<h2 id=\"how-to-run\" sourcefile=\"index.md\" sourcestartlinenumber=\"12\">How to run</h2>\n<h3 id=\"under-windows\" sourcefile=\"index.md\" sourcestartlinenumber=\"13\">Under Windows</h3>\n<ul sourcefile=\"index.md\" sourcestartlinenumber=\"14\">\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"14\">Download and unzip <a href=\"https://github.com/dotnet/docfx/releases/latest\" sourcefile=\"index.md\" sourcestartlinenumber=\"14\">docfx.zip</a> to run <code sourcefile=\"index.md\" sourcestartlinenumber=\"14\">docfx.exe</code> directly!</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"15\">Run <code sourcefile=\"index.md\" sourcestartlinenumber=\"15\">docfx</code> under current repo! Website will be generated under <code sourcefile=\"index.md\" sourcestartlinenumber=\"15\">_site</code> folder.</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"16\">Run any web hosting tool to host <code sourcefile=\"index.md\" sourcestartlinenumber=\"16\">_site</code> folder, e.g. <code sourcefile=\"index.md\" sourcestartlinenumber=\"16\">docfx serve _site</code>.</li>\n</ul>\n<h3 id=\"cross-platform-and-use-dnx\" sourcefile=\"index.md\" sourcestartlinenumber=\"18\">Cross platform and use <code sourcefile=\"index.md\" sourcestartlinenumber=\"18\">dnx</code></h3>\n<p sourcefile=\"index.md\" sourcestartlinenumber=\"19\">As a prerequisite, you will need to install <a href=\"http://docs.asp.net/en/latest/getting-started/installing-on-windows.html#install-the-net-version-manager-dnvm\" sourcefile=\"index.md\" sourcestartlinenumber=\"19\">DNVM</a> and <a href=\"http://docs.asp.net/en/latest/getting-started/installing-on-windows.html#install-the-net-execution-environment-dnx\" sourcefile=\"index.md\" sourcestartlinenumber=\"19\">DNX</a>.\n###Quick Start</p>\n<ul sourcefile=\"index.md\" sourcestartlinenumber=\"21\">\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"21\"><p sourcefile=\"index.md\" sourcestartlinenumber=\"21\"><code sourcefile=\"index.md\" sourcestartlinenumber=\"21\">dnvm upgrade</code> to get the latest dnvm.</p>\n</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"22\"><p sourcefile=\"index.md\" sourcestartlinenumber=\"22\">Add feed <a href=\"https://www.myget.org/F/aspnetrelease/api/v2/\" sourcefile=\"index.md\" sourcestartlinenumber=\"22\">https://www.myget.org/F/aspnetrelease/api/v2/</a> to Nuget.config</p>\n<blockquote sourcefile=\"index.md\" sourcestartlinenumber=\"23\">\n<p sourcefile=\"index.md\" sourcestartlinenumber=\"23\">For Windows, the nuget config file is <strong sourcefile=\"index.md\" sourcestartlinenumber=\"23\">%AppData%\\NuGet\\NuGet.config</strong>.</p>\n</blockquote>\n<blockquote sourcefile=\"index.md\" sourcestartlinenumber=\"25\">\n<p sourcefile=\"index.md\" sourcestartlinenumber=\"25\">For Linux/OSX, the nuget config file is <strong sourcefile=\"index.md\" sourcestartlinenumber=\"25\">~/.config/NuGet/NuGet.config</strong>.</p>\n</blockquote>\n<pre><code sourcefile=\"index.md\" sourcestartlinenumber=\"26\"></code></pre>\n</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"27\"><p sourcefile=\"index.md\" sourcestartlinenumber=\"27\"><code sourcefile=\"index.md\" sourcestartlinenumber=\"27\">dnu commands install docfx</code> to install <code sourcefile=\"index.md\" sourcestartlinenumber=\"27\">docfx</code> as a command</p>\n</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"28\"><p sourcefile=\"index.md\" sourcestartlinenumber=\"28\">Run <code sourcefile=\"index.md\" sourcestartlinenumber=\"28\">docfx</code> under current repo! Website will be generated under <code sourcefile=\"index.md\" sourcestartlinenumber=\"28\">_site</code> folder.</p>\n</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"29\"><p sourcefile=\"index.md\" sourcestartlinenumber=\"29\">Run any web hosting tool to host <code sourcefile=\"index.md\" sourcestartlinenumber=\"29\">_site</code> folder, e.g. <code sourcefile=\"index.md\" sourcestartlinenumber=\"29\">docfx serve _site</code>.</p>\n</li>\n</ul>\n<h2 id=\"further-information-about-docfx\" sourcefile=\"index.md\" sourcestartlinenumber=\"31\">Further information about <code sourcefile=\"index.md\" sourcestartlinenumber=\"31\">docfx</code></h2>\n<p sourcefile=\"index.md\" sourcestartlinenumber=\"32\"><code sourcefile=\"index.md\" sourcestartlinenumber=\"32\">docfx</code> is a tool to generate documentation towards .NET source code and markdown files. Please refer to <a href=\"http://dotnet.github.io/docfx/tutorial/docfx_getting_started.html\" sourcefile=\"index.md\" sourcestartlinenumber=\"32\">docfx</a> to get start. The <code sourcefile=\"index.md\" sourcestartlinenumber=\"32\">docfx</code> website itself is generated by <code sourcefile=\"index.md\" sourcestartlinenumber=\"32\">docfx</code>!</p>\n",
"conceptual": "\n<h2 id=\"description\" sourcefile=\"index.md\" sourcestartlinenumber=\"8\">Description</h2>\n<p sourcefile=\"index.md\" sourcestartlinenumber=\"9\">This is a sample docfx documentation project. It contains .NET source code and markdown files.\n<code sourcefile=\"index.md\" sourcestartlinenumber=\"10\">docfx.json</code> is the configuration file for running <code sourcefile=\"index.md\" sourcestartlinenumber=\"10\">docfx</code>.\n<code sourcefile=\"index.md\" sourcestartlinenumber=\"11\">docfx</code> will generate a static website as similar to <a href=\"http://docascode.github.io/docfx-seed/index.html\" sourcefile=\"index.md\" sourcestartlinenumber=\"11\">http://docascode.github.io/docfx-seed</a>.</p>\n<h2 id=\"how-to-run\" sourcefile=\"index.md\" sourcestartlinenumber=\"13\">How to run</h2>\n<h3 id=\"under-windows\" sourcefile=\"index.md\" sourcestartlinenumber=\"14\">Under Windows</h3>\n<ul sourcefile=\"index.md\" sourcestartlinenumber=\"15\">\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"15\">Download and unzip <a href=\"https://github.com/dotnet/docfx/releases/latest\" sourcefile=\"index.md\" sourcestartlinenumber=\"15\">docfx.zip</a> to run <code sourcefile=\"index.md\" sourcestartlinenumber=\"15\">docfx.exe</code> directly!</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"16\">Run <code sourcefile=\"index.md\" sourcestartlinenumber=\"16\">docfx</code> under current repo! Website will be generated under <code sourcefile=\"index.md\" sourcestartlinenumber=\"16\">_site</code> folder.</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"17\">Run any web hosting tool to host <code sourcefile=\"index.md\" sourcestartlinenumber=\"17\">_site</code> folder, e.g. <code sourcefile=\"index.md\" sourcestartlinenumber=\"17\">docfx serve _site</code>.</li>\n</ul>\n<h3 id=\"cross-platform-and-use-dnx\" sourcefile=\"index.md\" sourcestartlinenumber=\"19\">Cross platform and use <code sourcefile=\"index.md\" sourcestartlinenumber=\"19\">dnx</code></h3>\n<p sourcefile=\"index.md\" sourcestartlinenumber=\"20\">As a prerequisite, you will need to install <a href=\"http://docs.asp.net/en/latest/getting-started/installing-on-windows.html#install-the-net-version-manager-dnvm\" sourcefile=\"index.md\" sourcestartlinenumber=\"20\">DNVM</a> and <a href=\"http://docs.asp.net/en/latest/getting-started/installing-on-windows.html#install-the-net-execution-environment-dnx\" sourcefile=\"index.md\" sourcestartlinenumber=\"20\">DNX</a>.\n###Quick Start</p>\n<ul sourcefile=\"index.md\" sourcestartlinenumber=\"22\">\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"22\"><p sourcefile=\"index.md\" sourcestartlinenumber=\"22\"><code sourcefile=\"index.md\" sourcestartlinenumber=\"22\">dnvm upgrade</code> to get the latest dnvm.</p>\n</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"23\"><p sourcefile=\"index.md\" sourcestartlinenumber=\"23\">Add feed <a href=\"https://www.myget.org/F/aspnetrelease/api/v2/\" sourcefile=\"index.md\" sourcestartlinenumber=\"23\">https://www.myget.org/F/aspnetrelease/api/v2/</a> to Nuget.config</p>\n<blockquote sourcefile=\"index.md\" sourcestartlinenumber=\"24\">\n<p sourcefile=\"index.md\" sourcestartlinenumber=\"24\">For Windows, the nuget config file is <strong sourcefile=\"index.md\" sourcestartlinenumber=\"24\">%AppData%\\NuGet\\NuGet.config</strong>.</p>\n</blockquote>\n<blockquote sourcefile=\"index.md\" sourcestartlinenumber=\"26\">\n<p sourcefile=\"index.md\" sourcestartlinenumber=\"26\">For Linux/OSX, the nuget config file is <strong sourcefile=\"index.md\" sourcestartlinenumber=\"26\">~/.config/NuGet/NuGet.config</strong>.</p>\n</blockquote>\n<pre><code sourcefile=\"index.md\" sourcestartlinenumber=\"27\"></code></pre>\n</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"28\"><p sourcefile=\"index.md\" sourcestartlinenumber=\"28\"><code sourcefile=\"index.md\" sourcestartlinenumber=\"28\">dnu commands install docfx</code> to install <code sourcefile=\"index.md\" sourcestartlinenumber=\"28\">docfx</code> as a command</p>\n</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"29\"><p sourcefile=\"index.md\" sourcestartlinenumber=\"29\">Run <code sourcefile=\"index.md\" sourcestartlinenumber=\"29\">docfx</code> under current repo! Website will be generated under <code sourcefile=\"index.md\" sourcestartlinenumber=\"29\">_site</code> folder.</p>\n</li>\n<li sourcefile=\"index.md\" sourcestartlinenumber=\"30\"><p sourcefile=\"index.md\" sourcestartlinenumber=\"30\">Run any web hosting tool to host <code sourcefile=\"index.md\" sourcestartlinenumber=\"30\">_site</code> folder, e.g. <code sourcefile=\"index.md\" sourcestartlinenumber=\"30\">docfx serve _site</code>.</p>\n</li>\n</ul>\n<h2 id=\"further-information-about-docfx\" sourcefile=\"index.md\" sourcestartlinenumber=\"32\">Further information about <code sourcefile=\"index.md\" sourcestartlinenumber=\"32\">docfx</code></h2>\n<p sourcefile=\"index.md\" sourcestartlinenumber=\"33\"><code sourcefile=\"index.md\" sourcestartlinenumber=\"33\">docfx</code> is a tool to generate documentation towards .NET source code and markdown files. Please refer to <a href=\"http://dotnet.github.io/docfx/tutorial/docfx_getting_started.html\" sourcefile=\"index.md\" sourcestartlinenumber=\"33\">docfx</a> to get start. The <code sourcefile=\"index.md\" sourcestartlinenumber=\"33\">docfx</code> website itself is generated by <code sourcefile=\"index.md\" sourcestartlinenumber=\"33\">docfx</code>!</p>\n",
"type": "Conceptual",
"source": {
"remote": {
Expand All @@ -25,7 +25,8 @@
"_appName": "Seed",
"_appTitle": "docfx seed website",
"_enableSearch": true,
"rawTitle": "<h1 id=\"docfx-seed\" sourcefile=\"index.md\" sourcestartlinenumber=\"6\">docfx-seed</h1>",
"rawTitle": "<h1 id=\"docfx-seed\" sourcefile=\"index.md\" sourcestartlinenumber=\"7\">docfx-seed</h1>",
"_disableNewTab": true,
"lang": "zh-CN",
"layout": "landing",
"title": "docfx-seed",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<meta name="docfx:tocrel" content="toc.html">

<meta name="docfx:rel" content="../">

<meta name="docfx:docurl" content="https://github.com/dotnet/docfx/new/main/apiSpec/new?filename=BuildFromProject_Class1.md&amp;value=---%0Auid%3A%20BuildFromProject.Class1%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">

<script type="module">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<meta name="docfx:tocrel" content="toc.html">

<meta name="docfx:rel" content="../">

<meta name="docfx:docurl" content="https://github.com/dotnet/docfx/blob/main/samples/seed/specs/Cat.md/#L2">

<script type="module">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<meta name="docfx:rel" content="../">



<script type="module">
import docfx from './../public/main.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<meta name="docfx:rel" content="../">



<script type="module">
import docfx from './../public/main.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<meta name="docfx:tocrel" content="toc.html">

<meta name="docfx:rel" content="../">

<meta name="docfx:docurl" content="https://github.com/dotnet/docfx/blob/main/samples/seed/articles/csharp_coding_standards.md/#L1">

<script type="module">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<meta name="docfx:tocrel" content="toc.html">

<meta name="docfx:rel" content="../">

<meta name="docfx:docurl" content="https://github.com/dotnet/docfx/blob/main/samples/seed/articles/markdown.md/#L1">

<script type="module">
Expand Down
Loading

0 comments on commit 6d80b63

Please sign in to comment.