mirror of
https://github.com/danog/sass-site.git
synced 2024-11-26 12:04:40 +01:00
Remove old eslint/prettier rules
This commit is contained in:
parent
792513028a
commit
97e4f71a0c
54
.eslintrc.js
54
.eslintrc.js
@ -1,54 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
parserOptions: {
|
|
||||||
sourceType: 'script',
|
|
||||||
ecmaVersion: 2021,
|
|
||||||
tsconfigRootDir: __dirname,
|
|
||||||
warnOnUnsupportedTypeScriptVersion: false,
|
|
||||||
},
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
es2021: true,
|
|
||||||
node: true,
|
|
||||||
},
|
|
||||||
plugins: ['import', 'simple-import-sort', '@typescript-eslint'],
|
|
||||||
extends: [
|
|
||||||
'eslint:recommended',
|
|
||||||
'plugin:import/recommended',
|
|
||||||
'plugin:import/typescript',
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
'prettier',
|
|
||||||
],
|
|
||||||
settings: {
|
|
||||||
'import/resolver': {
|
|
||||||
typescript: {
|
|
||||||
project: ['tsconfig.json'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
overrides: [
|
|
||||||
{
|
|
||||||
files: ['*.ts'],
|
|
||||||
parserOptions: {
|
|
||||||
sourceType: 'module',
|
|
||||||
project: ['tsconfig.json'],
|
|
||||||
},
|
|
||||||
extends: [
|
|
||||||
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
||||||
],
|
|
||||||
rules: {
|
|
||||||
'import/order': 0,
|
|
||||||
'sort-imports': 0,
|
|
||||||
'simple-import-sort/imports': 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
rules: {
|
|
||||||
'import/order': 1,
|
|
||||||
'simple-import-sort/imports': 0,
|
|
||||||
'@typescript-eslint/no-var-requires': 0,
|
|
||||||
'no-console': 1,
|
|
||||||
'no-warning-comments': [1, { terms: ['todo', 'fixme', '@@@'] }],
|
|
||||||
},
|
|
||||||
};
|
|
@ -1,3 +1,11 @@
|
|||||||
{
|
{
|
||||||
"extends": "./node_modules/gts/"
|
"extends": "./node_modules/gts/",
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2021
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"node/no-unpublished-import": "off",
|
||||||
|
"node/no-unpublished-require": "off"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: 'github-actions'
|
||||||
|
directory: '/'
|
||||||
|
schedule:
|
||||||
|
interval: 'weekly'
|
||||||
|
- package-ecosystem: 'yarn'
|
||||||
|
directory: '/'
|
||||||
|
schedule:
|
||||||
|
interval: 'weekly'
|
@ -1,2 +0,0 @@
|
|||||||
singleQuote: true
|
|
||||||
trailingComma: all
|
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { EleventyRenderPlugin } = require('@11ty/eleventy');
|
const {EleventyRenderPlugin} = require('@11ty/eleventy');
|
||||||
const {
|
const {
|
||||||
absoluteUrl,
|
absoluteUrl,
|
||||||
convertHtmlToAbsoluteUrls,
|
convertHtmlToAbsoluteUrls,
|
||||||
@ -13,13 +13,13 @@ const yaml = require('js-yaml');
|
|||||||
const componentsPlugin =
|
const componentsPlugin =
|
||||||
require('./source/helpers/components/index.ts').default;
|
require('./source/helpers/components/index.ts').default;
|
||||||
const datesPlugin = require('./source/helpers/dates.ts').default;
|
const datesPlugin = require('./source/helpers/dates.ts').default;
|
||||||
const { liquidEngine, markdownEngine } = require('./source/helpers/engines.ts');
|
const {liquidEngine, markdownEngine} = require('./source/helpers/engines.ts');
|
||||||
const pagesPlugin = require('./source/helpers/pages.ts').default;
|
const pagesPlugin = require('./source/helpers/pages.ts').default;
|
||||||
const typePlugin = require('./source/helpers/type.ts').default;
|
const typePlugin = require('./source/helpers/type.ts').default;
|
||||||
const functionPlugin = require('./source/helpers/function.ts').default;
|
const functionPlugin = require('./source/helpers/function.ts').default;
|
||||||
|
|
||||||
/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
|
/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
|
||||||
module.exports = (eleventyConfig) => {
|
module.exports = eleventyConfig => {
|
||||||
eleventyConfig.addPassthroughCopy('source/assets/dist');
|
eleventyConfig.addPassthroughCopy('source/assets/dist');
|
||||||
eleventyConfig.addPassthroughCopy('source/assets/img');
|
eleventyConfig.addPassthroughCopy('source/assets/img');
|
||||||
eleventyConfig.addPassthroughCopy('source/favicon.ico');
|
eleventyConfig.addPassthroughCopy('source/favicon.ico');
|
||||||
@ -34,9 +34,7 @@ module.exports = (eleventyConfig) => {
|
|||||||
|
|
||||||
eleventyConfig.setLibrary('liquid', liquidEngine);
|
eleventyConfig.setLibrary('liquid', liquidEngine);
|
||||||
eleventyConfig.setLibrary('md', markdownEngine);
|
eleventyConfig.setLibrary('md', markdownEngine);
|
||||||
eleventyConfig.addDataExtension('yml, yaml', (contents) =>
|
eleventyConfig.addDataExtension('yml, yaml', contents => yaml.load(contents));
|
||||||
yaml.load(contents),
|
|
||||||
);
|
|
||||||
eleventyConfig.addDataExtension('ts', (_, filepath) => require(filepath));
|
eleventyConfig.addDataExtension('ts', (_, filepath) => require(filepath));
|
||||||
|
|
||||||
// register filters and shortcodes
|
// register filters and shortcodes
|
||||||
@ -50,12 +48,12 @@ module.exports = (eleventyConfig) => {
|
|||||||
eleventyConfig.addLiquidFilter('absoluteUrl', absoluteUrl);
|
eleventyConfig.addLiquidFilter('absoluteUrl', absoluteUrl);
|
||||||
eleventyConfig.addLiquidFilter(
|
eleventyConfig.addLiquidFilter(
|
||||||
'getNewestCollectionItemDate',
|
'getNewestCollectionItemDate',
|
||||||
getNewestCollectionItemDate,
|
getNewestCollectionItemDate
|
||||||
);
|
);
|
||||||
eleventyConfig.addLiquidFilter('dateToRfc3339', dateToRfc3339);
|
eleventyConfig.addLiquidFilter('dateToRfc3339', dateToRfc3339);
|
||||||
eleventyConfig.addLiquidFilter(
|
eleventyConfig.addLiquidFilter(
|
||||||
'htmlToAbsoluteUrls',
|
'htmlToAbsoluteUrls',
|
||||||
convertHtmlToAbsoluteUrls,
|
convertHtmlToAbsoluteUrls
|
||||||
);
|
);
|
||||||
|
|
||||||
// other plugins
|
// other plugins
|
||||||
|
16
package.json
16
package.json
@ -62,21 +62,16 @@
|
|||||||
"@types/markdown-it-footnote": "^3.0.0",
|
"@types/markdown-it-footnote": "^3.0.0",
|
||||||
"@types/node": "^16",
|
"@types/node": "^16",
|
||||||
"@types/prismjs": "^1.26.0",
|
"@types/prismjs": "^1.26.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
"@types/semver": "^7.5.0",
|
||||||
"@typescript-eslint/parser": "^5.60.0",
|
|
||||||
"cheerio": "^1.0.0-rc.12",
|
"cheerio": "^1.0.0-rc.12",
|
||||||
"date-fns": "^2.30.0",
|
"date-fns": "^2.30.0",
|
||||||
"deep-equal": "^2.2.1",
|
"deep-equal": "^2.2.1",
|
||||||
"eslint": "^8.43.0",
|
|
||||||
"eslint-config-prettier": "^8.8.0",
|
|
||||||
"eslint-import-resolver-typescript": "^3.5.5",
|
|
||||||
"eslint-plugin-import": "^2.27.5",
|
|
||||||
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
||||||
"gts": "^3.1.1",
|
"gts": "^3.1.1",
|
||||||
"jquery": "^3.7.0",
|
"jquery": "^3.7.0",
|
||||||
"jquery-ui": "^1.13.2",
|
"jquery-ui": "^1.13.2",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"kleur": "^4.1.5",
|
"kleur": "^4.1.5",
|
||||||
|
"liquidjs": "^10.8.3",
|
||||||
"lorem-ipsum": "^2.0.8",
|
"lorem-ipsum": "^2.0.8",
|
||||||
"markdown-it": "^13.0.1",
|
"markdown-it": "^13.0.1",
|
||||||
"markdown-it-anchor": "^8.6.7",
|
"markdown-it-anchor": "^8.6.7",
|
||||||
@ -100,12 +95,5 @@
|
|||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"tslib": ">=2"
|
"tslib": ">=2"
|
||||||
},
|
|
||||||
"yarn-upgrade-all": {
|
|
||||||
"ignore": [
|
|
||||||
"@sindresorhus/slugify",
|
|
||||||
"@types/node",
|
|
||||||
"strip-indent"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
const { babel } = require('@rollup/plugin-babel');
|
const {babel} = require('@rollup/plugin-babel');
|
||||||
const commonjs = require('@rollup/plugin-commonjs');
|
const commonjs = require('@rollup/plugin-commonjs');
|
||||||
const inject = require('@rollup/plugin-inject');
|
const inject = require('@rollup/plugin-inject');
|
||||||
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
const {nodeResolve} = require('@rollup/plugin-node-resolve');
|
||||||
const terser = require('@rollup/plugin-terser');
|
const terser = require('@rollup/plugin-terser');
|
||||||
const { defineConfig } = require('rollup');
|
const {defineConfig} = require('rollup');
|
||||||
|
|
||||||
const prod = process.env.BABEL_ENV === 'production';
|
const prod = process.env.BABEL_ENV === 'production';
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ const plugins = [
|
|||||||
browser: true,
|
browser: true,
|
||||||
}),
|
}),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
babel({ extensions: ['.js', '.ts'], babelHelpers: 'bundled' }),
|
babel({extensions: ['.js', '.ts'], babelHelpers: 'bundled'}),
|
||||||
inject({
|
inject({
|
||||||
$: 'jquery',
|
$: 'jquery',
|
||||||
jQuery: 'jquery',
|
jQuery: 'jquery',
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
import {
|
import {spawn as nodeSpawn, SpawnOptionsWithoutStdio} from 'node:child_process';
|
||||||
spawn as nodeSpawn,
|
|
||||||
SpawnOptionsWithoutStdio,
|
|
||||||
} from 'node:child_process';
|
|
||||||
import fs from 'node:fs/promises';
|
import fs from 'node:fs/promises';
|
||||||
|
|
||||||
import deepEqual from 'deep-equal';
|
import deepEqual from 'deep-equal';
|
||||||
import kleur from 'kleur';
|
import kleur from 'kleur';
|
||||||
import { compare, parse } from 'semver';
|
import {compare, parse} from 'semver';
|
||||||
|
|
||||||
type VersionCache = Record<string, string>;
|
type VersionCache = Record<string, string>;
|
||||||
|
|
||||||
@ -19,7 +16,7 @@ const VERSION_CACHE_PATH = './source/_data/versionCache.json';
|
|||||||
const spawn = (
|
const spawn = (
|
||||||
cmd: string,
|
cmd: string,
|
||||||
args: string[],
|
args: string[],
|
||||||
options: SpawnOptionsWithoutStdio,
|
options: SpawnOptionsWithoutStdio
|
||||||
) => {
|
) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const child = nodeSpawn(cmd, args, options);
|
const child = nodeSpawn(cmd, args, options);
|
||||||
@ -64,7 +61,7 @@ const getCacheFile = async () => {
|
|||||||
*/
|
*/
|
||||||
const writeCacheFile = async (cache: VersionCache) => {
|
const writeCacheFile = async (cache: VersionCache) => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.info(kleur.green(`[11ty] Writing version cache file...`));
|
console.info(kleur.green('[11ty] Writing version cache file...'));
|
||||||
await fs.writeFile(VERSION_CACHE_PATH, JSON.stringify(cache));
|
await fs.writeFile(VERSION_CACHE_PATH, JSON.stringify(cache));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,7 +76,7 @@ const getLatestVersion = async (repo: string) => {
|
|||||||
stdout = (await spawn(
|
stdout = (await spawn(
|
||||||
'git',
|
'git',
|
||||||
['ls-remote', '--tags', '--refs', `https://github.com/${repo}`],
|
['ls-remote', '--tags', '--refs', `https://github.com/${repo}`],
|
||||||
{ env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } },
|
{env: {...process.env, GIT_TERMINAL_PROMPT: '0'}}
|
||||||
)) as string;
|
)) as string;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
@ -92,7 +89,7 @@ const getLatestVersion = async (repo: string) => {
|
|||||||
};
|
};
|
||||||
const version = stdout
|
const version = stdout
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map((line) => line.split('refs/tags/').at(-1) ?? '')
|
.map(line => line.split('refs/tags/').at(-1) ?? '')
|
||||||
.filter(isNotPreRelease)
|
.filter(isNotPreRelease)
|
||||||
.sort(compare)
|
.sort(compare)
|
||||||
.at(-1);
|
.at(-1);
|
||||||
@ -108,16 +105,16 @@ module.exports = async () => {
|
|||||||
const cache = await getCacheFile();
|
const cache = await getCacheFile();
|
||||||
|
|
||||||
const versions = await Promise.all(
|
const versions = await Promise.all(
|
||||||
repos.map(async (repo) => [
|
repos.map(async repo => [
|
||||||
repo,
|
repo,
|
||||||
cache[repo] ?? (await getLatestVersion(repo)),
|
cache[repo] ?? (await getLatestVersion(repo)),
|
||||||
]),
|
])
|
||||||
);
|
);
|
||||||
const data = Object.fromEntries(
|
const data = Object.fromEntries(
|
||||||
versions.map(([repo, version]) => [
|
versions.map(([repo, version]) => [
|
||||||
repo.replace('sass/', ''),
|
repo.replace('sass/', ''),
|
||||||
{ version, url: `https://github.com/${repo}/releases/tag/${version}` },
|
{version, url: `https://github.com/${repo}/releases/tag/${version}`},
|
||||||
]),
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
const nextCache = Object.fromEntries(versions) as VersionCache;
|
const nextCache = Object.fromEntries(versions) as VersionCache;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
$(function () {
|
$(() => {
|
||||||
$('.impl-status').each(function () {
|
$('.impl-status').each(function () {
|
||||||
const statusBar = $(this);
|
const statusBar = $(this);
|
||||||
const expandLink = statusBar.find('a');
|
const expandLink = statusBar.find('a');
|
||||||
|
// eslint-disable-next-line eqeqeq
|
||||||
if (expandLink == null) {
|
if (expandLink == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -12,7 +13,7 @@ $(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
details.hide();
|
details.hide();
|
||||||
expandLink.on('click', function () {
|
expandLink.on('click', () => {
|
||||||
details.toggle();
|
details.toggle();
|
||||||
expandLink.toggleClass('expanded');
|
expandLink.toggleClass('expanded');
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
$(function () {
|
$(() => {
|
||||||
$('.sl-c-list-navigation-wrapper--collapsible li > ul')
|
$('.sl-c-list-navigation-wrapper--collapsible li > ul')
|
||||||
.parent()
|
.parent()
|
||||||
.children('a')
|
.children('a')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Documentation Nav Scroll
|
// Documentation Nav Scroll
|
||||||
$(function () {
|
$(() => {
|
||||||
// Vars
|
// Vars
|
||||||
const nav = $('.sl-c-list-navigation-wrapper');
|
const nav = $('.sl-c-list-navigation-wrapper');
|
||||||
const sticky = nav.offset();
|
const sticky = nav.offset();
|
||||||
@ -18,7 +18,7 @@ $(function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// When scrolling the page, execute stickyNav
|
// When scrolling the page, execute stickyNav
|
||||||
$(window).on('scroll', function () {
|
$(window).on('scroll', () => {
|
||||||
stickyNav();
|
stickyNav();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ const redirects: Record<string, Record<string, string>> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const { pathname, hash } = window.location;
|
const {pathname, hash} = window.location;
|
||||||
const match = redirects[pathname]?.[hash];
|
const match = redirects[pathname]?.[hash];
|
||||||
if (match) {
|
if (match) {
|
||||||
window.location.href = match;
|
window.location.href = match;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
$(function () {
|
$(() => {
|
||||||
$('.code-example').each(function () {
|
$('.code-example').each(function () {
|
||||||
const figure = $(this);
|
const figure = $(this);
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@ export const renderPermalink: anchor.PermalinkGenerator = (
|
|||||||
slug,
|
slug,
|
||||||
opts: anchor.LinkInsideHeaderPermalinkOptions,
|
opts: anchor.LinkInsideHeaderPermalinkOptions,
|
||||||
state,
|
state,
|
||||||
idx,
|
idx
|
||||||
) => {
|
) => {
|
||||||
// https://github.com/valeriangalliat/markdown-it-anchor/blob/649582d58185b00cfb2ceee9b6b4cd6aafc645b7/permalink.js#L148-L151
|
// https://github.com/valeriangalliat/markdown-it-anchor/blob/649582d58185b00cfb2ceee9b6b4cd6aafc645b7/permalink.js#L148-L151
|
||||||
const title = state.tokens[idx + 1]?.children
|
const title = state.tokens[idx + 1]?.children
|
||||||
?.filter(
|
?.filter(
|
||||||
(token: Token) => token.type === 'text' || token.type === 'code_inline',
|
(token: Token) => token.type === 'text' || token.type === 'code_inline'
|
||||||
)
|
)
|
||||||
.reduce((acc, t) => acc + t.content, '');
|
.reduce((acc, t) => acc + t.content, '');
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ export const renderPermalink: anchor.PermalinkGenerator = (
|
|||||||
}),
|
}),
|
||||||
Object.assign(new state.Token('html_inline', '', 0), {
|
Object.assign(new state.Token('html_inline', '', 0), {
|
||||||
content: opts.symbol,
|
content: opts.symbol,
|
||||||
meta: { isPermalinkSymbol: true },
|
meta: {isPermalinkSymbol: true},
|
||||||
}),
|
}),
|
||||||
new state.Token('link_close', 'a', -1),
|
new state.Token('link_close', 'a', -1),
|
||||||
];
|
];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import sass from 'sass';
|
import sass from 'sass';
|
||||||
import stripIndent from 'strip-indent';
|
import stripIndent from 'strip-indent';
|
||||||
|
|
||||||
import { liquidEngine } from '../engines';
|
import {liquidEngine} from '../engines';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a code example.
|
* Renders a code example.
|
||||||
@ -55,7 +55,7 @@ export default async function codeExample(
|
|||||||
contents: string,
|
contents: string,
|
||||||
exampleName: string,
|
exampleName: string,
|
||||||
autogenCSS = true,
|
autogenCSS = true,
|
||||||
syntax: 'sass' | 'scss' | null = null,
|
syntax: 'sass' | 'scss' | null = null
|
||||||
) {
|
) {
|
||||||
if (!exampleName) {
|
if (!exampleName) {
|
||||||
throw new Error('`{% codeExample %}` tags require a unique name.');
|
throw new Error('`{% codeExample %}` tags require a unique name.');
|
||||||
@ -70,7 +70,7 @@ export default async function codeExample(
|
|||||||
const generateCodeExample = (
|
const generateCodeExample = (
|
||||||
text: string,
|
text: string,
|
||||||
autogenCSS: boolean,
|
autogenCSS: boolean,
|
||||||
syntax: 'sass' | 'scss' | null,
|
syntax: 'sass' | 'scss' | null
|
||||||
) => {
|
) => {
|
||||||
const contents = stripIndent(text);
|
const contents = stripIndent(text);
|
||||||
const splitContents = contents.split('\n===\n');
|
const splitContents = contents.split('\n===\n');
|
||||||
@ -96,9 +96,9 @@ const generateCodeExample = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const scssExamples =
|
const scssExamples =
|
||||||
scssContents?.split('\n---\n').map((str) => str.trim()) ?? [];
|
scssContents?.split('\n---\n').map(str => str.trim()) ?? [];
|
||||||
const sassExamples =
|
const sassExamples =
|
||||||
sassContents?.split('\n---\n').map((str) => str.trim()) ?? [];
|
sassContents?.split('\n---\n').map(str => str.trim()) ?? [];
|
||||||
|
|
||||||
if (!cssContents && autogenCSS) {
|
if (!cssContents && autogenCSS) {
|
||||||
const sections = scssContents ? scssExamples : sassExamples;
|
const sections = scssContents ? scssExamples : sassExamples;
|
||||||
@ -114,18 +114,18 @@ const generateCodeExample = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cssExamples =
|
const cssExamples =
|
||||||
cssContents?.split('\n---\n').map((str) => str.trim()) ?? [];
|
cssContents?.split('\n---\n').map(str => str.trim()) ?? [];
|
||||||
|
|
||||||
const { scssPaddings, sassPaddings, cssPaddings } = getPaddings(
|
const {scssPaddings, sassPaddings, cssPaddings} = getPaddings(
|
||||||
scssExamples,
|
scssExamples,
|
||||||
sassExamples,
|
sassExamples,
|
||||||
cssExamples,
|
cssExamples
|
||||||
);
|
);
|
||||||
|
|
||||||
const { canSplit, maxSourceWidth, maxCSSWidth } = getCanSplit(
|
const {canSplit, maxSourceWidth, maxCSSWidth} = getCanSplit(
|
||||||
scssExamples,
|
scssExamples,
|
||||||
sassExamples,
|
sassExamples,
|
||||||
cssExamples,
|
cssExamples
|
||||||
);
|
);
|
||||||
let splitLocation: number | null = null;
|
let splitLocation: number | null = null;
|
||||||
if (canSplit) {
|
if (canSplit) {
|
||||||
@ -156,7 +156,7 @@ const generateCodeExample = (
|
|||||||
const getPaddings = (
|
const getPaddings = (
|
||||||
scssExamples: string[],
|
scssExamples: string[],
|
||||||
sassExamples: string[],
|
sassExamples: string[],
|
||||||
cssExamples: string[],
|
cssExamples: string[]
|
||||||
) => {
|
) => {
|
||||||
const scssPaddings: number[] = [];
|
const scssPaddings: number[] = [];
|
||||||
const sassPaddings: number[] = [];
|
const sassPaddings: number[] = [];
|
||||||
@ -164,9 +164,9 @@ const getPaddings = (
|
|||||||
const maxSections = Math.max(
|
const maxSections = Math.max(
|
||||||
scssExamples.length,
|
scssExamples.length,
|
||||||
sassExamples.length,
|
sassExamples.length,
|
||||||
cssExamples.length,
|
cssExamples.length
|
||||||
);
|
);
|
||||||
Array.from({ length: maxSections }).forEach((_, i) => {
|
Array.from({length: maxSections}).forEach((_, i) => {
|
||||||
const scssLines = (scssExamples[i] || '').split('\n').length;
|
const scssLines = (scssExamples[i] || '').split('\n').length;
|
||||||
const sassLines = (sassExamples[i] || '').split('\n').length;
|
const sassLines = (sassExamples[i] || '').split('\n').length;
|
||||||
const cssLines = (cssExamples[i] || '').split('\n').length;
|
const cssLines = (cssExamples[i] || '').split('\n').length;
|
||||||
@ -181,7 +181,7 @@ const getPaddings = (
|
|||||||
const maxLines = Math.max(
|
const maxLines = Math.max(
|
||||||
isLastScssSection ? 0 : scssLines,
|
isLastScssSection ? 0 : scssLines,
|
||||||
isLastSassSection ? 0 : sassLines,
|
isLastSassSection ? 0 : sassLines,
|
||||||
isLastCssSection ? 0 : cssLines,
|
isLastCssSection ? 0 : cssLines
|
||||||
);
|
);
|
||||||
|
|
||||||
scssPaddings.push(
|
scssPaddings.push(
|
||||||
@ -191,7 +191,7 @@ const getPaddings = (
|
|||||||
comparisonB: cssExamples.slice(i),
|
comparisonB: cssExamples.slice(i),
|
||||||
lines: scssLines,
|
lines: scssLines,
|
||||||
maxLines,
|
maxLines,
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
sassPaddings.push(
|
sassPaddings.push(
|
||||||
@ -201,7 +201,7 @@ const getPaddings = (
|
|||||||
comparisonB: cssExamples.slice(i),
|
comparisonB: cssExamples.slice(i),
|
||||||
lines: sassLines,
|
lines: sassLines,
|
||||||
maxLines,
|
maxLines,
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
cssPaddings.push(
|
cssPaddings.push(
|
||||||
@ -211,11 +211,11 @@ const getPaddings = (
|
|||||||
comparisonB: sassExamples.slice(i),
|
comparisonB: sassExamples.slice(i),
|
||||||
lines: cssLines,
|
lines: cssLines,
|
||||||
maxLines,
|
maxLines,
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return { scssPaddings, sassPaddings, cssPaddings };
|
return {scssPaddings, sassPaddings, cssPaddings};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -260,7 +260,7 @@ const getTotalPadding = (sections1: string[], sections2: string[]) => {
|
|||||||
sum +
|
sum +
|
||||||
Math.max(
|
Math.max(
|
||||||
(sections1[i] || '').split('\n').length,
|
(sections1[i] || '').split('\n').length,
|
||||||
(sections2[i] || '').split('\n').length,
|
(sections2[i] || '').split('\n').length
|
||||||
) +
|
) +
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
@ -270,15 +270,13 @@ const getTotalPadding = (sections1: string[], sections2: string[]) => {
|
|||||||
const getCanSplit = (
|
const getCanSplit = (
|
||||||
scssExamples: string[],
|
scssExamples: string[],
|
||||||
sassExamples: string[],
|
sassExamples: string[],
|
||||||
cssExamples: string[],
|
cssExamples: string[]
|
||||||
) => {
|
) => {
|
||||||
const exampleSourceLengths = [...scssExamples, ...sassExamples].flatMap(
|
const exampleSourceLengths = [...scssExamples, ...sassExamples].flatMap(
|
||||||
(source) => source.split('\n').map((line) => line.length),
|
source => source.split('\n').map(line => line.length)
|
||||||
);
|
);
|
||||||
const cssSourceLengths = cssExamples.length
|
const cssSourceLengths = cssExamples.length
|
||||||
? cssExamples.flatMap((source) =>
|
? cssExamples.flatMap(source => source.split('\n').map(line => line.length))
|
||||||
source.split('\n').map((line) => line.length),
|
|
||||||
)
|
|
||||||
: [0];
|
: [0];
|
||||||
|
|
||||||
const maxSourceWidth = Math.max(...exampleSourceLengths);
|
const maxSourceWidth = Math.max(...exampleSourceLengths);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import stripIndent from 'strip-indent';
|
import stripIndent from 'strip-indent';
|
||||||
|
|
||||||
import { liquidEngine } from '../engines';
|
import {liquidEngine} from '../engines';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a status dashboard for each implementation's support for a feature.
|
* Renders a status dashboard for each implementation's support for a feature.
|
||||||
@ -42,11 +42,11 @@ interface CompatibilityOptions {
|
|||||||
|
|
||||||
const extend = <
|
const extend = <
|
||||||
K extends keyof CompatibilityOptions,
|
K extends keyof CompatibilityOptions,
|
||||||
V extends CompatibilityOptions[K],
|
V extends CompatibilityOptions[K]
|
||||||
>(
|
>(
|
||||||
value: V,
|
value: V,
|
||||||
obj: CompatibilityOptions,
|
obj: CompatibilityOptions,
|
||||||
key: K,
|
key: K
|
||||||
) => {
|
) => {
|
||||||
obj[key] = value;
|
obj[key] = value;
|
||||||
};
|
};
|
||||||
@ -72,13 +72,13 @@ const parseCompatibilityOpts = (...args: string[]): CompatibilityOptions => {
|
|||||||
if (typeof arg !== 'string') {
|
if (typeof arg !== 'string') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||||
`Received non-string argument to {% compatibility %} tag: ${arg}`,
|
`Received non-string argument to {% compatibility %} tag: ${arg}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const match = arg.match(keyValueRegex);
|
const match = arg.match(keyValueRegex);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Arguments should be in the format 'key:value'; received ${arg}.`,
|
`Arguments should be in the format 'key:value'; received ${arg}.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const key: string = match[1].trim();
|
const key: string = match[1].trim();
|
||||||
@ -90,7 +90,7 @@ const parseCompatibilityOpts = (...args: string[]): CompatibilityOptions => {
|
|||||||
throw new Error(
|
throw new Error(
|
||||||
`Unable to parse argument ${key} with value ${
|
`Unable to parse argument ${key} with value ${
|
||||||
value as string
|
value as string
|
||||||
}. Try wrapping it in double quotes: ${key}:"${value as string}"`,
|
}. Try wrapping it in double quotes: ${key}:"${value as string}"`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (key && Object.hasOwn(opts, key)) {
|
if (key && Object.hasOwn(opts, key)) {
|
||||||
@ -98,7 +98,7 @@ const parseCompatibilityOpts = (...args: string[]): CompatibilityOptions => {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||||
`Received unexpected argument to {% compatibility %} tag: ${arg}`,
|
`Received unexpected argument to {% compatibility %} tag: ${arg}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import { highlight, languages } from 'prismjs';
|
import {highlight, languages} from 'prismjs';
|
||||||
import PrismLoader from 'prismjs/components/index';
|
import PrismLoader from 'prismjs/components/index';
|
||||||
import stripIndent from 'strip-indent';
|
import stripIndent from 'strip-indent';
|
||||||
|
|
||||||
import { liquidEngine } from '../engines';
|
import {liquidEngine} from '../engines';
|
||||||
import { default as codeExample } from './codeExample';
|
import {default as codeExample} from './codeExample';
|
||||||
import { compatibility, implStatus } from './compatibility';
|
import {compatibility, implStatus} from './compatibility';
|
||||||
import { getDocTocData, getToc } from './toc';
|
import {getDocTocData, getToc} from './toc';
|
||||||
|
|
||||||
export { codeExample };
|
export {codeExample};
|
||||||
export { compatibility, implStatus };
|
export {compatibility, implStatus};
|
||||||
export { getDocTocData, getToc };
|
export {getDocTocData, getToc};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns HTML for a fun fact that's not directly relevant to the main
|
* Returns HTML for a fun fact that's not directly relevant to the main
|
||||||
|
@ -9,11 +9,11 @@ type TOCItem = {
|
|||||||
*/
|
*/
|
||||||
export const getDocTocData = (data: TOCItem) => {
|
export const getDocTocData = (data: TOCItem) => {
|
||||||
const text = Object.keys(data).filter(
|
const text = Object.keys(data).filter(
|
||||||
(key) => ![':children', ':expanded'].includes(key),
|
key => ![':children', ':expanded'].includes(key)
|
||||||
)[0];
|
)[0];
|
||||||
const href = data[text] as string;
|
const href = data[text] as string;
|
||||||
const expanded = Boolean(data[':expanded']);
|
const expanded = Boolean(data[':expanded']);
|
||||||
return { text, href, expanded };
|
return {text, href, expanded};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +41,7 @@ export const getToc = (html: string, topLevelTotal: number): TOCItem[] => {
|
|||||||
const level = parseInt(h.name[1], 10);
|
const level = parseInt(h.name[1], 10);
|
||||||
const title = $(h).html() as string;
|
const title = $(h).html() as string;
|
||||||
const id = $(h).attr('id') as string;
|
const id = $(h).attr('id') as string;
|
||||||
const tocItem: TOCItem = { [title]: `#${id}` };
|
const tocItem: TOCItem = {[title]: `#${id}`};
|
||||||
byLevel[level].push(tocItem);
|
byLevel[level].push(tocItem);
|
||||||
if (level === 2) {
|
if (level === 2) {
|
||||||
toc.push(tocItem);
|
toc.push(tocItem);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import slugify from '@sindresorhus/slugify';
|
import slugify from '@sindresorhus/slugify';
|
||||||
import { Liquid } from 'liquidjs';
|
import {Liquid} from 'liquidjs';
|
||||||
import markdown from 'markdown-it';
|
import markdown from 'markdown-it';
|
||||||
import markdownAnchor from 'markdown-it-anchor';
|
import markdownAnchor from 'markdown-it-anchor';
|
||||||
import markdownItAttrs from 'markdown-it-attrs';
|
import markdownItAttrs from 'markdown-it-attrs';
|
||||||
@ -7,7 +7,7 @@ import markdownDefList from 'markdown-it-deflist';
|
|||||||
import markdownItFootnote from 'markdown-it-footnote';
|
import markdownItFootnote from 'markdown-it-footnote';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { renderPermalink } from './components/anchors';
|
import {renderPermalink} from './components/anchors';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns Markdown engine with custom configuration and plugins.
|
* Returns Markdown engine with custom configuration and plugins.
|
||||||
@ -27,7 +27,7 @@ export const markdownEngine = markdown({
|
|||||||
.use(markdownAnchor, {
|
.use(markdownAnchor, {
|
||||||
level: 2,
|
level: 2,
|
||||||
permalink: renderPermalink,
|
permalink: renderPermalink,
|
||||||
slugify: (s) => slugify(s),
|
slugify: s => slugify(s),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import * as cheerio from 'cheerio';
|
import * as cheerio from 'cheerio';
|
||||||
import stripIndent from 'strip-indent';
|
import stripIndent from 'strip-indent';
|
||||||
|
|
||||||
import { codeBlock } from './components';
|
import {codeBlock} from './components';
|
||||||
import { liquidEngine } from './engines';
|
import {liquidEngine} from './engines';
|
||||||
|
|
||||||
const links: Record<string, string> = {
|
const links: Record<string, string> = {
|
||||||
number: '/documentation/values/numbers',
|
number: '/documentation/values/numbers',
|
||||||
@ -21,7 +21,7 @@ const links: Record<string, string> = {
|
|||||||
const returnTypeLink = (returnType: string) =>
|
const returnTypeLink = (returnType: string) =>
|
||||||
returnType
|
returnType
|
||||||
.split('|')
|
.split('|')
|
||||||
.map((type) => {
|
.map(type => {
|
||||||
type = type.trim();
|
type = type.trim();
|
||||||
const link = links[type];
|
const link = links[type];
|
||||||
if (!link) {
|
if (!link) {
|
||||||
@ -49,7 +49,7 @@ export function _function(content: string, ...signatures: string[]) {
|
|||||||
|
|
||||||
// Highlight each signature
|
// Highlight each signature
|
||||||
const names: string[] = [];
|
const names: string[] = [];
|
||||||
const highlightedSignatures = signatures.map((signature) => {
|
const highlightedSignatures = signatures.map(signature => {
|
||||||
signature = stripIndent(signature).trim();
|
signature = stripIndent(signature).trim();
|
||||||
const [name] = signature.split('(', 2);
|
const [name] = signature.split('(', 2);
|
||||||
const nameWithoutNamespace = name.split('.').at(-1) || name;
|
const nameWithoutNamespace = name.split('.').at(-1) || name;
|
||||||
@ -63,7 +63,7 @@ export function _function(content: string, ...signatures: string[]) {
|
|||||||
names.push(nameWithoutNamespace);
|
names.push(nameWithoutNamespace);
|
||||||
const nameEl = signatureElements
|
const nameEl = signatureElements
|
||||||
.filter((index, element) => {
|
.filter((index, element) => {
|
||||||
return $(element).text() == nameWithoutNamespace;
|
return $(element).text() === nameWithoutNamespace;
|
||||||
})
|
})
|
||||||
.eq(0);
|
.eq(0);
|
||||||
nameEl.addClass('docSearch-function');
|
nameEl.addClass('docSearch-function');
|
||||||
@ -71,7 +71,7 @@ export function _function(content: string, ...signatures: string[]) {
|
|||||||
}
|
}
|
||||||
return signatureElements
|
return signatureElements
|
||||||
.toArray()
|
.toArray()
|
||||||
.map((el) => $.html(el))
|
.map(el => $.html(el))
|
||||||
.join('')
|
.join('')
|
||||||
.trim();
|
.trim();
|
||||||
});
|
});
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { LoremIpsum } from 'lorem-ipsum';
|
import {LoremIpsum} from 'lorem-ipsum';
|
||||||
import stripIndent from 'strip-indent';
|
import stripIndent from 'strip-indent';
|
||||||
import truncate from 'truncate-html';
|
import truncate from 'truncate-html';
|
||||||
import { typogrify } from 'typogr';
|
import {typogrify} from 'typogr';
|
||||||
|
|
||||||
import { markdownEngine } from './engines';
|
import {markdownEngine} from './engines';
|
||||||
|
|
||||||
const lorem = new LoremIpsum();
|
const lorem = new LoremIpsum();
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ export const getLorem = (type: string, number = 1) => {
|
|||||||
* @see https://github.com/oe/truncate-html
|
* @see https://github.com/oe/truncate-html
|
||||||
*/
|
*/
|
||||||
export const truncateHTML = (html: string, words = 170) =>
|
export const truncateHTML = (html: string, words = 170) =>
|
||||||
truncate(html, words, { byWords: true, keepWhitespaces: true });
|
truncate(html, words, {byWords: true, keepWhitespaces: true});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders block of Markdown into HTML.
|
* Renders block of Markdown into HTML.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const { DefaultTheme, DefaultThemeRenderContext, JSX } = require('typedoc');
|
// eslint-disable-next-line node/no-missing-require
|
||||||
|
const {DefaultTheme, DefaultThemeRenderContext, JSX} = require('typedoc');
|
||||||
|
|
||||||
function bind(fn, first) {
|
function bind(fn, first) {
|
||||||
return (...r) => fn(first, ...r);
|
return (...r) => fn(first, ...r);
|
||||||
@ -11,7 +12,7 @@ function bind(fn, first) {
|
|||||||
function parseCompatibility(input) {
|
function parseCompatibility(input) {
|
||||||
return input
|
return input
|
||||||
.split(',')
|
.split(',')
|
||||||
.map((arg) => `'${arg.trim()}'`)
|
.map(arg => `'${arg.trim()}'`)
|
||||||
.join(', ');
|
.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,16 +22,16 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
|||||||
// doesn't work. Instead, we emit each overload as a separate entry with its
|
// doesn't work. Instead, we emit each overload as a separate entry with its
|
||||||
// own panel.
|
// own panel.
|
||||||
oldMember = this.member;
|
oldMember = this.member;
|
||||||
member = bind(function (context, props) {
|
member = bind((context, props) => {
|
||||||
const signatures = props?.signatures;
|
const signatures = props?.signatures;
|
||||||
if (signatures && signatures.length > 1) {
|
if (signatures && signatures.length > 1) {
|
||||||
const element = JSX.createElement(
|
const element = JSX.createElement(
|
||||||
JSX.Fragment,
|
JSX.Fragment,
|
||||||
null,
|
null,
|
||||||
...signatures.map((signature) => {
|
...signatures.map(signature => {
|
||||||
props.signatures = [signature];
|
props.signatures = [signature];
|
||||||
return context.oldMember(props);
|
return context.oldMember(props);
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
props.signatures = signatures;
|
props.signatures = signatures;
|
||||||
return element;
|
return element;
|
||||||
@ -44,7 +45,7 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
|||||||
comment = bind((context, props) => {
|
comment = bind((context, props) => {
|
||||||
if (!props.comment) return;
|
if (!props.comment) return;
|
||||||
const compatibilityTags = props.comment.blockTags.filter(
|
const compatibilityTags = props.comment.blockTags.filter(
|
||||||
(tag) => tag.tag === '@compatibility',
|
tag => tag.tag === '@compatibility'
|
||||||
);
|
);
|
||||||
props.comment.removeTags('@compatibility');
|
props.comment.removeTags('@compatibility');
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
|||||||
if (!parent) return;
|
if (!parent) return;
|
||||||
|
|
||||||
parent.children.unshift(
|
parent.children.unshift(
|
||||||
...compatibilityTags.map((compat) => {
|
...compatibilityTags.map(compat => {
|
||||||
// Compatibility tags should have a single text block.
|
// Compatibility tags should have a single text block.
|
||||||
const text = compat.content[0].text;
|
const text = compat.content[0].text;
|
||||||
|
|
||||||
@ -60,13 +61,13 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
|||||||
// after that is the contents of the block.
|
// after that is the contents of the block.
|
||||||
const lineBreak = text.indexOf('\n');
|
const lineBreak = text.indexOf('\n');
|
||||||
const compatibilityArgs = parseCompatibility(
|
const compatibilityArgs = parseCompatibility(
|
||||||
lineBreak === -1 ? text : text.substring(0, lineBreak),
|
lineBreak === -1 ? text : text.substring(0, lineBreak)
|
||||||
);
|
);
|
||||||
const restOfFirst =
|
const restOfFirst =
|
||||||
lineBreak === -1 ? null : text.substring(lineBreak + 1);
|
lineBreak === -1 ? null : text.substring(lineBreak + 1);
|
||||||
|
|
||||||
const rest = [
|
const rest = [
|
||||||
...(restOfFirst ? [{ kind: 'text', text: restOfFirst }] : []),
|
...(restOfFirst ? [{kind: 'text', text: restOfFirst}] : []),
|
||||||
...compat.content.slice(1),
|
...compat.content.slice(1),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
|||||||
(rest ? context.markdown(rest) : '') +
|
(rest ? context.markdown(rest) : '') +
|
||||||
'{% endcompatibility %}',
|
'{% endcompatibility %}',
|
||||||
});
|
});
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
@ -91,25 +92,25 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
|||||||
.oldMarkdown(text)
|
.oldMarkdown(text)
|
||||||
.replace(
|
.replace(
|
||||||
/<p><strong>Heads up!<\/strong>([^]*?)<\/p>/g,
|
/<p><strong>Heads up!<\/strong>([^]*?)<\/p>/g,
|
||||||
'{% headsUp %}$1{% endheadsUp %}',
|
'{% headsUp %}$1{% endheadsUp %}'
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
/<p><strong>Fun fact!<\/strong>([^]*?)<\/p>/g,
|
/<p><strong>Fun fact!<\/strong>([^]*?)<\/p>/g,
|
||||||
'{% funFact %}$1{% endfunFact %}',
|
'{% funFact %}$1{% endfunFact %}'
|
||||||
),
|
),
|
||||||
this,
|
this
|
||||||
);
|
);
|
||||||
|
|
||||||
// Relative URLs don't work well for index pages since they can be rendered at
|
// Relative URLs don't work well for index pages since they can be rendered at
|
||||||
// different directory levels, so we just convert all URLs to absolute to be
|
// different directory levels, so we just convert all URLs to absolute to be
|
||||||
// safe.
|
// safe.
|
||||||
oldUrlTo = this.urlTo;
|
oldUrlTo = this.urlTo;
|
||||||
urlTo = bind(function (context, reflection) {
|
urlTo = bind((context, reflection) => {
|
||||||
const relative = context.oldUrlTo(reflection);
|
const relative = context.oldUrlTo(reflection);
|
||||||
|
|
||||||
const absolute = new URL(
|
const absolute = new URL(
|
||||||
relative,
|
relative,
|
||||||
`relative:///documentation/js-api/${context.theme.markedPlugin.location}`,
|
`relative:///documentation/js-api/${context.theme.markedPlugin.location}`
|
||||||
);
|
);
|
||||||
absolute.pathname = absolute.pathname
|
absolute.pathname = absolute.pathname
|
||||||
.replace(/\.html$/, '')
|
.replace(/\.html$/, '')
|
||||||
@ -123,7 +124,7 @@ class SassSiteTheme extends DefaultTheme {
|
|||||||
this.contextCache ??= new SassSiteRenderContext(
|
this.contextCache ??= new SassSiteRenderContext(
|
||||||
this,
|
this,
|
||||||
page,
|
page,
|
||||||
this.application.options,
|
this.application.options
|
||||||
);
|
);
|
||||||
return this.contextCache;
|
return this.contextCache;
|
||||||
}
|
}
|
||||||
@ -135,7 +136,7 @@ class SassSiteTheme extends DefaultTheme {
|
|||||||
// render title on its own.
|
// render title on its own.
|
||||||
const breadcrumb = page.model.parent
|
const breadcrumb = page.model.parent
|
||||||
? `<ul class="tsd-breadcrumb">${JSX.renderElement(
|
? `<ul class="tsd-breadcrumb">${JSX.renderElement(
|
||||||
context.breadcrumb(page.model),
|
context.breadcrumb(page.model)
|
||||||
)}</ul>`
|
)}</ul>`
|
||||||
: '';
|
: '';
|
||||||
const heading =
|
const heading =
|
||||||
@ -145,7 +146,7 @@ class SassSiteTheme extends DefaultTheme {
|
|||||||
page.model.name +
|
page.model.name +
|
||||||
(page.model.typeParameters
|
(page.model.typeParameters
|
||||||
? `<${page.model.typeParameters
|
? `<${page.model.typeParameters
|
||||||
.map((item) => item.name)
|
.map(item => item.name)
|
||||||
.join(', ')}>`
|
.join(', ')}>`
|
||||||
: '');
|
: '');
|
||||||
|
|
||||||
@ -182,7 +183,7 @@ title: ${JSON.stringify(`${page.model.name} | JS API`)}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.load = (app) => {
|
exports.load = app => {
|
||||||
app.converter.addUnknownSymbolResolver((ref, refl, part, symbolId) => {
|
app.converter.addUnknownSymbolResolver((ref, refl, part, symbolId) => {
|
||||||
if (!symbolId) return;
|
if (!symbolId) return;
|
||||||
const name = symbolId.qualifiedName;
|
const name = symbolId.qualifiedName;
|
||||||
|
Loading…
Reference in New Issue
Block a user