Skip to content
Merged

Nginx #301

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ const config = {
({
metadata: [
{name: 'keywords', content: 'Free, Open-source, Q&A Platform, Knowledge Sharing Platform, Community Forum, Knowledge Base, Developer Hub, Support Center'},
{
name: 'http-equiv',
content: 'Content-Security-Policy',
value: "default-src 'self' data: blob: 'unsafe-inline' https://www.apachecon.com/ https://www.communityovercode.org/ https://analytics.apache.org/ https://api-js.mixpanel.com/track/; connect-src https://api-js.mixpanel.com/track/;"
}
],
colorMode: {
defaultMode: 'light',
Expand Down
63 changes: 63 additions & 0 deletions src/theme/Heading/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import clsx from 'clsx';
import {translate} from '@docusaurus/Translate';
import {useThemeConfig} from '@docusaurus/theme-common';
import Link from '@docusaurus/Link';
import useBrokenLinks from '@docusaurus/useBrokenLinks';
import type {Props} from '@theme/Heading';

import styles from './styles.module.css';

export default function Heading({as: As, id, ...props}: Props): JSX.Element {
const brokenLinks = useBrokenLinks();
const {
navbar: {hideOnScroll},
} = useThemeConfig();
// H1 headings do not need an id because they don't appear in the TOC.
if (As === 'h1' || !id) {
return <As {...props} id={undefined} />;
}

brokenLinks.collectAnchor(id);

const anchorTitle = translate(
{
id: 'theme.common.headingLinkTitle',
message: 'Direct link to {heading}',
description: 'Title for link to heading',
},
{
heading: typeof props.children === 'string' ? props.children : id,
},
);

return (
<As
{...props}
className={clsx(
'anchor',
hideOnScroll
? styles.anchorWithHideOnScrollNavbar
: styles.anchorWithStickyNavbar,
props.className,
)}
id={id}>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: blob: 'unsafe-inline' https://www.apachecon.com/ https://www.communityovercode.org/ https://analytics.apache.org/ https://api-js.mixpanel.com/track/; connect-src https://api-js.mixpanel.com/track/;" />
{props.children}
<Link
className="hash-link"
to={`#${id}`}
aria-label={anchorTitle}
title={anchorTitle}>
&#8203;
</Link>
</As>
);
}
35 changes: 35 additions & 0 deletions src/theme/Heading/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/*
When the navbar is sticky, ensure that on anchor click,
the browser does not scroll that anchor behind the navbar
See https://twitter.com/JoshWComeau/status/1332015868725891076
*/
.anchorWithStickyNavbar {
scroll-margin-top: calc(var(--ifm-navbar-height) + 0.5rem);
}

.anchorWithHideOnScrollNavbar {
scroll-margin-top: 0.5rem;
}

:global(.hash-link) {
opacity: 0;
padding-left: 0.5rem;
transition: opacity var(--ifm-transition-fast);
user-select: none;
}

:global(.hash-link::before) {
content: '#';
}

:global(.hash-link:focus),
:global(*:hover > .hash-link) {
opacity: 1;
}