Compare commits

...

35 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
João Demenech
8327f4efc0 [site,storybook,seo][xs]: fix duplicate user canonical issues -- refs #957 2023-08-07 15:18:12 -03:00
Ola Rubaj
d6a12e3111 Merge pull request #998 from datopian/987-tutorial4-websitey-stuff
Tutorial 4 (overview): Customising your website locally and previewing your changes locally
2023-08-04 14:55:20 +02:00
Ola Rubaj
9fc834c16d Merge pull request #997 from datopian/985-tutorial3-collaboration
Tutorial 3 (overview): Collaborating with others on your website project
2023-08-04 14:53:24 +02:00
Ola Rubaj
1a7371f9c5 [guide/index][m]: tutorial4 overview 2023-07-28 16:33:33 +02:00
Ola Rubaj
c5ae365a20 [site/content/guide][m]: tutorial 3 overview 2023-07-28 15:55:09 +02:00
Ola Rubaj
30f7de04c7 Markdownbased repo content migration + adjustments 2023-07-28 15:40:44 +02:00
João Demenech
989d0987c6 Merge pull request #995 from datopian/site/minor-fixes
Site/minor fixes
2023-07-27 16:28:13 -03:00
João Demenech
e1014025f0 [site,docs][xs]: fix groups facet not working for a dataset on the tutorial -- refs #974 2023-07-27 16:20:37 -03:00
João Demenech
7fc69b7ce8 [site,bug][xs]: fix weird margins on pages -- refs #993 2023-07-27 15:43:14 -03:00
João Demenech
d88a23c922 Merge pull request #991 from datopian/feature/seo-improvements-ii
SEO Improvements (II) - JSON-LD
2023-07-27 13:10:33 -03:00
João Demenech
d367deaea3 [seo,json-ld][m]: implement json-ld (schema markups) 2023-07-26 18:00:12 -03:00
João Demenech
3e9eadcc69 [site,seo][xs]: merge main and fix conflict 2023-07-21 17:58:58 -03:00
Luccas Mateus de Medeiros Gomes
da226ef205 Merge branch 'main' of github.com:datopian/portaljs 2023-07-21 07:43:38 -03:00
Luccas Mateus de Medeiros Gomes
a37a31f89a [lighthouse][xs] - try ga lazyOnload 2023-07-21 07:42:36 -03:00
João Demenech
03c27df800 [site,seo][s]: alt images, description and titles fixes for multiple pages 2023-07-20 18:30:54 -03:00
João Demenech
d198130038 [site,seo][s]: add description metadata to main pages 2023-07-20 18:00:00 -03:00
Luccas Mateus
06209877ea Lighthouse improvements (#990)
* [site][lighthouse] - increate accessibility

* [site][xs] - fix accessbiility
2023-07-20 11:11:07 -03:00
Luccas Mateus
822a3ce5ec [site][lighthouse] - increate accessibility (#989) 2023-07-20 10:17:24 -03:00
João Demenech
1f06c67d13 [site, blog][xs]: Fix order of authors on a post 2023-07-19 16:17:56 -03:00
João Demenech
9dea140859 SEO Improvements (#983)
* [site,seo][xs]: add custom _document with lang prop, add description to meta tags, make title larger

* [site,seo][xs]: add apple touch icon, add alt props to images

* [site,seo][xs]: add icon to default seo

* [site,seo][s]: implement next-sitemap

* [site,seo][s]: review page titles

* Rebuild package-lock.json files

* Regenerate package-lock
2023-07-19 07:23:06 -03:00
João Demenech
d5899b22ab [site,blog][xs]: Fix typo 2023-07-18 15:23:14 -03:00
João Demenech
dc895ed277 Merge pull request #984 from datopian/feature/maps-blog-post
[site]: Create new blog post about maps
2023-07-18 15:19:01 -03:00
João Demenech
7315df8a86 [site,blog][m]: create new blog post about maps 2023-07-18 14:08:33 -03:00
João Demenech
349f5bea66 Merge pull request #982 from datopian/lighthouse-improvements
[site][m] - improvements to lighthouse score
2023-07-17 15:04:25 -03:00
João Demenech
6aef860a81 Merge pull request #981 from datopian/changeset-release/main
Version Packages
2023-07-17 14:51:08 -03:00
github-actions[bot]
1a22e54d5b Version Packages 2023-07-17 17:41:23 +00:00
78 changed files with 15157 additions and 1557 deletions

View File

@@ -1,5 +0,0 @@
---
'@portaljs/components': patch
---
Fix missing CSS styles for PDF component

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

21
nx.json
View File

@@ -5,7 +5,13 @@
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"]
"cacheableOperations": [
"build",
"lint",
"test",
"e2e",
"build-storybook"
]
}
}
},
@@ -30,6 +36,14 @@
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore"
]
},
"build-storybook": {
"inputs": [
"default",
"^production",
"{projectRoot}/.storybook/**/*",
"{projectRoot}/tsconfig.storybook.json"
]
}
},
"namedInputs": {
@@ -39,7 +53,10 @@
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json"
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)",
"!{projectRoot}/.storybook/**/*",
"!{projectRoot}/tsconfig.storybook.json"
],
"sharedGlobals": ["{workspaceRoot}/babel.config.json"]
},

15339
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,8 @@
{
"name": "portaljs",
"workspaces": ["./packages/*"],
"workspaces": [
"./packages/*"
],
"version": "0.0.0",
"license": "MIT",
"scripts": {
@@ -18,10 +20,20 @@
"@nrwl/js": "15.9.2",
"@nrwl/linter": "15.9.2",
"@nrwl/next": "15.9.2",
"@nrwl/react": "15.9.2",
"@nrwl/react": "^15.9.2",
"@nrwl/rollup": "15.9.2",
"@nrwl/storybook": "15.9.2",
"@nrwl/webpack": "15.9.2",
"@nrwl/workspace": "15.9.2",
"@nx/js": "16.6.0",
"@rollup/plugin-url": "^7.0.0",
"@storybook/addon-essentials": "7.0.18",
"@storybook/addon-interactions": "7.0.18",
"@storybook/core-server": "7.0.18",
"@storybook/jest": "~0.1.0",
"@storybook/react-webpack5": "^7.0.18",
"@storybook/test-runner": "^0.11.0",
"@storybook/testing-library": "~0.2.0",
"@svgr/rollup": "^6.1.2",
"@swc/core": "^1.2.173",
"@swc/helpers": "~0.5.0",
@@ -37,6 +49,7 @@
"@typescript-eslint/parser": "^5.36.1",
"babel-jest": "^29.4.1",
"chai": "^4.3.7",
"core-js": "^3.6.5",
"cypress": "^12.2.0",
"eslint": "~8.15.0",
"eslint-config-next": "13.1.1",
@@ -56,11 +69,16 @@
"react-test-renderer": "18.2.0",
"rehype-stringify": "^9.0.3",
"remark": "^14.0.3",
"storybook-tailwind-dark-mode": "^1.0.22",
"swc-loader": "0.1.15",
"ts-jest": "^29.0.5",
"ts-node": "10.9.1",
"typescript": "~4.9.5",
"unist-util-select": "^4.0.3",
"unist-util-visit": "^4.1.2"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}

View File

@@ -0,0 +1,3 @@
User-agent: *
Allow: /$
Disallow: /

View File

@@ -1,5 +1,11 @@
# @portaljs/components
## 0.3.1
### Patch Changes
- [#980](https://github.com/datopian/portaljs/pull/980) [`38738525`](https://github.com/datopian/portaljs/commit/3873852567b1aab4827a716bd588bd5de3223e2b) Thanks [@demenech](https://github.com/demenech)! - Fix missing CSS styles for PDF component
## 0.3.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@portaljs/components",
"version": "0.3.0",
"version": "0.3.1",
"type": "module",
"description": "https://portaljs.org",
"keywords": [
@@ -16,7 +16,7 @@
"build": "tsc && vite build && npm run build-tailwind && npm run fix-leaflet",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"build-storybook": "storybook build && cp ./.storybook/robots.txt ./storybook-static",
"build-tailwind": "NODE_ENV=production npx tailwindcss --postcss -c tailwind.config.js -i src/index.css -o ./dist/style.css --minify",
"prepare": "npm run build",
"fix-leaflet": "node ./scripts/fix-leaflet.cjs"

View File

@@ -0,0 +1,21 @@
import type { StorybookConfig } from '@storybook/react-webpack5';
const config: StorybookConfig = {
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
addons: [
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@nrwl/react/plugins/storybook',
'storybook-tailwind-dark-mode'
],
framework: {
name: '@storybook/react-webpack5',
options: {},
},
};
export default config;
// To customize your webpack configuration you can use the webpackFinal field.
// Check https://storybook.js.org/docs/react/builders/webpack#extending-storybooks-webpack-config
// and https://nx.dev/packages/storybook/documents/custom-builder-configs

View File

@@ -0,0 +1,14 @@
import './tailwind-imports.css';
const preview = {
globalTypes: {
darkMode: {
defaultValue: false, // Enable dark mode by default on all stories
},
className: {
defaultValue: 'dark', // Set your custom dark mode class name
},
},
};
export default preview;

View File

@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

View File

@@ -0,0 +1,31 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"outDir": ""
},
"files": [
"../../node_modules/@nx/react/typings/styled-jsx.d.ts",
"../../node_modules/@nx/react/typings/cssmodule.d.ts",
"../../node_modules/@nx/react/typings/image.d.ts"
],
"exclude": [
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.tsx",
"src/**/*.test.tsx",
"src/**/*.spec.jsx",
"src/**/*.test.js"
],
"include": [
"src/**/*.stories.ts",
"src/**/*.stories.js",
"src/**/*.stories.jsx",
"src/**/*.stories.tsx",
"src/**/*.stories.mdx",
".storybook/*.js",
".storybook/*.ts"
]
}

View File

@@ -0,0 +1,11 @@
// libs/shared/ui/postcss.config.js
const { join } = require('path');
module.exports = {
plugins: {
tailwindcss: {
config: join(__dirname, 'tailwind.config.js'),
},
autoprefixer: {},
},
};

View File

@@ -34,6 +34,37 @@
"jestConfig": "packages/core/jest.config.ts",
"passWithNoTests": true
}
},
"storybook": {
"executor": "@nrwl/storybook:storybook",
"options": {
"port": 4400,
"configDir": "packages/core/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"build-storybook": {
"executor": "@nrwl/storybook:build",
"outputs": ["{options.outputDir}"],
"options": {
"outputDir": "dist/storybook/core",
"configDir": "packages/core/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"test-storybook": {
"executor": "nx:run-commands",
"options": {
"command": "test-storybook -c packages/core/.storybook --url=http://localhost:4400"
}
}
}
}

View File

@@ -0,0 +1,48 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Card } from './Card';
const meta: Meta<typeof Card> = {
component: Card,
};
export default meta;
type Story = StoryObj<typeof Card>;
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/react/api/csf
* to learn how to use render functions.
*/
const blog = {
urlPath: "#",
title: "Card title goes here",
date: "2021-01-01",
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, diam quis accumsan maximus, quam libero porttitor nisl, vita",
}
export const Primary: Story = {
render: () => (
<Card className="md:col-span-3">
<Card.Title href={`${blog.urlPath}`}>
{blog.title}
</Card.Title>
<Card.Eyebrow
as="time"
dateTime={blog.date}
className="md:hidden"
decorate
>
{blog.date}
</Card.Eyebrow>
{blog.description && (
<Card.Description>
{blog.description}
</Card.Description>
)}
<Card.Cta>Read article</Card.Cta>
</Card>
),
};

View File

@@ -0,0 +1,44 @@
const { createGlobPatternsForDependencies } = require('@nrwl/next/tailwind');
const { join } = require('path');
// const defaultTheme = require("tailwindcss/defaultTheme");
const colors = require("tailwindcss/colors");
module.exports = {
content: [
join(__dirname, './src/**/*.{js,ts,jsx,tsx}'),
...createGlobPatternsForDependencies(__dirname),
],
darkMode: "class",
theme: {
extend: {
// support wider width for large screens >1440px eg. in hero
maxWidth: {
"8xl": "88rem",
},
// fontFamily: {
// sans: ["ui-sans-serif", ...defaultTheme.fontFamily.sans],
// serif: ["ui-serif", ...defaultTheme.fontFamily.serif],
// mono: ["ui-monospace", ...defaultTheme.fontFamily.mono],
// headings: ["-apple-system", ...defaultTheme.fontFamily.sans],
// },
colors: {
background: {
DEFAULT: colors.white,
dark: colors.slate[900],
},
primary: {
DEFAULT: colors.gray[700],
dark: colors.gray[300],
},
secondary: {
DEFAULT: colors.sky[400],
dark: colors.sky[400],
},
},
},
},
/* eslint global-require: off */
// plugins: [
// require("@tailwindcss/typography")
// ],
};

View File

@@ -1,5 +1,6 @@
{
"compilerOptions": {
"baseUrl": ".",
"jsx": "react-jsx",
"module": "es2020",
"moduleResolution": "node",
@@ -22,6 +23,9 @@
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./.storybook/tsconfig.json"
}
]
}

View File

@@ -17,7 +17,11 @@
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx"
"**/*.test.jsx",
"**/*.stories.ts",
"**/*.stories.js",
"**/*.stories.jsx",
"**/*.stories.tsx"
],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}

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

5
site/.gitignore vendored
View File

@@ -35,3 +35,8 @@ yarn-error.log*
# markdowndb
markdown.db
# seo
robots.txt
sitemap-0.xml
sitemap.xml

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

@@ -58,7 +58,7 @@ export default function Features() {
>
<div className="absolute -inset-px rounded-xl border-2 border-transparent opacity-0 [background:linear-gradient(var(--quick-links-hover-bg,theme(colors.sky.50)),var(--quick-links-hover-bg,theme(colors.sky.50)))_padding-box,linear-gradient(to_top,theme(colors.blue.300),theme(colors.blue.400),theme(colors.blue.500))_border-box] group-hover:opacity-100 dark:[--quick-links-hover-bg:theme(colors.slate.800)]" />
<div className="relative overflow-hidden rounded-xl p-6">
<img src={feature.icon} alt="" className="h-24 w-auto" />
<img src={feature.icon} alt={feature.title} className="h-24 w-auto" />
<h2 className="mt-4 font-display text-base text-primary dark:text-primary-dark">
<span className="absolute -inset-px rounded-xl" />
{feature.title}

View File

@@ -41,7 +41,7 @@ export function Hero() {
{/* Commented code on line 37, 39 and 113 will reenable the two columns hero */}
<div className="mx-auto grid max-w-2xl grid-cols-1 gap-y-16 gap-x-8 px-4 lg:max-w-8xl lg:grid-cols-2 lg:px-8 xl:gap-x-16 xl:px-12">
<div className="relative mb-10 lg:mb-0 md:text-center lg:text-left">
<div role="heading">
<div>
<h1 className="inline bg-gradient-to-r from-blue-500 via-blue-300 to-blue-500 bg-clip-text text-5xl tracking-tight text-transparent">
The JavaScript framework for data portals
</h1>

View File

@@ -0,0 +1,65 @@
import { ArticleJsonLd } from 'next-seo';
import { useRouter } from 'next/router';
export default function JSONLD({
meta,
source,
}: {
meta: any;
source: string;
}): JSX.Element {
if (!source) {
return <></>;
}
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://portaljs.org';
const pageUrl = `${baseUrl}/${meta.urlPath}`;
const imageMatches = source.match(
/(?<=src: ")(.*)\.((png)|(jpg)|(jpeg))(?=")/g
);
let images = [];
if (imageMatches) {
images = [...imageMatches];
images = images.map((img) =>
img.startsWith('http')
? img
: `${baseUrl}${img.startsWith('/') ? '' : '/'}${img}`
);
}
let Component: JSX.Element;
const isBlog: boolean =
/^blog\/.*/.test(meta.urlPath) || meta.filetype === 'blog';
const isDoc: boolean = /^((docs)|(howtos\/)|(guide\/)).*/.test(meta.urlPath);
if (isBlog) {
Component = (
<ArticleJsonLd
type="BlogPosting"
url={pageUrl}
title={meta.title}
datePublished={meta.date}
dateModified={meta.date}
authorName={meta.authors.length ? meta.authors[0].name : 'PortalJS'}
description={meta.description}
images={images}
/>
);
} else if (isDoc) {
Component = (
<ArticleJsonLd
url={pageUrl}
title={meta.title}
images={images}
datePublished={meta.date}
dateModified={meta.date}
authorName={meta.authors.length ? meta.authors[0].name : 'PortalJS'}
description={meta.description}
/>
);
}
return Component;
}

View File

@@ -54,12 +54,14 @@ function useTableOfContents(tableOfContents) {
export default function Layout({
children,
title,
description,
tableOfContents = [],
isHomePage = false,
sidebarTree = [],
}: {
children;
title?: string;
description?: string;
tableOfContents?;
urlPath?: string;
sidebarTree?: [];
@@ -82,9 +84,9 @@ export default function Layout({
return (
<>
{title && <NextSeo title={title} />}
{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

@@ -12,7 +12,6 @@ export default function MDXPage({ source, frontMatter }) {
return <LayoutComponent {...frontMatter}>{children}</LayoutComponent>;
};
return (
<Layout>
<MDXRemote {...source} components={{ DocsPagination, NextSeo, Hero }} />

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

@@ -20,7 +20,7 @@ export default function NavItem({ item }) {
};
return (
<Menu as="div" className="relative">
<Menu as="div" role="menu" className="relative">
<Menu.Item>
{Object.prototype.hasOwnProperty.call(item, 'href') ? (
<Link

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

View File

@@ -0,0 +1,64 @@
---
title: 'Enhancing Geospatial Data Visualization with PortalJS'
date: 2023-07-18
authors: ['João Demenech', 'Luccas Mateus', 'Yoana Popova']
filetype: 'blog'
---
Are you keen on building rich and interactive data portals? Do you find value in the power and flexibility of JavaScript, Nextjs, and React? In that case, allow us to introduce you to [PortalJS](https://portaljs.org/), a state-of-the-art framework leveraging these technologies to help you build amazing data portals.
Perhaps you already understand that the effective data visualization lies in the adept utilization of various data components. Within [PortalJS](https://portaljs.org/), we take data visualization a step further. It's not just about displaying data - it's about telling a captivating story through the strategic orchestration of a diverse array of data components.
We are now eager to share our latest enhancement to [PortalJS](https://portaljs.org/): maps, a powerful tool for visualizing geospatial data. In this post, we will to take you on a tour of our experiments and progress in enhancing map functionalities on [PortalJS](https://portaljs.org/). Our journey into this innovative feature is still in its early stages, with new facets being unveiled and refined as we perfect our API. Still, this exciting development opens a new avenue for visualizing data, enhancing your ability to convey complex geospatial information with clarity and precision.
## Exploring Map Formats
Maps play a crucial role in geospatial data visualization. Several formats exist for storing and sharing this type of data, with GeoJSON, KML, and shapefiles being among the most popular. As a prominent figure in the field of open-source data portal platforms, [PortalJS](https://portaljs.org/) strives to support as many map formats as possible.
Taking inspiration from the ckanext-geoview extension, we currently support KML and GeoJSON formats in [PortalJS](https://portaljs.org/). This remarkable extension is a plugin for CKAN, the worlds leading open source data management system, that enables users to visualize geospatial data in diverse formats on an interactive map. Apart from KML and GeoJSON formats support, our roadmap entails extending compatibility to encompass all other formats supported by ckanext-geoview. Rest assured, we are committed to empowering users with a wide array of map format options in the future.
So, what makes these formats special?
- **GeoJSON**: This format uses JSON to depict simple geographic features and their associated attributes. It's often hailed as the most popular choice in the field.
- **KML**: An XML-based format, KML can store details like placemarks, paths, polygons, and styles.
- **Shapefiles**: These are file collections that store vector data—points, lines, and polygons—and their attributes.
## Unveiling the Power of Leaflet and OpenLayers
To display maps in [PortalJS](https://portaljs.org/), we utilize two powerful JavaScript libraries for creating interactive maps based on different layers: Leaflet and OpenLayers. Each offers distinct advantages (and disadvantages), inspiring us to integrate both and give users the flexibility to choose.
Leaflet is the leading open-source JavaScript library known for its mobile-friendly, interactive maps. With its compact size (just 42 KB of JS), it provides all the map features most developers need. Leaflet is designed with simplicity, performance and usability in mind. It works efficiently across all major desktop and mobile platforms.
OpenLayers is a high-performance library packed with features for creating interactive web maps. OpenLayers can display map tiles, vector data, and markers sourced from anywhere on any webpage. It's an excellent tool for leveraging geographic information of all kinds.
## Introducing Map Feature
Both components have some similar features and props, such as:
### Polygons and points
![Map with polygons and points](/assets/blog/2023-07-18-map-polygons-and-points.png)
Our initial version enables the use of both vectors and points to display information. Points are simpler and faster to render than vectors, but they have less detail and interactivity. For example, if you have data that is represented by coordinates or addresses, you can use points to show them on the map. This way, you can avoid time-consuming loading and rendering complex vector shapes that may slow down your map.
### Tooltips
![Map with tooltips](/assets/blog/2023-07-18-map-tooltips.png)
We have implemented an exciting feature that enhances the usability of our map component: tooltips. When you hover over a polygon or point on the map, a small pop-up window, known as a tooltip, appears. This tooltip provides relevant details about the feature under your cursor, according to what features the map creator wants to highlight. For example, when exploring countries, you can effortlessly discover their name, population, and area by hovering over them. Similarly, hovering over cities reveals useful information like their name, temperature, and elevation. To enable this handy tooltip functionality on our map, simply include a tooltip prop when using the map component.
### Focus
![Map with polygons over a region](/assets/blog/2023-07-18-map-polygons-on-region.png)
Users can also choose a region of focus, which will depend on the data, by setting initial center coordinates and zoom level. This is especially helpful for maps that are not global, such as the ones that use data from a specific country, city or region.
## Mapping the Future with PortalJS
Through our ongoing enhancements to the [PortalJS library](https://storybook.portaljs.org/), we aim to empower users to create engaging and informative data portals featuring diverse map formats and data components.
Why not give [PortalJS](https://portaljs.org/) a try today and discover the possibilities for your own data portals? To get started, check out our comprehensive documentation here: [PortalJS Documentation](https://portaljs.org/docs).
Have questions or comments about using [PortalJS](https://portaljs.org/) for your data portals? Feel free to share your thoughts on our [Discord channel](https://discord.com/invite/EeyfGrGu4U). We're here to help you make the most of your data.
Stay tuned for more exciting developments as we continue to enhance [PortalJS](https://portaljs.org/)!

View File

@@ -264,7 +264,7 @@ The above script will output the following to the terminal:
## Done!
That's it! We've just created a simple catalog of our GitHub projects using markdown files and the MarkdownDB package. You can find the full code for this tutorial [here](https://github.com/datopian/markdowndb/tree/main/examples/basic-example).
That's it! We've just created a simple catalog of our GitHub projects using markdown files and the MarkdownDB package. You can find the [full code for this tutorial here](https://github.com/datopian/markdowndb/tree/main/examples/basic-example).
We look forward to seeing the amazing applications you'll build with this tool!

View File

@@ -1,7 +1,7 @@
const config = {
title: 'PortalJS',
title: 'PortalJS - The JavaScript framework for data portals.',
description:
'PortalJS is a framework for rapidly building rich data portal frontends using a modern frontend approach. PortalJS can be used to present a single dataset or build a full-scale data catalog/portal.',
'PortalJS is a JavaScript framework for rapidly building rich data portal frontends using a modern frontend approach.',
theme: {
default: 'dark',
toggleIcon: '/images/theme-button.svg',
@@ -36,6 +36,10 @@ const config = {
],
footerLinks: [],
nextSeo: {
additionalLinkTags: [
{ rel: 'icon', href: '/favicon.ico' },
{ rel: 'apple-touch-icon', href: '/icon.png', sizes: '120x120' },
],
openGraph: {
type: 'website',
title:

View File

@@ -1,6 +1,7 @@
<NextSeo title="Creating new datasets - PortalJS" />
# Creating new datasets
---
title: 'Creating new datasets'
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.
@@ -10,7 +11,7 @@ Let's explore how to add and display more datasets to our portal.
As you have seen, in this example a dataset page is just a markdown file on disk plus a data file.
To create a new data showcase page we just create a new markdown file in the `content/` folder and a new data file in the `public/` folder.
To create a new data showcase page we just create a new markdown file in the `content/` folder and a new data file in the `public/` folder.
Let's do that now. Create a `content/my-incredible-dataset` folder, and inside this new folder create a `index.md` file with the following content:
@@ -19,7 +20,7 @@ Let's do that now. Create a `content/my-incredible-dataset` folder, and inside t
This is my incredible dataset.
## Chart
## Chart
<LineChart
title="US Population By Decade"
@@ -42,7 +43,7 @@ Year,Population (mi)
Note that pages are associated with a route based on their pathname, so, to see the new data page, access http://localhost:3000/my-incredible-dataset from the browser. You should see the following:
<img src="/assets/docs/my-incredible-dataset.png" />
<img src="/assets/docs/my-incredible-dataset.png" alt="Page of a new dataset created on a PortalJS data portal" />
> [!tip]
> In this tutorial we opted for storing content as markdown files and data as CSV files in the app, but PortalJS can have metadata, data and content stored anywhere.
@@ -58,12 +59,11 @@ List of available datasets:
- [My Awesome Dataset](/my-awesome-dataset)
- [My Incredible Dataset](/my-incredible-dataset)
```
From the browser, access http://localhost:3000. You should see the following:
<img src="/assets/docs/datasets-index-page.png" />
<img src="/assets/docs/datasets-index-page.png" alt="PortalJS data portal with multiple datasets" />
At this point, the app has multiple datasets, and users can find and navigate to any dataset they want. In the next lesson, you are going to learn how to improve this experience with search.

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,7 @@
<NextSeo title="Getting Started - PortalJS" />
# Getting Started
---
title: Getting Started
description: 'Getting started guide and tutorial about data portal-building with PortalJS!'
---
Welcome to the PortalJS documentation!
@@ -38,7 +39,7 @@ Let's check it's working and what we have! Open http://localhost:3000 from your
You should see a page like this when you access http://localhost:3000. This is the starter template page which shows the most simple data portal you could have: a simple README plus csv file.
<img src="/assets/examples/basic-example.png" />
<img src="/assets/examples/basic-example.png" alt="Initial state of the PortalJS tutorial project" />
### Editing the Page
@@ -51,8 +52,8 @@ Lets try editing the starter page.
After refreshing the page, you should see the new text:
<img src="/assets/docs/editing-the-page-1.png" />
<img src="/assets/docs/editing-the-page-1.png" alt="PortalJS tutorial project after a simple change is made by a user" />
Congratulations! The app is up and running and you learned how to edit a page. In the next lesson, you are going to learn how to create new datasets.
Congratulations! The app is up and running and you learned how to edit a page. In the next lesson, you are going to learn how to create new datasets.
<DocsPagination next="/docs/creating-new-datasets" />

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.
@@ -26,7 +27,7 @@ This example makes use of the [markdowndb](https://github.com/datopian/markdownd
From the browser, access http://localhost:3000. You should see the following, you now have a searchable automatic list of your datasets:
![](https://i.imgur.com/9HfSPIx.png)
![Simple data catalog built with PortalJS](https://i.imgur.com/9HfSPIx.png)
To make this catalog look even better, we can change the text that is being displayed for each dataset to a title. Let's do that by adding the "title" [frontmatter field](https://daily-dev-tips.com/posts/what-exactly-is-frontmatter/) to the first dataset in the list. Change `content/my-awesome-dataset/index.md` to the following:
@@ -46,7 +47,7 @@ Built with PortalJS
Rerun `npm run mddb` and, from the browser, access http://localhost:3000. You should see the title appearing instead of the folder name:
![](https://i.imgur.com/nvmSnJ5.png)
![Example of a newly added dataset on a data catalog built with PortalJS](https://i.imgur.com/nvmSnJ5.png)
Any frontmatter attribute that you add will automatically get indexed and be usable in the search box.
@@ -102,7 +103,7 @@ List of available datasets:
You now have a filter in your page with all possible values automatically added to it.
![](https://i.imgur.com/p2miSdg.png)
![Data catalog with facets built with PortalJS](https://i.imgur.com/p2miSdg.png)
In the next lesson, you are going to learn how to display metadata on the dataset page.

View File

@@ -1,10 +1,11 @@
<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.
![](https://i.imgur.com/O145uuc.png)
![Example of a page displaying the title metadata twice](https://i.imgur.com/O145uuc.png)
Change the content inside `/content/my-awesome-dataset/index.md` to this.
@@ -15,7 +16,7 @@ author: 'Rufus Pollock'
description: 'An awesome dataset displaying some awesome data'
modified: '2023-05-04'
files: ['data.csv']
groups: ['Awesome']
group: 'Awesome'
---
Built with PortalJS
@@ -27,7 +28,7 @@ Built with PortalJS
Once you refresh the page at `http://localhost:3000/my-awesome-dataset` you should see something like this at the top:
![](https://i.imgur.com/nvDYJQT.png)
![Example of a dataset page displaying metadata](https://i.imgur.com/nvDYJQT.png)
These are the standard metadata fields that will be shown at the top of the page if you add them.
@@ -35,6 +36,6 @@ These are the standard metadata fields that will be shown at the top of the page
- `author`, `description`, and `modified` which gets displayed below the title
- `files` that get displayed as a table with two columns: `File` which is linked directly to the file, and `Format` which show the file format.
Feel free to experiment with these metadata fields. At this point, you might want to deploy the app, and that's what you are going to learn in the next lesson.
Feel free to experiment with these metadata fields. At this point, you might want to deploy the app, and that's what you are going to learn in the next lesson.
<DocsPagination prev="/docs/searching-datasets" next="/docs/deploying-your-portaljs-app" />

View File

@@ -1,11 +1,16 @@
---
showToc: false
showSidebar: false
title: 'Markdown-based Websites Guide'
disableTitle: true
description: Create markdown-based websites and data portals, update it, add collaborators and discover markdown superpowers with Flowershow and PortalJS
---
<Hero title="Markdown-based Websites" subtitle="Create markdown-based website, update it, add collaborators and discover markdown superpowers" />
# Tutorial 1: Create a website from scratch using markdown and PortalJS
## Tutorials
### Tutorial 1: Create a website from scratch using markdown and PortalJS
In this tutorial we will walk you through creating an elegant, fully functional website written in simple markdown and published with PortalJS.
@@ -17,7 +22,7 @@ By the end of this tutorial you will:
Below is a screenshot of how the final website will look like:
![[tutorial-1-result.png]]
### Setup a sandbox website including live publishing
#### Setup a sandbox website including live publishing
- Prerequisites: sign up for GitHub and Vercel
- Navigate to [datopian/flowershow repository](https://github.com/datopian/flowershow)
@@ -25,14 +30,14 @@ Below is a screenshot of how the final website will look like:
- Let the site build on Vercel
- Visit the site! Yay! Your site is working! 🎉
### Now, let's edit the front page
#### Now, let's edit the front page
- Navigate to `content/index.md` file in the site repository
- Add some text to it
- Save and watch the site redeploy
- Visit the site! Yay! Your changes are live! 🎉
### Let's add a page: e.g. about page
#### Let's add a page: e.g. about page
- Navigate to the `content` folder in the site repository
- Add `about.md` file with some text
@@ -42,7 +47,7 @@ Below is a screenshot of how the final website will look like:
> [!tip]
> Read full tutorial [[create-a-website-from-scratch|here!]]
# Tutorial 2: Editing your site locally on your computer
### Tutorial 2: Editing your site locally on your computer
In this tutorial, we will walk you through the process of editing your Flowershow website locally on your computer.
@@ -58,20 +63,20 @@ Below is a screenshot of how the final website will look like:
![[tutorial-2-result.png]]
### Clone the repository to your computer
#### Clone the repository to your computer
- Setup GitHub Desktop app with your GitHub account
- Grab your site's repository URL
- Open GitHub Desktop app and clone the repository
- Yay! You have a copy of your website's repository on your computer! 🎉
### Now, let's edit in Obsidian
#### Now, let's edit in Obsidian
- Open the `/content` folder of the cloned repository in Obsidian
- Edit the home page and the about page
- Create a folder with the reviews of books you've read
### Commit your changes
#### Commit your changes
- Commit the changes in GitHub Desktop app
- Push the changes to the remote repository
@@ -79,4 +84,113 @@ Below is a screenshot of how the final website will look like:
- Visit the site! Yay! Your changes are live! 🎉
> [!tip]
> Read full tutorial [[edit-a-website-locally|here!]]
> Read full tutorial [[edit-a-website-locally|here!]]
### Tutorial 3: Collaborating with others on your website project
In this tutorial, we will guide you through collaborating with others on the same website project using GitHub.
By the end of this tutorial, you will:
- Understand what a branch is and how to create one.
- Understand what a pull request (PR) is and how to create one.
- Learn how to review and merge a PR.
- Know how to resolve conflicts if they arise.
- Collaborate with others using GitHub, following best practices.
#### Create a new branch
- Navigate to your site's repository on GitHub
- Click on the 'Branch' dropdown menu, type a new branch name and press Enter
- Yay! You've created a new branch! 🎉
#### Now, let's make changes in the new branch
- Switch to the new branch in GitHub Desktop
- Open the `/content` folder of the repository in Obsidian
- Edit the `about` page
- Commit the changes in GitHub Desktop app and push them to the remote repository on GitHub
#### Create a pull request (PR)
- Go back to your site's repository on GitHub
- Click on 'New pull request'
- Select your branch from the dropdown menu
- Write a brief description of your changes, then click on 'Create pull request'
- Yay! Your changes are ready to be reviewed! 🎉
#### Review and merge a pull request
- Navigate to the 'Pull requests' tab in your repository
- Open the newly created pull request
- Review the changes, add comments if necessary
- If everything is in order, click 'Merge pull request', then 'Confirm merge'
- Yay! You've merged your changes into the main branch! 🎉
#### Resolving conflicts
- In case of conflicts between your changes and those on the main branch, GitHub will alert you
- Follow the on-screen instructions to resolve the conflicts and merge your changes
> [!tip]
> Read full tutorial [[collaborate-on-website-project|here!]] (TBD)
### Tutorial 4: Customising your website locally and previewing your changes locally
In this tutorial, we will dive into the more technical aspects of website customisation, but this time, everything will be done locally. You'll learn how to preview your site on your own machine before pushing changes to the live site, ensuring everything looks and works exactly as you want.
By the end of this tutorial, you will:
- Understand how to preview your site locally.
- Know how to change your website's title and description.
- Learn how to customise your website's appearance using Tailwind themes.
- Understand how to configure the navbar, navigation links, and logo.
- Learn how to integrate Google Analytics into your website.
- Be aware of additional customisation options for deeper customisation.
#### Previewing the site locally
- Navigate to your website's repository directory on your computer using command line
- Install the site's dependencies
- Start the local development server
- Visit the local address displayed in your command line. Yay! You can now preview your changes locally, live! 🎉
#### Changing the site title and description
- Perfect! You've personalised your site's title and description! 🎉
#### Configuring the title, description and navbar
- Open the `content/config.mjs` file in your code editor
- Edit the `title` and `description` fields
- Edit the fields in the `navbar` field to customise your navbar's title and logo. Then, add navigation links to `navLinks` field (these will be displayed in the navbar). Save and refresh your local site to see the changes.
#### Integrating with Google Analytics
- Still in the `content/config.mjs` file, navigate to the `analytics` field
- Enter your Google Analytics tracking ID, save and refresh your local site to ensure it's integrated correctly
- Excellent! Your website is now integrated with Google Analytics! 🎉
#### Customising the Tailwind theme
- Open `tailwind.config.js` file in your code editor
- Change the light and dark theme colours and fonts to your liking, save and refresh your local site to see the changes
- Awesome! Your website now has a new look! 🎉
When you're happy with all your changes, use GitHub Desktop to commit your changes and push them back to your GitHub repository.
In addition to these topics, the full tutorial shows you what other customisations options are available and where to find information on these.
> [!tip]
> Read full tutorial here! (TBD)
## Howtos
- [[quickly-create-a-sandbox-website|How to quickly create a sandbox website]]
- [[edit-text-on-a-single-md-page|How to quickly edit text on a single Markdown-based page]]
- [[add-a-simple-md-page|How to add a simple Markdown page]]
- [[edit-or-add-md-pages-locally|How to edit or add Markdown-based pages locally on your computer]]
- [[how-to-add-images-to-a-md-page|How to add images to a Markdown-based page]]
- [[publish-obsidian-vault-to-github|How to push an Obsidian vault to a GitHub repository]]
- [[create-a-simple-catalog-of-anything|How to create a simple catalog of anything in Obsidian]]

View File

@@ -1,13 +1,16 @@
---
title: How to quickly add a simple Markdown-based page
date: 2023-07-27
authors: ['Lauren Wigmore', 'Ola Rubaj']
filetype: 'blog'
---
Welcome to this tutorial on how to quickly add a simple Markdown-based page to your website. The steps here are designed for non-technical contributors. There's no need to know how to code!
Welcome to this howto on how to quickly add a simple Markdown-based page to your website. The steps here are designed for non-technical contributors. There's no need to know how to code!
> [!important]
> This "How to" is only recommended for very simple Markdown pages, e.g. those without images, links to other pages, diagrams, or other elements that can't be previewed in GitHub preview mode.
> This "How to" is only recommended for very simple Markdown pages, e.g. those without images, links to other pages, diagrams, or other elements that can't be previewed in GitHub preview mode.
>[!tip]
> [!tip]
> If you are unfamiliar with Markdown (and its different flavours and extra elements supported by Flowershow based websites), check out [this short guide](https://flowershow.app/docs/syntax) on available syntax elements.
## Steps
@@ -20,15 +23,15 @@ Welcome to this tutorial on how to quickly add a simple Markdown-based page to y
> [!tip]
> If you want to add your page to a new subfolder, in the "Name your file..." field, first type the name of the new subfolder, followed by a forward slash, .e.g., `blog/`. After you hit the slash, you'll see the name field gets cleared, but the path before it has been extended with your subfolder name. You can repeat this process if you want to put your file into further nested subfolders. Then, simply type the name of the file with ".md" extension.
5. Paste or write the contents of the file in Markdown format.
5. Paste or write the contents of the file in Markdown format.
6. (Optionally) Switch to the "Preview" mode, by toggling from "Edit" -> "Preview" at the top of the file content, to see a rough visualisation of your changes. Keep in mind though, that the actual website may have different styling and may support additional Markdown elements that GitHub doesn't render on the preview.
5. When you're happy with the content, click on the “Commit changes...” button. In the "Commit message" field, provide a concise summary of your changes. If necessary, you can add further explanation in the "Extended description" text field. Then select “Commit directly to the main branch”, and hit "Commit changes."
6. The site is now going to be rebuilt to reflect the changes saved to the `main` branch. This can take up to a few minutes. After this time you should see your page live.
7. When you're happy with the content, click on the “Commit changes...” button. In the "Commit message" field, provide a concise summary of your changes. If necessary, you can add further explanation in the "Extended description" text field. Then select “Commit directly to the main branch”, and hit "Commit changes."
8. The site is now going to be rebuilt to reflect the changes saved to the `main` branch. This can take up to a few minutes. After this time you should see your page live.
## Summary
Congratulations, you've now learned how to create a new Markdown page on your Flowershow-based website.
Congratulations, you've now learned how to create a new Markdown page on your Flowershow-based website.
If anything is not clear to you, or you have suggestions on how we can make this 'How to' better, please don't hesitate to let us know.
If anything is not clear to you, or you have suggestions on how we can make this 'How to' better, please don't hesitate to let us know.
Happy editing!

View File

@@ -3,13 +3,6 @@ title: How to add or edit content on the Life Itself ecosystem page
isDraft: true
---
## Contents
1. [Introduction](#introduction)
2. [How to edit and add to the site](#how-to-edit-and-add-to-the-site)
3. [Glossary](#glossary)
4. [Contact](#contact)
## Introduction
From the outset, we have argued that any successful mapping effort must be collaborative and participatory. To make it as simple as possible to contribute, we have opened up the site, giving it a wiki-like structure, meaning people can contribute and add items directly - no coding required. We hope this can support the ongoing growth of our contributor community, and empower users to continue in collective efforts to make the map ever more useful and informative.

View File

@@ -1,4 +1,7 @@
# How to add Google Analytics?
---
title: How to add Google Analytics?
description: Learn how to implement Google Analytics on PortalJS data portals
---
>[!todo] Prerequisites
>- [Google Analytics account](https://support.google.com/analytics/answer/9304153?hl=en)
@@ -74,4 +77,4 @@ export default function MyApp({ Component, pageProps }) {
```
>[!info]
> For more info on measuring pageviews with Google Analytics see [Google Analytics documentation](https://developers.google.com/analytics/devguides/collection/gtagjs/pages).
> For more info on measuring pageviews with Google Analytics see [Google Analytics documentation](https://developers.google.com/analytics/devguides/collection/gtagjs/pages).

View File

@@ -1,4 +1,7 @@
# How to add a simple blog?
---
title: How to add a simple blog?
description: Learn how to add a simple blog on a PortalJS data portal
---
## Setup
@@ -13,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>
);
}
```
@@ -29,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>;
}
```
@@ -54,7 +57,7 @@ export default BlogPost({ content, title, date, authors }) {
<BlogLayout title={title} date={date} authors={authors}
{content}
</BlogLayout>
)
)
}
```
@@ -62,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,4 +1,7 @@
# How to add user comments?
---
title: How to add user comments?
description: Learn how to add user comments on a PortalJS data portal
---
![[comments-example.png]]

View File

@@ -1,4 +1,7 @@
# How to create data-rich documents with charts and tables?
---
title: How to create data-rich documents with charts and tables?
description: Learn how to create a data-rich document with charts and tables on a PortalJS data portal
---
> [!info] Prerequisites
> If you want to enrich your markdown content with charts and tables, you first need to add support for rendering markdown files in your PortalJS app. Follow [[markdown|this guide]] to learn how to do this.
@@ -15,12 +18,12 @@ Now, in order to use these components in your markdown files, we need to pass th
```tsx
// e.g. /blog/[[...slug]].tsx
import fs from "fs";
import { LineChart, Table, Catalog, Vega, VegaLite } from "@portaljs/components";
import fs from 'fs';
import { LineChart, Table, Catalog, Vega, VegaLite } from '@portaljs/components';
import { MdxRemote } from "next-mdx-remote";
import clientPromise from "@/lib/mddb.mjs";
import parse from "@/lib/markdown";
import { MdxRemote } from 'next-mdx-remote';
import clientPromise from '@/lib/mddb.mjs';
import parse from '@/lib/markdown';
const components = {
Table: Table,
@@ -29,37 +32,35 @@ const components = {
LineChart: LineChart,
};
export default function Page({ source }) {
source = JSON.parse(source);
source = JSON.parse(source);
return (
<>
<MdxRemote source={source} components={components} />
</>
);
return (
<>
<MdxRemote source={source} components={components} />
</>
);
}
// Import metadata of a file matching the static path and return its parsed source and frontmatter object
export const getStaticProps = async ({ params }) => {
const urlPath = params?.slug ? (params.slug as string[]).join("/") : "/";
const urlPath = params?.slug ? (params.slug as string[]).join('/') : '/';
const mddb = await clientPromise;
const dbFile = await mddb.getFileByUrl(urlPath);
const filePath = dbFile!.file_path;
// const frontMatter = dbFile!.metadata ?? {};
const mddb = await clientPromise;
const dbFile = await mddb.getFileByUrl(urlPath);
const filePath = dbFile!.file_path;
// const frontMatter = dbFile!.metadata ?? {};
const source = fs.readFileSync(filePath, { encoding: "utf-8" });
const { mdxSource } = await parse(source, "mdx", {});
const source = fs.readFileSync(filePath, { encoding: 'utf-8' });
const { mdxSource } = await parse(source, 'mdx', {});
return {
props: {
source: JSON.stringify(mdxSource),
// frontMatter
},
};
return {
props: {
source: JSON.stringify(mdxSource),
// frontMatter
},
};
};
```
You can now use these components in your markdown, like so:
@@ -93,39 +94,39 @@ Example usage:
cols={[
{
key: 'id',
name: 'ID'
name: 'ID',
},
{
key: 'firstName',
name: 'First name'
name: 'First name',
},
{
key: 'lastName',
name: 'Last name'
name: 'Last name',
},
{
key: 'age',
name: 'Age'
}
name: 'Age',
},
]}
data={[
{
age: 35,
firstName: 'Jon',
id: 1,
lastName: 'Snow'
lastName: 'Snow',
},
{
age: 42,
firstName: 'Cersei',
id: 2,
lastName: 'Lannister'
}
lastName: 'Lannister',
},
]}
/>
```
>[!info]
> [!info]
> More info on the [storybook page](https://storybook.portaljs.org/?path=/docs/components-table--docs)
### Linechart
@@ -139,31 +140,16 @@ Example usage:
```js
<LineChart
data={[
[
'1850',
-0.41765878
],
[
'1851',
-0.2333498
],
[
'1852',
-0.22939907
],
[
'1853',
-0.27035445
],
[
'1854',
-0.29163003
]
['1850', -0.41765878],
['1851', -0.2333498],
['1852', -0.22939907],
['1853', -0.27035445],
['1854', -0.29163003],
]}
/>
/>
```
>[!info]
> [!info]
> More info on the [storybook page](https://storybook.portaljs.org/?path=/docs/components-linechart--docs)
### Vega chart
@@ -179,30 +165,30 @@ Example usage:
table: [
{
x: 1850,
y: -0.418
y: -0.418,
},
{
x: 2020,
y: 0.923
}
]
y: 0.923,
},
],
}}
spec={{
$schema: 'https://vega.github.io/schema/vega-lite/v4.json',
data: {
name: 'table'
name: 'table',
},
encoding: {
x: {
field: 'x',
type: 'ordinal'
type: 'ordinal',
},
y: {
field: 'y',
type: 'quantitative'
}
type: 'quantitative',
},
},
mark: 'bar'
mark: 'bar',
}}
/>
```
@@ -222,35 +208,35 @@ Example usage:
table: [
{
x: 1850,
y: -0.418
y: -0.418,
},
{
x: 2020,
y: 0.923
}
]
y: 0.923,
},
],
}}
spec={{
$schema: 'https://vega.github.io/schema/vega-lite/v4.json',
data: {
name: 'table'
name: 'table',
},
encoding: {
x: {
field: 'x',
type: 'ordinal'
type: 'ordinal',
},
y: {
field: 'y',
type: 'quantitative'
}
type: 'quantitative',
},
},
mark: 'bar'
mark: 'bar',
}}
/>
```
>[!info]
> [!info]
> More info on the [storybook page](https://storybook.portaljs.org/?path=/docs/components-vegalite--docs)
### Catalog
@@ -269,28 +255,21 @@ Example usage:
metadata: {
'details-of-task': 'Detect and categorise abusive language in social media data',
language: 'Albanian',
'level-of-annotation': [
'Posts'
],
'level-of-annotation': ['Posts'],
'link-to-data': 'https://doi.org/10.6084/m9.figshare.19333298.v1',
'link-to-publication': 'https://arxiv.org/abs/2107.13592',
medium: [
'Text'
],
medium: ['Text'],
'percentage-abusive': 13.2,
platform: [
'Instagram',
'Youtube'
],
platform: ['Instagram', 'Youtube'],
reference: 'Nurce, E., Keci, J., Derczynski, L., 2021. Detecting Abusive Albanian. arXiv:2107.13592',
'size-of-dataset': 11874,
'task-description': 'Hierarchical (offensive/not; untargeted/targeted; person/group/other)',
title: 'Detecting Abusive Albanian'
title: 'Detecting Abusive Albanian',
},
url_path: 'dataset-4'
url_path: 'dataset-4',
},
]}
/>
/>
```
You can also add facets that are going to act as filters for your metadata.
@@ -305,30 +284,23 @@ You can also add facets that are going to act as filters for your metadata.
metadata: {
'details-of-task': 'Detect and categorise abusive language in social media data',
language: 'Albanian',
'level-of-annotation': [
'Posts'
],
'level-of-annotation': ['Posts'],
'link-to-data': 'https://doi.org/10.6084/m9.figshare.19333298.v1',
'link-to-publication': 'https://arxiv.org/abs/2107.13592',
medium: [
'Text'
],
medium: ['Text'],
'percentage-abusive': 13.2,
platform: [
'Instagram',
'Youtube'
],
platform: ['Instagram', 'Youtube'],
reference: 'Nurce, E., Keci, J., Derczynski, L., 2021. Detecting Abusive Albanian. arXiv:2107.13592',
'size-of-dataset': 11874,
'task-description': 'Hierarchical (offensive/not; untargeted/targeted; person/group/other)',
title: 'Detecting Abusive Albanian'
title: 'Detecting Abusive Albanian',
},
url_path: 'dataset-4'
url_path: 'dataset-4',
},
]}
facets={['platform', 'language']}
/>
/>
```
>[!info]
> [!info]
> More info on the [storybook page](https://storybook.portaljs.org/?path=/docs/components-catalog--docs)

View File

@@ -1,5 +1,8 @@
---
title: "How to edit a page with a code editor or Obsidian"
title: 'How to edit a page with a code editor or Obsidian'
date: 2023-07-27
authors: ['Jake Hirsch', 'Ola Rubaj']
filetype: 'blog'
isDraft: true
---

View File

@@ -1,5 +1,8 @@
---
title: How to edit or add Markdown-based pages locally on your computer
date: 2023-07-27
authors: ['Jake Hirsch', 'Ola Rubaj']
filetype: 'blog'
---
## Intro

View File

@@ -1,13 +1,16 @@
---
title: How to quickly edit text content on a single Markdown-based page
title: How to quickly edit text on a single Markdown-based page
date: 2023-07-27
authors: ['Ola Rubaj']
filetype: 'blog'
---
Welcome to this tutorial on how to quickly edit text content on a single Markdown-based page. The steps here are designed for non-technical contributors. There's no need to know how to code!
Welcome to this tutorial on how to quickly edit text content on a single Markdown-based page. The steps here are designed for non-technical contributors. There's no need to know how to code!
> [!important]
> This "How to" is only recommended for text changes only, e.g. those that don't include adding images, links to other pages, diagrams, or other elements that can't be previewed in GitHub preview mode.
> This "How to" is only recommended for text changes only, e.g. those that don't include adding images, links to other pages, diagrams, or other elements that can't be previewed in GitHub preview mode.
>[!tip]
> [!tip]
> If you are unfamiliar with Markdown (and its different flavours and extra elements supported by Flowershow based websites), check out [this short guide](https://flowershow.app/docs/syntax) on available syntax elements.
## Steps

View File

@@ -0,0 +1,45 @@
---
title: How to add images to a Markdown-based page
date: 2023-07-27
authors: ['Jake Hirsch', 'Ola Rubaj']
filetype: 'blog'
---
## Intro
Here, you will learn how to add images to a Markdown-based page. These instructions show how to add these images locally, on your computer, so first you need to know how to work locally with GitHub Desktop app and Obsidian. If you're new to these tools, we recommend reading this howto first:
- [[blog/edit-or-add-md-pages-locally|How to edit or add Markdown pages locally]]
Or you can follow these two tutorials to start from scratch:
- [[create-a-website-from-scratch|Tutorial 1: Create a Markdown based website from scratch]]
- [[edit-a-website-locally|Tutorial 2: Edit your website locally on your computer]]
## Prerequisites
- A GitHub account
- A GitHub Desktop app
- Obsidian
## Steps
### Step 1: Set the assets folder as an attachment folder
In Obsidian, in the root of your vault, create a new folder called 'assets'. Then, right click on and select "set as attachment folder". By doing so, all the images you paste into your note will automatically be saved to this folder (instead of being saved to the root, next to all your notes). This is necessary for your website to display embedded images.
### Step 2: Copy and paste your image
Copy whichever image you would like to add and paste it directly into your Obsidian note. You can check that it has been saved to the "assets" folder.
### Step 3: Commit and push
To learn more about this step, see the howto or the tutorials listed in the intro section.
## Summary
Congratulations, you've now learned how to add an image to your Markdown page!
If anything is not clear to you, or you have suggestions on how we can make this 'How to' better, please don't hesitate to let us know.
Happy editing!

View File

@@ -0,0 +1,33 @@
---
title: How to format a perfect Markdown-based page
date: 2023-07-27
authors: ['Lauren Wigmore', 'Ola Rubaj']
filetype: 'blog'
isDraft: true
---
Welcome to this information guide to help you understand how to format the perfect Markdown-based page for your website. The information here is designed to give you an overview.
## Types of Markdown Styles
There are three types of Markdown options that are supported by Flowershow.
- CommonMark
- GitHub Flavored Markdown (GFM) - a superset of CommonMark
- Obsidian Flavored Markdown - a superset of CommonMark with most GFM functionalities plus its own syntax elements, such as wikilinks, callouts, LaTeX, mermaid diagrams, and more.
Each one has extra functionalities building on top of the previous Markdown option.
Flowershow aims to be fully Obsidian compatible since it supports most Obsidian Flavored Markdown syntax elements and therefore, it is the best to use as an editor.
## Useful Links
It would be too complicated (and long) to explain all of the formatting aspects here, so we have included the links below to provide you with this information and more!
[Flowershow Documents Page](https://flowershow.app/docs/syntax) - Use this page to see all of the useful key elements that are frequently required on Flowershow pages.
[Obsidian help pages](https://help.obsidian.md/Editing+and+formatting/Obsidian+Flavored+Markdown) - Use this to get more information on Obsidian's supported syntax
[GFM cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) - Use this as a quick guide to using Markdown for Github
## Other useful pages
[How to quickly add a simple Markdown-based page](https://guide.portaljs.org/guides/add-a-simple-md-page)
[How to quickly edit text content on a single Markdown-based page](https://guide.portaljs.org/guides/edit-text-on-a-single-md-page)

View File

@@ -1,4 +1,7 @@
# Guides and tutorials
---
title: Guides and Tutorials
description: Learn more about how you can achieve different data portal features with PortalJS
---
- [[howtos/analytics|How to add web analytics?]]
- [[howtos/seo|How to customize page metadata for SEO?]]

View File

@@ -1,4 +1,7 @@
# How to add markdown-based content pages?
---
title: How to add markdown-based content pages?
description: Learn how to add markdown-based content pages on PortalJS data portals
---
## Add content layer to your app

View File

@@ -1,5 +1,8 @@
---
title: How to push an Obsidian vault to a GitHub repository
date: 2023-07-27
authors: ['Jake Hirsch', 'Ola Rubaj']
filetype: 'blog'
---
This howto walks you through the process of setting up your Obsidian vault as a GitHub repository. Here are some of the benefits of doing so:
@@ -34,7 +37,7 @@ In this howto, we will use the GitHub Desktop application, an easy-to-use interf
2.6. Add an optional description.
2.7. Make sure the checkbox "Initialize this repository with a README" is unchecked, and "Git Ignore" and "License" are set to "None".
2.7. Make sure the checkbox "Initialise this repository with a README" is unchecked, and "Git Ignore" and "License" are set to "None".
2.8. Click on "Create Repository".

View File

@@ -1,5 +1,8 @@
---
title: How to quickly create a sandbox website
date: 2023-07-27
authors: ['Lauren Wigmore', 'Ola Rubaj']
filetype: 'blog'
---
By the end of this guide you will have a working markdown site you can edit, which gets published automatically online 🎉
@@ -22,13 +25,8 @@ The website will then be deployed. This takes approximately 1 minute.
Once you are on the Congratulations screen, click on the preview of your sandbox website to see the live/published version.
For instructions on how to add and edit pages, we recommend these tutorials:
For instructions on how to add and edit pages, we recommend these howtos:
- [[edit-a-page-with-code-editor-or-obsidian|How to edit text content on a single Markdown-based page]]
- [[add-a-simple-md-page|How to add a simple Markdown-based page]]
Here are some other links Vercel links that might be useful for you:
- [Dashboard Features Overview](https://vercel.com/docs/concepts/dashboard-features/overview)
- [Dashboard Features](https://vercel.com/docs/concepts/dashboard-features)
- [Projects](https://vercel.com/docs/concepts/projects/project-dashboard)
- [[howtos/add-a-simple-md-page|How to add a simple markdown page]]
- [[howtos/edit-text-on-a-single-md-page|How to edit text on a single markdown-based page]]
- [[howtos/edit-or-add-md-pages-locally|How to edit or add a markdown page locally on your computer]]

View File

@@ -1,4 +1,7 @@
# How to customize page metadata for SEO?
---
title: How to customize page metadata for SEO?
description: Learn how to customize page metadata for SEO on data portals built with PortalJS
---
>[!info]
>See [`next-seo` documentation](https://github.com/garmeeh/next-seo) to learn more.
@@ -76,4 +79,4 @@ export default function Page() (
```
>[!info]
> To learn more on per-page SEO configuration with `next-seo`, see [this docs section](https://github.com/garmeeh/next-seo#add-seo-to-page)
> To learn more on per-page SEO configuration with `next-seo`, see [this docs section](https://github.com/garmeeh/next-seo#add-seo-to-page)

View File

@@ -1,4 +1,7 @@
# How to build a sitemap?
---
title: How to build a sitemap?
description: Learn how to build a sitemap for a data portal built with PortalJS
---
## Setup
@@ -91,4 +94,4 @@ Add this to the scripts section in your `package.json` to regenerate the sitemap
"prebuild": "node ./scripts/sitemap.mjs",
```
```

View File

@@ -1,5 +1,6 @@
---
title: "Why use these tools to create a catalog?"
isDraft: true
---
On this site, we offer a “recipe” which uses a combination of free tools to easily create a directory of information that can be used for multiple purposes. With this method, you can start capturing information quickly and intuitively in a format that is flexible and usable later for various needs. Why does this help us? Because to map information to collect, organise, structure, and classify it and present it clearly is a way to make more sense of it and therefore of the world around us.

View File

@@ -6,7 +6,7 @@ export default function DefaultLayout({ children, ...frontMatter }) {
{/* Default layout */}
{!frontMatter.layout && (
<>
<h1>{frontMatter.title}</h1>
{!frontMatter.disableTitle && <h1>{frontMatter.title}</h1>}
{frontMatter.author && (
<div className="-mt-6">
<p className="opacity-60 pl-1">{frontMatter.author}</p>

View File

@@ -13,7 +13,7 @@ export const DocsLayout: React.FC<any> = ({ children, ...frontMatter }) => {
<time dateTime={created}>{formatDate(created)}</time>
</p>
)}
{title && <h1>{title}</h1>}
{!frontMatter.disableTitle && title && <h1>{title}</h1>}
</div>
</header>
<section>{children}</section>

View File

@@ -1,21 +1,21 @@
import { h } from "hastscript";
import matter from "gray-matter";
import mdxmermaid from "mdx-mermaid";
import remarkCallouts from "@portaljs/remark-callouts";
import remarkEmbed from "@portaljs/remark-embed";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import remarkSmartypants from "remark-smartypants";
import remarkToc from "remark-toc";
import remarkWikiLink, { getPermalinks } from "@portaljs/remark-wiki-link";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypeKatex from "rehype-katex";
import rehypeSlug from "rehype-slug";
import rehypePrismPlus from "rehype-prism-plus";
import { serialize } from "next-mdx-remote/serialize";
import { h } from 'hastscript';
import matter from 'gray-matter';
import mdxmermaid from 'mdx-mermaid';
import remarkCallouts from '@portaljs/remark-callouts';
import remarkEmbed from '@portaljs/remark-embed';
import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
import remarkSmartypants from 'remark-smartypants';
import remarkToc from 'remark-toc';
import remarkWikiLink, { getPermalinks } from '@portaljs/remark-wiki-link';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeKatex from 'rehype-katex';
import rehypeSlug from 'rehype-slug';
import rehypePrismPlus from 'rehype-prism-plus';
import { serialize } from 'next-mdx-remote/serialize';
import * as tw from "../tailwind.config";
import { siteConfig } from "../config/siteConfig";
import * as tw from '../tailwind.config';
import { siteConfig } from '../config/siteConfig';
/**
* Parse a markdown or MDX file to an MDX source form + front matter data
@@ -36,14 +36,14 @@ const parse = async function (source, format, scope) {
remarkPlugins: [
remarkEmbed,
remarkGfm,
[remarkSmartypants, { quotes: false, dashes: "oldschool" }],
[remarkSmartypants, { quotes: false, dashes: 'oldschool' }],
remarkMath,
remarkCallouts,
[remarkWikiLink, { permalinks, pathFormat: "obsidian-short" }],
[remarkWikiLink, { permalinks, pathFormat: 'obsidian-short' }],
[
remarkToc,
{
heading: "Table of contents",
heading: 'Table of contents',
tight: true,
},
],
@@ -54,29 +54,29 @@ const parse = async function (source, format, scope) {
[
rehypeAutolinkHeadings,
{
properties: { className: "heading-link" },
properties: { className: 'heading-link' },
test(element) {
return (
["h2", "h3", "h4", "h5", "h6"].includes(element.tagName) &&
element.properties?.id !== "table-of-contents" &&
element.properties?.className !== "blockquote-heading"
['h2', 'h3', 'h4', 'h5', 'h6'].includes(element.tagName) &&
element.properties?.id !== 'table-of-contents' &&
element.properties?.className !== 'blockquote-heading'
);
},
content() {
content(node) {
return [
h(
"svg",
'svg',
{
xmlns: "http:www.w3.org/2000/svg",
xmlns: 'http:www.w3.org/2000/svg',
fill: tw.theme.extend.colors.secondary.DEFAULT,
viewBox: "0 0 20 20",
className: "w-5 h-5",
viewBox: '0 0 20 20',
className: 'w-5 h-5',
},
[
h("path", {
fillRule: "evenodd",
clipRule: "evenodd",
d: "M9.493 2.853a.75.75 0 00-1.486-.205L7.545 6H4.198a.75.75 0 000 1.5h3.14l-.69 5H3.302a.75.75 0 000 1.5h3.14l-.435 3.148a.75.75 0 001.486.205L7.955 14h2.986l-.434 3.148a.75.75 0 001.486.205L12.456 14h3.346a.75.75 0 000-1.5h-3.14l.69-5h3.346a.75.75 0 000-1.5h-3.14l.435-3.147a.75.75 0 00-1.486-.205L12.045 6H9.059l.434-3.147zM8.852 7.5l-.69 5h2.986l.69-5H8.852z",
h('path', {
fillRule: 'evenodd',
clipRule: 'evenodd',
d: 'M9.493 2.853a.75.75 0 00-1.486-.205L7.545 6H4.198a.75.75 0 000 1.5h3.14l-.69 5H3.302a.75.75 0 000 1.5h3.14l-.435 3.148a.75.75 0 001.486.205L7.955 14h2.986l-.434 3.148a.75.75 0 001.486.205L12.456 14h3.346a.75.75 0 000-1.5h-3.14l.69-5h3.346a.75.75 0 000-1.5h-3.14l.435-3.147a.75.75 0 00-1.486-.205L12.045 6H9.059l.434-3.147zM8.852 7.5l-.69 5h2.986l.69-5H8.852z',
}),
]
),
@@ -84,7 +84,7 @@ const parse = async function (source, format, scope) {
},
},
],
[rehypeKatex, { output: "mathml" }],
[rehypeKatex, { output: 'mathml' }],
[rehypePrismPlus, { ignoreMissing: true }],
],
format,

View File

@@ -0,0 +1,11 @@
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: process.env.SITE_URL || 'https://portaljs.org',
generateRobotsTxt: true,
robotsTxtOptions: {
policies: [
{ userAgent: '*', disallow: '/people' },
{ userAgent: '*', disallow: '/?amp=1' },
],
},
};

49
site/package-lock.json generated
View File

@@ -50,6 +50,7 @@
"devDependencies": {
"@tailwindcss/typography": "^0.5.9",
"autoprefixer": "^10.4.14",
"next-sitemap": "^4.1.8",
"postcss": "^8.4.22",
"prettier": "^2.8.7",
"remark": "^14.0.2",
@@ -229,6 +230,12 @@
"resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-6.0.2.tgz",
"integrity": "sha512-Tbsj02wXCbqGmzdnXNk0SOF19ChhRU70BsroIi4Pm6Ehp56in6vch94mfbdQ17DozxkL3BAVjbZ4Qc1a0HFRAg=="
},
"node_modules/@corex/deepmerge": {
"version": "4.0.43",
"resolved": "https://registry.npmjs.org/@corex/deepmerge/-/deepmerge-4.0.43.tgz",
"integrity": "sha512-N8uEMrMPL0cu/bdboEWpQYb/0i2K5Qn8eCsxzOmxSggJbbQte7ljMRoXm917AbntqTGOzdTu+vP3KOOzoC70HQ==",
"dev": true
},
"node_modules/@docsearch/css": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/@docsearch/css/-/css-3.5.0.tgz",
@@ -7087,6 +7094,15 @@
"node": "*"
}
},
"node_modules/minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"dev": true,
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/minipass": {
"version": "3.3.6",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz",
@@ -7330,6 +7346,39 @@
"react-dom": ">=16.0.0"
}
},
"node_modules/next-sitemap": {
"version": "4.1.8",
"resolved": "https://registry.npmjs.org/next-sitemap/-/next-sitemap-4.1.8.tgz",
"integrity": "sha512-XAXpBHX4o89JfMgvrm0zimlZwpu2iBPXHpimJMUrqOZSc4C2oB1Lv89mxuVON9IE8HOezaM+w4GjJxcYCuGPTQ==",
"dev": true,
"funding": [
{
"url": "https://github.com/iamvishnusankar/next-sitemap.git"
}
],
"dependencies": {
"@corex/deepmerge": "^4.0.43",
"@next/env": "^13.4.3",
"fast-glob": "^3.2.12",
"minimist": "^1.2.8"
},
"bin": {
"next-sitemap": "bin/next-sitemap.mjs",
"next-sitemap-cjs": "bin/next-sitemap.cjs"
},
"engines": {
"node": ">=14.18"
},
"peerDependencies": {
"next": "*"
}
},
"node_modules/next-sitemap/node_modules/@next/env": {
"version": "13.4.10",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.10.tgz",
"integrity": "sha512-3G1yD/XKTSLdihyDSa8JEsaWOELY+OWe08o0LUYzfuHp1zHDA8SObQlzKt+v+wrkkPcnPweoLH1ImZeUa0A1NQ==",
"dev": true
},
"node_modules/next-themes": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.2.1.tgz",

View File

@@ -6,6 +6,7 @@
"dev": "npm run mddb && next dev",
"build": "next build",
"prebuild": "npm run mddb && node ./scripts/fix-symlinks.mjs",
"postbuild": "next-sitemap",
"start": "next start",
"mddb": "mddb content"
},
@@ -52,6 +53,7 @@
"devDependencies": {
"@tailwindcss/typography": "^0.5.9",
"autoprefixer": "^10.4.14",
"next-sitemap": "^4.1.8",
"postcss": "^8.4.22",
"prettier": "^2.8.7",
"remark": "^14.0.2",

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

@@ -12,6 +12,8 @@ import { GetStaticProps, GetStaticPropsResult } from 'next';
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);
@@ -28,15 +30,29 @@ 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 (
<Layout
tableOfContents={tableOfContents}
title={meta.title}
sidebarTree={sidebarTree}
urlPath={meta.urlPath}
>
<MDXPage source={source} frontMatter={meta} />
</Layout>
<>
<JSONLD meta={meta} source={source.compiledSource} />
<BreadcrumbJsonLd itemListElements={breadcrumbs} />
<Layout
tableOfContents={tableOfContents}
title={meta.title}
description={meta.description}
sidebarTree={sidebarTree}
urlPath={meta.urlPath}
>
<MDXPage source={source} frontMatter={meta} />
</Layout>
</>
);
}

View File

@@ -47,7 +47,12 @@ function MyApp({ Component, pageProps }) {
defaultTheme={siteConfig.theme.default}
forcedTheme={siteConfig.theme.default ? null : 'light'}
>
<DefaultSeo defaultTitle={siteConfig.title} {...siteConfig.nextSeo} />
<DefaultSeo
defaultTitle={siteConfig.title}
description={siteConfig.description}
titleTemplate="PortalJS - %s"
{...siteConfig.nextSeo}
/>
{/* Global Site Tag (gtag.js) - Google Analytics */}
{siteConfig.analytics && (
@@ -58,7 +63,7 @@ function MyApp({ Component, pageProps }) {
/>
<Script
id="gtag-init"
strategy="afterInteractive"
strategy="lazyOnload"
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];

13
site/pages/_document.tsx Normal file
View File

@@ -0,0 +1,13 @@
import { Html, Head, Main, NextScript } from 'next/document';
export default function Document() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}

View File

@@ -3,10 +3,15 @@ import computeFields from '@/lib/computeFields';
import clientPromise from '@/lib/mddb';
import { BlogsList, SimpleLayout } from '@portaljs/core';
import * as fs from 'fs';
import { NextSeo } from 'next-seo';
export default function Blog({ blogs }) {
return (
<>
<NextSeo
title="Blog posts"
description="Find news and more information about rapidly building rich data portals using a modern frontend framework in the PortalJS blog"
/>
<Layout>
<SimpleLayout title="Blog posts">
<BlogsList blogs={blogs} />
@@ -48,12 +53,9 @@ export async function getStaticProps() {
const blogList = await Promise.all(blogsWithComputedFields);
const blogsSorted = blogList.sort(
(a, b) =>
new Date(b?.date).getTime() -
new Date(a?.date).getTime()
(a, b) => new Date(b?.date).getTime() - new Date(a?.date).getTime()
);
return {
props: {
blogs: blogsSorted,

View File

@@ -8,6 +8,7 @@ import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import { collectHeadings } from '@portaljs/core';
import Head from 'next/head';
import { LogoJsonLd } from 'next-seo';
export default function Home({ sidebarTree }) {
const router = useRouter();
@@ -24,6 +25,10 @@ export default function Home({ sidebarTree }) {
return (
<>
<LogoJsonLd
url="https://portaljs.org"
logo="https://portaljs.org/icon.png"
/>
<Layout
isHomePage={true}
tableOfContents={tableOfContents}

BIN
site/public/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,4 +1,4 @@
@import "@portaljs/remark-callouts/styles.css";
@import '@portaljs/remark-callouts/styles.css';
@import './prism.css';
html,
@@ -31,7 +31,7 @@ html {
/* tooltip fade-out clip */
.tooltip-body::after {
content: "";
content: '';
position: absolute;
right: 0;
top: 3.6rem; /* multiple of $line-height used on the tooltip body (defined in tooltipBodyStyle) */

View File

@@ -15,10 +15,10 @@
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@portaljs/core": ["packages/core/src/index.ts"],
"@portaljs/portaljs-components": [
"packages/portaljs-components/src/index.ts"
],
"@portaljs/core": ["packages/core/src/index.ts"]
]
}
},
"exclude": ["node_modules", "tmp"]