Compare commits

..

9 Commits

Author SHA1 Message Date
Ola Rubaj
573f938dfe [.changeset][xs]: add changeset file 2023-08-14 15:22:29 +02:00
Ola Rubaj
961a219f61 [remark-wiki-link][m]: parse note embeds as regular wiki links
- temporary solution before we have a proper note embed support
2023-08-11 18:07:02 +02:00
João Demenech
df395e2b70 [site,#957,seo][s]: fix build issue 2023-08-10 11:01:10 -03:00
João Demenech
ea5dade346 [site,#957,seo][s]: improves descriptions for pages 2023-08-10 10:52:23 -03:00
João Demenech
8027026399 [site,#957][s]: improves mobile reponsiveness 2023-08-10 10:35:34 -03:00
João Demenech
af7812f689 Merge pull request #1004 from datopian/custom-404
[site]: Custom 404 page + JSON-LD breadcrumbs
2023-08-09 18:01:04 -03:00
João Demenech
6a36e65b27 [site,seo][m]: add breadcrumbs json-ld to dynamic pages 2023-08-09 17:53:59 -03:00
João Demenech
38aa62fcef [404,seo][xs]: custom 404 page with noindex,nofollow meta tag 2023-08-09 16:57:01 -03:00
Ola Rubaj
ed9b575b4e Core package storybook setup (#1003)
* [/][m]: add storybook to core package

* [/][s]: replace nx with nrwl packages for storybook

* [core][xs]: mv tsconfig.storybook.json to .storybook/tsconfig.json

* [/][s]: configure storybook with tailwind

* [core/tailwind.config.js][xs]: add basic Flowershow tailwind config

* [core][xs]: add example story

* [core][s]: darkmode storybook addon
2023-08-09 14:14:06 -03:00
20 changed files with 158 additions and 57 deletions

View 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).

View File

@@ -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 = {

View File

@@ -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(

View File

@@ -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>'
);
});
});
});

View File

@@ -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");
});
});
});
});

View File

@@ -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>
);

View File

@@ -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">

View File

@@ -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>

View File

@@ -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"

View File

@@ -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.

View File

@@ -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 its done, youll 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

View File

@@ -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!

View File

@@ -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.

View File

@@ -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.

View File

@@ -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

View File

@@ -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
}
```

View File

@@ -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]

View File

@@ -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
View 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>
</>
);
}

View File

@@ -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}