doc: update site anchor
parent
9bb6e79db0
commit
bd05fda435
|
@ -42,7 +42,7 @@
|
||||||
<a-anchor-link
|
<a-anchor-link
|
||||||
v-for="h in headers"
|
v-for="h in headers"
|
||||||
:key="h.title"
|
:key="h.title"
|
||||||
:href="h.href || `#${h.title.replace(/^(\d)/, '_$1')}`"
|
:href="h.href || `#${slugifyTitle(h.title)}`"
|
||||||
:title="h.title"
|
:title="h.title"
|
||||||
></a-anchor-link>
|
></a-anchor-link>
|
||||||
</a-anchor>
|
</a-anchor>
|
||||||
|
@ -88,6 +88,9 @@ import RightBottomAd from '../components/rice/right_bottom_rice.vue';
|
||||||
import { CloseOutlined, MenuOutlined } from '@ant-design/icons-vue';
|
import { CloseOutlined, MenuOutlined } from '@ant-design/icons-vue';
|
||||||
import ThemeIcon from './ThemeIcon.vue';
|
import ThemeIcon from './ThemeIcon.vue';
|
||||||
|
|
||||||
|
const rControl = /[\u0000-\u001f]/g;
|
||||||
|
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g;
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Layout',
|
name: 'Layout',
|
||||||
components: {
|
components: {
|
||||||
|
@ -162,6 +165,21 @@ export default defineComponent({
|
||||||
visible.value = !visible.value;
|
visible.value = !visible.value;
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
|
slugifyTitle: (str: string) => {
|
||||||
|
return (
|
||||||
|
str
|
||||||
|
// Remove control characters
|
||||||
|
.replace(rControl, '')
|
||||||
|
// Replace special characters
|
||||||
|
.replace(rSpecial, '-')
|
||||||
|
// Remove continuos separators
|
||||||
|
.replace(/\-{2,}/g, '-')
|
||||||
|
// Remove prefixing and trailing separtors
|
||||||
|
.replace(/^\-+|\-+$/g, '')
|
||||||
|
// ensure it doesn't start with a number (#121)
|
||||||
|
.replace(/^(\d)/, '_$1')
|
||||||
|
);
|
||||||
|
},
|
||||||
themeMode,
|
themeMode,
|
||||||
visible,
|
visible,
|
||||||
isMobile: globalConfig.isMobile,
|
isMobile: globalConfig.isMobile,
|
||||||
|
|
Loading…
Reference in New Issue