Compare commits
9 Commits
core-story
...
1005-note-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
573f938dfe | ||
|
|
961a219f61 | ||
|
|
df395e2b70 | ||
|
|
ea5dade346 | ||
|
|
8027026399 | ||
|
|
af7812f689 | ||
|
|
6a36e65b27 | ||
|
|
38aa62fcef | ||
|
|
ed9b575b4e |
5
.changeset/thick-worms-peel.md
Normal file
5
.changeset/thick-worms-peel.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@portaljs/remark-wiki-link': minor
|
||||
---
|
||||
|
||||
Parse note embeds as regular wiki links (until we add proper support for note embeds).
|
||||
@@ -15,9 +15,9 @@ const defaultWikiLinkResolver = (target: string) => {
|
||||
|
||||
export interface FromMarkdownOptions {
|
||||
pathFormat?:
|
||||
| "raw" // default; use for regular relative or absolute paths
|
||||
| "obsidian-absolute" // use for Obsidian-style absolute paths (with no leading slash)
|
||||
| "obsidian-short"; // use for Obsidian-style shortened paths (shortest path possible)
|
||||
| "raw" // default; use for regular relative or absolute paths
|
||||
| "obsidian-absolute" // use for Obsidian-style absolute paths (with no leading slash)
|
||||
| "obsidian-short"; // use for Obsidian-style shortened paths (shortest path possible)
|
||||
permalinks?: string[]; // list of permalinks to match possible permalinks of a wiki link against
|
||||
wikiLinkResolver?: (name: string) => string[]; // function to resolve wiki links to an array of possible permalinks
|
||||
newClassName?: string; // class name to add to links that don't have a matching permalink
|
||||
@@ -125,13 +125,24 @@ function fromMarkdown(opts: FromMarkdownOptions = {}) {
|
||||
if (isEmbed) {
|
||||
const [isSupportedFormat, format] = isSupportedFileFormat(target);
|
||||
if (!isSupportedFormat) {
|
||||
wikiLink.data.hName = "p";
|
||||
wikiLink.data.hChildren = [
|
||||
{
|
||||
type: "text",
|
||||
value: `![[${target}]]`,
|
||||
},
|
||||
];
|
||||
// Temporarily render note transclusion as a regular wiki link
|
||||
if (!format) {
|
||||
wikiLink.data.hName = "a";
|
||||
wikiLink.data.hProperties = {
|
||||
className: classNames + " " + "transclusion",
|
||||
href: hrefTemplate(link) + headingId,
|
||||
};
|
||||
wikiLink.data.hChildren = [{ type: "text", value: displayName }];
|
||||
|
||||
} else {
|
||||
wikiLink.data.hName = "p";
|
||||
wikiLink.data.hChildren = [
|
||||
{
|
||||
type: "text",
|
||||
value: `![[${target}]]`,
|
||||
},
|
||||
];
|
||||
}
|
||||
} else if (format === "pdf") {
|
||||
wikiLink.data.hName = "iframe";
|
||||
wikiLink.data.hProperties = {
|
||||
|
||||
@@ -15,9 +15,9 @@ const defaultWikiLinkResolver = (target: string) => {
|
||||
|
||||
export interface HtmlOptions {
|
||||
pathFormat?:
|
||||
| "raw" // default; use for regular relative or absolute paths
|
||||
| "obsidian-absolute" // use for Obsidian-style absolute paths (with no leading slash)
|
||||
| "obsidian-short"; // use for Obsidian-style shortened paths (shortest path possible)
|
||||
| "raw" // default; use for regular relative or absolute paths
|
||||
| "obsidian-absolute" // use for Obsidian-style absolute paths (with no leading slash)
|
||||
| "obsidian-short"; // use for Obsidian-style shortened paths (shortest path possible)
|
||||
permalinks?: string[]; // list of permalinks to match possible permalinks of a wiki link against
|
||||
wikiLinkResolver?: (name: string) => string[]; // function to resolve wiki links to an array of possible permalinks
|
||||
newClassName?: string; // class name to add to links that don't have a matching permalink
|
||||
@@ -108,7 +108,16 @@ function html(opts: HtmlOptions = {}) {
|
||||
if (isEmbed) {
|
||||
const [isSupportedFormat, format] = isSupportedFileFormat(target);
|
||||
if (!isSupportedFormat) {
|
||||
this.raw(`![[${target}]]`);
|
||||
// Temporarily render note transclusion as a regular wiki link
|
||||
if (!format) {
|
||||
this.tag(
|
||||
`<a href="${hrefTemplate(link + headingId)}" class="${classNames} transclusion">`
|
||||
);
|
||||
this.raw(displayName);
|
||||
this.tag("</a>");
|
||||
} else {
|
||||
this.raw(`![[${target}]]`);
|
||||
}
|
||||
} else if (format === "pdf") {
|
||||
this.tag(
|
||||
`<iframe width="100%" src="${hrefTemplate(
|
||||
|
||||
@@ -309,4 +309,16 @@ describe("micromark-extension-wiki-link", () => {
|
||||
expect(serialized).toBe('<p><a href="/" class="internal">/index</a></p>');
|
||||
});
|
||||
});
|
||||
|
||||
describe("transclusions", () => {
|
||||
test("parsers a transclusion as a regular wiki link", () => {
|
||||
const serialized = micromark("![[Some Page]]", "ascii", {
|
||||
extensions: [syntax()],
|
||||
htmlExtensions: [html() as any], // TODO type fix
|
||||
});
|
||||
expect(serialized).toBe(
|
||||
'<p><a href="Some Page" class="internal new transclusion">Some Page</a></p>'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -535,4 +535,28 @@ describe("remark-wiki-link", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("transclusions", () => {
|
||||
test("replaces a transclusion with a regular wiki link", () => {
|
||||
const processor = unified().use(markdown).use(wikiLinkPlugin);
|
||||
|
||||
let ast = processor.parse("![[Some Page]]");
|
||||
ast = processor.runSync(ast);
|
||||
|
||||
expect(select("wikiLink", ast)).not.toEqual(null);
|
||||
|
||||
visit(ast, "wikiLink", (node: Node) => {
|
||||
expect(node.data?.isEmbed).toEqual(true);
|
||||
expect(node.data?.exists).toEqual(false);
|
||||
expect(node.data?.permalink).toEqual("Some Page");
|
||||
expect(node.data?.alias).toEqual(null);
|
||||
expect(node.data?.hName).toEqual("a");
|
||||
expect((node.data?.hProperties as any).className).toEqual(
|
||||
"internal new transclusion"
|
||||
);
|
||||
expect((node.data?.hProperties as any).href).toEqual("Some Page");
|
||||
expect((node.data?.hChildren as any)[0].value).toEqual("Some Page");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ import { useEffect, useState } from 'react';
|
||||
const Stat = ({ title, value, ...props }) => {
|
||||
return (
|
||||
<div {...props}>
|
||||
<span className="text-6xl font-bold text-secondary">{value}</span>
|
||||
<span className="text-4xl sm:text-6xl font-bold text-secondary">{value}</span>
|
||||
<p className="text-lg font-medium">{title}</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -86,7 +86,7 @@ export default function Layout({
|
||||
<>
|
||||
{title && <NextSeo title={title} description={description} />}
|
||||
<Nav />
|
||||
<div className="mx-auto p-6 bg-background dark:bg-background-dark">
|
||||
<div className="mx-auto p-2 sm:p-6 bg-background dark:bg-background-dark">
|
||||
{isHomePage && <Hero />}
|
||||
|
||||
<div className="relative mx-auto flex max-w-8xl justify-center sm:px-2 lg:px-8 xl:px-12">
|
||||
|
||||
@@ -92,7 +92,7 @@ export default function MobileNavigation({ navigation }) {
|
||||
>
|
||||
{/* <Logomark className="h-9 w-9" /> */}
|
||||
<div className="font-extrabold text-slate-900 dark:text-white text-2xl ml-6">
|
||||
{siteConfig.title}
|
||||
PortalJS
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -95,7 +95,10 @@ export default function Nav() {
|
||||
<MobileNavigation navigation={siteConfig.navLinks} />
|
||||
</div>
|
||||
<div className="flex flex-none items-center">
|
||||
<NavbarTitle />
|
||||
<div className="hidden sm:block">
|
||||
<NavbarTitle />
|
||||
</div>
|
||||
|
||||
<div className="hidden lg:flex ml-8 mr-6 sm:mr-8 md:mr-0">
|
||||
{siteConfig.navLinks.map((item) => (
|
||||
<NavItem item={item} key={item.name} />
|
||||
@@ -123,9 +126,8 @@ export default function Nav() {
|
||||
)}
|
||||
{siteConfig.github && (
|
||||
<div className="mt-1">
|
||||
<
|
||||
// @ts-ignore
|
||||
GitHubButton
|
||||
{/* @ts-ignore */}
|
||||
<GitHubButton
|
||||
href={siteConfig.github}
|
||||
data-color-scheme="no-preference: light; light: light; dark: dark;"
|
||||
data-size="large"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: 'Creating new datasets'
|
||||
description: 'PortalJS Tutorial II - Learn how to create new datasets on a data portal'
|
||||
description: 'Learn how to create new datasets and an index for all datasets on a data portal built with PortalJS'
|
||||
---
|
||||
|
||||
So far, the PortalJS app we created only has a single page displaying a dataset. Data catalogs and data portals generally showcase many different datasets.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<NextSeo title="Deploying your PortalJS app - PortalJS" />
|
||||
|
||||
# Deploying your PortalJS app
|
||||
---
|
||||
title: Deploying your PortalJS app
|
||||
description: 'Learn how to deploy PortalJS apps to Vercel and Cloudflare'
|
||||
---
|
||||
|
||||
Finally, let's learn how to deploy PortalJS apps to Vercel or Cloudflare Pages.
|
||||
|
||||
@@ -35,7 +36,7 @@ When you deploy, your PortalJS app will start building. It should finish in unde
|
||||
|
||||
When it’s done, you’ll get deployment URLs. Click on one of the URLs and you should see your PortalJS app live.
|
||||
|
||||
>[!tip]
|
||||
> [!tip]
|
||||
> You can find a more in-depth explanation about this process at https://nextjs.org/learn/basics/deploying-nextjs-app/deploy
|
||||
|
||||
### One-Click Deploy
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Getting Started
|
||||
description: 'Getting started guide and tutorial about data portal-building with PortalJS'
|
||||
description: 'Getting started guide and tutorial about data portal-building with PortalJS!'
|
||||
---
|
||||
|
||||
Welcome to the PortalJS documentation!
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<NextSeo title="Searching datasets - PortalJS" />
|
||||
|
||||
# Searching datasets
|
||||
---
|
||||
title: Searching datasets
|
||||
description: 'Learn how to create a searchable datasets index with facets on a PortalJs data portal'
|
||||
---
|
||||
|
||||
Typing out every link in the index page will get cumbersome eventually, and as the portal grows, finding the datasets you are looking for on the index page will become harder and harder, for that we will need search functionality.
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<NextSeo title="Showing metadata - PortalJS" />
|
||||
|
||||
# Showing metadata
|
||||
---
|
||||
title: Showing metadata
|
||||
description: "Learn how to display metadata on the dataset page of a data portal built with PortalJS"
|
||||
---
|
||||
|
||||
If you go now to `http://localhost:3000/my-awesome-dataset`, you will see that we now have two titles on the page. That's because `title` is one of the default metadata fields supported by PortalJS.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: How to add Google Analytics?
|
||||
description: Learn to implement Google Analytics on PortalJS data portals
|
||||
description: Learn how to implement Google Analytics on PortalJS data portals
|
||||
---
|
||||
|
||||
>[!todo] Prerequisites
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: How to add a simple blog?
|
||||
description: How to add a simple blog on a PortalJS data portal
|
||||
description: Learn how to add a simple blog on a PortalJS data portal
|
||||
---
|
||||
|
||||
## Setup
|
||||
@@ -16,15 +16,15 @@ npm i @portaljs/core
|
||||
Add the following code to the Next.js page that is going to be your blog home page, e.g. to `/pages/blog/index.tsx`:
|
||||
|
||||
```tsx
|
||||
import { BlogsList, SimpleLayout } from "@portaljs/core";
|
||||
import { BlogsList, SimpleLayout } from '@portaljs/core';
|
||||
|
||||
// pass a list of blogs, home page title and home page description, e.g. from `getStaticProps`
|
||||
export default function BlogIndex({ blogs, title, description }) {
|
||||
return (
|
||||
<SimpleLayout title={title} description={description}>
|
||||
<BlogsList blogs={blogs} />
|
||||
</SimpleLayout>
|
||||
);
|
||||
return (
|
||||
<SimpleLayout title={title} description={description}>
|
||||
<BlogsList blogs={blogs} />
|
||||
</SimpleLayout>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -32,16 +32,16 @@ export default function BlogIndex({ blogs, title, description }) {
|
||||
|
||||
```ts
|
||||
interface BlogsListProps {
|
||||
blogs: Blog;
|
||||
blogs: Blog;
|
||||
}
|
||||
|
||||
interface Blog {
|
||||
title: string;
|
||||
date: string;
|
||||
urlPath: string;
|
||||
description?: string;
|
||||
authors?: Array<string>;
|
||||
tags?: Array<string>;
|
||||
title: string;
|
||||
date: string;
|
||||
urlPath: string;
|
||||
description?: string;
|
||||
authors?: Array<string>;
|
||||
tags?: Array<string>;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -57,7 +57,7 @@ export default BlogPost({ content, title, date, authors }) {
|
||||
<BlogLayout title={title} date={date} authors={authors}
|
||||
{content}
|
||||
</BlogLayout>
|
||||
)
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -65,14 +65,14 @@ export default BlogPost({ content, title, date, authors }) {
|
||||
|
||||
```ts
|
||||
interface BlogLayoutProps {
|
||||
title?: string;
|
||||
date?: string;
|
||||
authors?: Array<Author>;
|
||||
title?: string;
|
||||
date?: string;
|
||||
authors?: Array<Author>;
|
||||
}
|
||||
|
||||
interface Author {
|
||||
name: string;
|
||||
avatar: string; // avatar image path
|
||||
urlPath?: string; // author page
|
||||
name: string;
|
||||
avatar: string; // avatar image path
|
||||
urlPath?: string; // author page
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: How to customize page metadata for SEO?
|
||||
description: Learn to customize page metadata for SEO on data portals with PortalJS
|
||||
description: Learn how to customize page metadata for SEO on data portals built with PortalJS
|
||||
---
|
||||
|
||||
>[!info]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: How to build a sitemap?
|
||||
description: Learn how to build a sitemap for a data portal with PortalJS
|
||||
description: Learn how to build a sitemap for a data portal built with PortalJS
|
||||
---
|
||||
|
||||
## Setup
|
||||
|
||||
24
site/pages/404.tsx
Normal file
24
site/pages/404.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import Layout from '@/components/Layout';
|
||||
import { NextSeo } from 'next-seo';
|
||||
import Link from 'next/link';
|
||||
|
||||
export default function () {
|
||||
return (
|
||||
<>
|
||||
<NextSeo noindex={true} nofollow={true} />
|
||||
<Layout>
|
||||
<div className="flex items-center justify-center h-full">
|
||||
<div className="text-center">
|
||||
<h1 className="text-2xl">404 - Page not found</h1>
|
||||
<p className="text-lg mt-5">
|
||||
It seems like you are looking for a page that doesn't exist.
|
||||
</p>
|
||||
<Link className="underline" href="/">
|
||||
Go back to home
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</Layout>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { CustomAppProps } from './_app.jsx';
|
||||
import computeFields from '@/lib/computeFields';
|
||||
import { getAuthorsDetails } from '@/lib/getAuthorsDetails';
|
||||
import JSONLD from '@/components/JSONLD';
|
||||
import { BreadcrumbJsonLd } from 'next-seo';
|
||||
|
||||
export default function Page({ source, meta, sidebarTree }) {
|
||||
source = JSON.parse(source);
|
||||
@@ -29,9 +30,19 @@ export default function Page({ source, meta, sidebarTree }) {
|
||||
setTableOfContents(toc ?? []);
|
||||
}, [router.asPath]); // update table of contents on route change with next/link
|
||||
|
||||
const urlSegments = meta.urlPath.split('/');
|
||||
const breadcrumbs = urlSegments.map((segment, i) => {
|
||||
return {
|
||||
position: i + 1,
|
||||
name: i == urlSegments.length - 1 ? meta.title || segment : segment,
|
||||
item: '/' + urlSegments.slice(0, i + 1).join('/'),
|
||||
};
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<JSONLD meta={meta} source={source.compiledSource} />
|
||||
<BreadcrumbJsonLd itemListElements={breadcrumbs} />
|
||||
<Layout
|
||||
tableOfContents={tableOfContents}
|
||||
title={meta.title}
|
||||
|
||||
Reference in New Issue
Block a user