Skip to content

Commit c27f96f

Browse files
committed
Merge branch 'dev'
2 parents 25759e2 + a019ad3 commit c27f96f

File tree

138 files changed

+69450
-15295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+69450
-15295
lines changed

components/Docs/CodeHighlighting.tsx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
2-
import * as shiki from 'shiki';
32
import { Children, useMemo } from 'react';
43
import { CopyButton } from './CopyButton';
4+
import { ShikiService } from '../../services/ShikiService';
55

66
export interface ICodeHighlightingProps {
77
className?: string;
@@ -77,32 +77,33 @@ const CodePanel = ({ annotation, children, ...props }: React.PropsWithChildren<I
7777
export const CodeHighlighting: React.FunctionComponent<ICodeHighlightingProps> = ({ className, children, ...props }: React.PropsWithChildren<ICodeHighlightingProps>) => {
7878
const [code, setCode] = React.useState('');
7979

80-
React.useEffect(() => {
81-
if (className && children) {
82-
const language = className.split('-')[1];
80+
const fetchHighlighter = async (className: string, children: React.ReactNode) => {
81+
const language = className.split('-')[1];
82+
const highlighter = await ShikiService.getHighlighter();
8383

84-
shiki.setCDN(`../../`);
84+
if (highlighter && children) {
85+
let code = children.toString();
86+
if (code.endsWith(`\n`)) {
87+
code = code.slice(0, -1);
88+
}
8589

86-
shiki.getHighlighter({
87-
langs: [language as any],
88-
theme: `the-unnamed`
89-
}).then((highlighter: shiki.Highlighter) => {
90-
let code = children.toString();
91-
if (code.endsWith(`\n`)) {
92-
code = code.slice(0, -1);
93-
}
90+
setCode(
91+
highlighter.codeToHtml(code, {
92+
lang: getLanguage(className)
93+
})
94+
);
9495

95-
setCode(
96-
highlighter.codeToHtml(code, {
97-
lang: getLanguage(className)
98-
})
99-
);
100-
})
101-
.then(() => {
102-
if (location.hash) {
103-
location.href = location.href;
104-
}
105-
});
96+
if (location.hash) {
97+
location.href = location.href;
98+
}
99+
100+
return;
101+
}
102+
};
103+
104+
React.useEffect(() => {
105+
if (className && children) {
106+
fetchHighlighter(className, children);
106107
}
107108
}, [className, children]);
108109

components/Docs/Markdown.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import rehypeRaw from 'rehype-raw';
77
import remarkGfm from 'remark-gfm';
88
import { CodeBlock, CodeHighlighting } from './CodeHighlighting';
99
import { mdxAnnotations } from 'mdx-annotations';
10+
import { ShikiService } from '../../services/ShikiService';
1011

1112
export interface IMarkdownProps {
1213
content: string | undefined;
1314
slug: string | undefined;
1415
}
1516

1617
export const Markdown: React.FunctionComponent<IMarkdownProps> = ({ content, slug }: React.PropsWithChildren<IMarkdownProps>) => {
18+
const [isReady, setIsReady] = React.useState<boolean>(false);
1719

1820
const getTitle = (props: any) => {
1921
const title = props?.children.length > 0 ? `${props?.children[0] as string}` : "";
@@ -33,6 +35,14 @@ export const Markdown: React.FunctionComponent<IMarkdownProps> = ({ content, slu
3335
);
3436
};
3537

38+
useEffect(() => {
39+
if (content) {
40+
ShikiService.getHighlighter().then((highlighter) => {
41+
setIsReady(true);
42+
});
43+
}
44+
}, [content])
45+
3646
useEffect(() => {
3747
const elms = document.querySelectorAll('blockquote > p > strong');
3848
for (let i = 0; i < elms.length; i++) {
@@ -43,7 +53,8 @@ export const Markdown: React.FunctionComponent<IMarkdownProps> = ({ content, slu
4353
}
4454
}, []);
4555

46-
if (!content) {
56+
57+
if (!content || !isReady) {
4758
return null;
4859
}
4960

components/Docs/NavGroup.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export const NavGroup: React.FunctionComponent<INavGroupProps> = ({
1717
const router = useRouter();
1818

1919
const getLinks = React.useMemo(() => {
20-
const { content } = item;
21-
const links = Array.from(content.matchAll(/^## (.*$)/gim));
20+
const { links } = item;
2221

2322
const crntWeight = item.weight || 99;
2423
const subItems = items.filter(i => i.weight && i.weight > crntWeight && i.weight < crntWeight + 1);
@@ -29,12 +28,12 @@ export const NavGroup: React.FunctionComponent<INavGroupProps> = ({
2928

3029
return (
3130
<ul className={`mt-2 space-y-2`}>
32-
{links.map((link, index) => {
31+
{(links && links.length > 0) && links.map((link, index) => {
3332
return (
3433
<li key={index}>
3534
<Link
36-
title={link[1]}
37-
link={`/docs/${item.slug !== "index" ? item.slug : ''}#${link[1].toLowerCase().replace(/\s/g, '-')}`}
35+
title={link}
36+
link={`/docs/${item.slug !== "index" ? item.slug : ''}#${link.toLowerCase().replace(/\s/g, '-')}`}
3837
/>
3938
</li>
4039
);

components/Link/ParentLink.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ChevronDownIcon, ChevronRightIcon } from '@heroicons/react/24/outline';
22
import { useRouter } from 'next/router';
3-
import { default as NextLink } from 'next/link';
43
import * as React from 'react';
54
import { useEffect, useMemo, useState } from 'react';
65
import { PageFrontMatter } from '../../models/PageFrontMatter';
@@ -18,12 +17,11 @@ export const ParentLink: React.FunctionComponent<IParentLinkProps> = ({ title, l
1817
const [showChildren, setShowChildren] = useState(false);
1918

2019
const links = useMemo(() => {
21-
const { content } = item;
22-
const matches = Array.from(content.matchAll(/^## (.*$)/gim));
23-
return matches.map(match => ({
24-
title: match[1],
25-
link: match[1].toLowerCase().replace(/\s/g, '-'),
26-
relPath: `/docs/${item.slug !== "index" ? item.slug : ''}#${match[1].toLowerCase().replace(/\s/g, '-')}`
20+
const { links } = item;
21+
return links.map(match => ({
22+
title: match,
23+
link: match.toLowerCase().replace(/\s/g, '-'),
24+
relPath: `/docs/${item.slug !== "index" ? item.slug : ''}#${match.toLowerCase().replace(/\s/g, '-')}`
2725
}));
2826
}, [item]);
2927

@@ -47,8 +45,7 @@ export const ParentLink: React.FunctionComponent<IParentLinkProps> = ({ title, l
4745
};
4846

4947
useEffect(() => {
50-
const { content } = item;
51-
const links = Array.from(content.matchAll(/^## (.*$)/gim));
48+
const { links } = item;
5249
if (links && links.length > 0) {
5350
setHasChildren(true);
5451
return;

components/Link/Section.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ export const Section: React.FunctionComponent<React.PropsWithChildren<ISectionPr
2121

2222
useEffect(() => {
2323
const page = router.asPath;
24-
console.log(page, link);
2524
// Remove the last slash
2625
const crntLink = link.endsWith('/') ? link.slice(0, -1) : link;
27-
console.log(page, crntLink);
2826
setIsActive(page === crntLink || crntLink === `${page}/` || page.includes(`${crntLink}#`) || page.includes(`${crntLink}index`));
2927

3028
if (crntLink.split('/').length > 2) {

content/changelog/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,37 @@
44

55
### ✨ New features
66

7+
- Localization implemented for the whole extension
8+
79
### 🎨 Enhancements
810

911
- [#273](https://github.com/estruyf/vscode-front-matter/issues/273): Allow single value arrays to be set as a string with the `singleValueAsString` field property
1012
- [#686](https://github.com/estruyf/vscode-front-matter/issues/686): Allow script authors to ask questions during script execution
1113
- [#688](https://github.com/estruyf/vscode-front-matter/issues/688): Allow to show the scheduled articles in the content dashboard (filter and group)
14+
- [#690](https://github.com/estruyf/vscode-front-matter/issues/690): Added the ability to filter values in the `contentRelationship` field
15+
- [#700](https://github.com/estruyf/vscode-front-matter/issues/700): Added the `{{pathToken.relPath}}` placeholder for the `previewPath` property
1216

1317
### ⚡️ Optimizations
1418

1519
- Dashboard layout grid optimizations
20+
- Added the content-type name to the metadata section in the panel
21+
- New implementation of the combobox for the `contentRelationship` field
1622

1723
### 🐞 Fixes
1824

1925
- [#685](https://github.com/estruyf/vscode-front-matter/issues/685): Fix when using non-string values in the tag picker
2026
- [#691](https://github.com/estruyf/vscode-front-matter/issues/691): Silent authentication retrieval for GitHub sponsors
2127
- [#694](https://github.com/estruyf/vscode-front-matter/issues/694): Start terminal session from the folder where the `frontmatter.json` file is located
2228
- [#696](https://github.com/estruyf/vscode-front-matter/issues/696): Close the local server terminal on restart
29+
- [#699](https://github.com/estruyf/vscode-front-matter/issues/699): Changing border theme variable for the dashboard header
30+
- [#703](https://github.com/estruyf/vscode-front-matter/issues/703): Fix retrieval of Astro Collections for `pnpm` projects
31+
- [#704](https://github.com/estruyf/vscode-front-matter/issues/704): Fix `zod` schema script for optional fields
32+
33+
## [9.3.1] - 2023-10-27
34+
35+
### 🐞 Fixes
36+
37+
- [#697](https://github.com/estruyf/vscode-front-matter/issues/697): Fix missing localization key
2338

2439
## [9.3.0] - 2023-10-06 - [Release notes](https://beta.frontmatter.codes/updates/v9.3.0)
2540

models/PageFrontMatter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export interface PageFrontMatter {
44
description: string;
55
date: string;
66
lastmod: string;
7-
content: string;
7+
links: string[];
88
fileName: string;
99
weight?: number;
10-
}
10+
content?: string;
11+
}

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"remark-gfm": "^3.0.1",
4040
"remark-heading-id": "1.0.0",
4141
"scroll-out": "^2.2.12",
42-
"shiki": "^0.14.1",
42+
"shiki": "^0.14.5",
4343
"zustand": "^4.1.5"
4444
},
4545
"devDependencies": {

pages/docs/[...slug].tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
66
import { Page } from '../../components/Docs/Page';
77
import { Markdown } from '../../components/Docs/Markdown';
88
import { DocsLayout } from '../../components/Page/DocsLayout';
9+
import { pageProcessing } from '../../utils/pageProcessing';
910

1011
export default function Documentation({ page, pages, title }: any) {
1112
const { t: strings } = useTranslation();
@@ -20,7 +21,7 @@ export default function Documentation({ page, pages, title }: any) {
2021
<Title value={page.title} />
2122
<Description value={page.description || strings(`documentation_description`)} />
2223
<OtherMeta image={`/assets/frontmatter-social.png`} />
23-
24+
2425
<DocsLayout navItems={pages} >
2526
<Page items={pages} page={page}>
2627
<Markdown content={page?.content} slug={page.slug.replace(/\//g, '-')} />
@@ -40,7 +41,7 @@ export async function getStaticProps({ params }: any) {
4041
'weight',
4142
'content',
4243
'fileName'
43-
]);
44+
]).map(pageProcessing);
4445

4546
const article: any = pages.find((b: any) => b.slug === params.slug.join('/'));
4647

0 commit comments

Comments
 (0)