Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(website/resources): make downloadable
Elian Doran6c504eeb3eba
diff --git a/apps/icon-pack-builder/src/index.ts b/apps/icon-pack-builder/src/index.tsindex b97df2b5a7..0df1b77338 100644--- a/apps/icon-pack-builder/src/index.ts+++ b/apps/icon-pack-builder/src/index.ts@@ -13,7 +13,7 @@ process.env.TRILIUM_RESOURCE_DIR = "../server/src";process.env.NODE_ENV = "development";async function main() {- const outputDir = join(__dirname, "../../website/src/assets/resources/icon-packs");+ const outputDir = join(__dirname, "../../website/public/resources/icon-packs");mkdirSync(outputDir, { recursive: true });const i18n = await import("@triliumnext/server/src/services/i18n.js");@@ -49,7 +49,8 @@ async function main() {});// Export to zip.- const zipFilePath = join(outputDir, `${iconPack.name}.zip`);+ const zipFileName = `${iconPack.name}.zip`;+ const zipFilePath = join(outputDir, zipFileName);const fileOutputStream = createWriteStream(zipFilePath);const { exportToZip } = (await import("@triliumnext/server/src/services/export/zip.js")).default;const taskContext = new (await import("@triliumnext/server/src/services/task_context.js")).default(@@ -62,6 +63,7 @@ async function main() {const metaFilePath = join(outputDir, `${iconPack.name}.json`);writeFileSync(metaFilePath, JSON.stringify({name: iconPack.name,+ file: zipFileName,...iconPack.meta}, null, 2));diff --git a/apps/website/src/assets/resources/icon-packs/Boxicons 3 (Basic).json b/apps/website/public/resources/icon-packs/Boxicons 3 (Basic).jsonsimilarity index 71%rename from apps/website/src/assets/resources/icon-packs/Boxicons 3 (Basic).jsonrename to apps/website/public/resources/icon-packs/Boxicons 3 (Basic).jsonindex 8a1f01d2b0..ad22a7e06c 100644--- a/apps/website/src/assets/resources/icon-packs/Boxicons 3 (Basic).json+++ b/apps/website/public/resources/icon-packs/Boxicons 3 (Basic).json@@ -1,5 +1,6 @@{"name": "Boxicons 3 (Basic)",+ "file": "Boxicons 3 (Basic).zip","version": "3.0.0","website": "https://boxicons.com/"}\ No newline at end of filediff --git a/apps/website/src/assets/resources/icon-packs/Boxicons 3 (Basic).zip b/apps/website/public/resources/icon-packs/Boxicons 3 (Basic).zipsimilarity index 99%rename from apps/website/src/assets/resources/icon-packs/Boxicons 3 (Basic).ziprename to apps/website/public/resources/icon-packs/Boxicons 3 (Basic).zipindex 50037259cd..37ccc87408 100644Binary files a/apps/website/src/assets/resources/icon-packs/Boxicons 3 (Basic).zip and b/apps/website/public/resources/icon-packs/Boxicons 3 (Basic).zip differdiff --git a/apps/website/src/assets/resources/icon-packs/Boxicons 3 (Brands).json b/apps/website/public/resources/icon-packs/Boxicons 3 (Brands).jsonsimilarity index 71%rename from apps/website/src/assets/resources/icon-packs/Boxicons 3 (Brands).jsonrename to apps/website/public/resources/icon-packs/Boxicons 3 (Brands).jsonindex c56f2e7315..b77f2b42ab 100644--- a/apps/website/src/assets/resources/icon-packs/Boxicons 3 (Brands).json+++ b/apps/website/public/resources/icon-packs/Boxicons 3 (Brands).json@@ -1,5 +1,6 @@{"name": "Boxicons 3 (Brands)",+ "file": "Boxicons 3 (Brands).zip","version": "3.0.0","website": "https://boxicons.com/"}\ No newline at end of filediff --git a/apps/website/src/assets/resources/icon-packs/Boxicons 3 (Brands).zip b/apps/website/public/resources/icon-packs/Boxicons 3 (Brands).zipsimilarity index 98%rename from apps/website/src/assets/resources/icon-packs/Boxicons 3 (Brands).ziprename to apps/website/public/resources/icon-packs/Boxicons 3 (Brands).zipindex 51b0ca1fd6..1949fc11f1 100644Binary files a/apps/website/src/assets/resources/icon-packs/Boxicons 3 (Brands).zip and b/apps/website/public/resources/icon-packs/Boxicons 3 (Brands).zip differdiff --git a/apps/website/src/assets/resources/icon-packs/Material Design Icons.json b/apps/website/public/resources/icon-packs/Material Design Icons.jsonsimilarity index 74%rename from apps/website/src/assets/resources/icon-packs/Material Design Icons.jsonrename to apps/website/public/resources/icon-packs/Material Design Icons.jsonindex 5accd8fcb7..52d4f7aa98 100644--- a/apps/website/src/assets/resources/icon-packs/Material Design Icons.json+++ b/apps/website/public/resources/icon-packs/Material Design Icons.json@@ -1,5 +1,6 @@{"name": "Material Design Icons",+ "file": "Material Design Icons.zip","version": "7.4.47","website": "https://pictogrammers.com/library/mdi/"}\ No newline at end of filediff --git a/apps/website/src/assets/resources/icon-packs/Material Design Icons.zip b/apps/website/public/resources/icon-packs/Material Design Icons.zipsimilarity index 99%rename from apps/website/src/assets/resources/icon-packs/Material Design Icons.ziprename to apps/website/public/resources/icon-packs/Material Design Icons.zipindex 81f8b2914a..6bdb51ec68 100644Binary files a/apps/website/src/assets/resources/icon-packs/Material Design Icons.zip and b/apps/website/public/resources/icon-packs/Material Design Icons.zip differdiff --git a/apps/website/src/assets/resources/icon-packs/Phosphor Icons (Fill).json b/apps/website/public/resources/icon-packs/Phosphor Icons (Fill).jsonsimilarity index 71%rename from apps/website/src/assets/resources/icon-packs/Phosphor Icons (Fill).jsonrename to apps/website/public/resources/icon-packs/Phosphor Icons (Fill).jsonindex 239fccb3d4..ad99d0784c 100644--- a/apps/website/src/assets/resources/icon-packs/Phosphor Icons (Fill).json+++ b/apps/website/public/resources/icon-packs/Phosphor Icons (Fill).json@@ -1,5 +1,6 @@{"name": "Phosphor Icons (Fill)",+ "file": "Phosphor Icons (Fill).zip","version": "2.1.2","website": "https://phosphoricons.com/"}\ No newline at end of filediff --git a/apps/website/src/assets/resources/icon-packs/Phosphor Icons (Fill).zip b/apps/website/public/resources/icon-packs/Phosphor Icons (Fill).zipsimilarity index 99%rename from apps/website/src/assets/resources/icon-packs/Phosphor Icons (Fill).ziprename to apps/website/public/resources/icon-packs/Phosphor Icons (Fill).zipindex 929822c9ac..cd4a3fbc9d 100644Binary files a/apps/website/src/assets/resources/icon-packs/Phosphor Icons (Fill).zip and b/apps/website/public/resources/icon-packs/Phosphor Icons (Fill).zip differdiff --git a/apps/website/src/assets/resources/icon-packs/Phosphor Icons (Regular).json b/apps/website/public/resources/icon-packs/Phosphor Icons (Regular).jsonsimilarity index 70%rename from apps/website/src/assets/resources/icon-packs/Phosphor Icons (Regular).jsonrename to apps/website/public/resources/icon-packs/Phosphor Icons (Regular).jsonindex bc06402d57..f8a89a1821 100644--- a/apps/website/src/assets/resources/icon-packs/Phosphor Icons (Regular).json+++ b/apps/website/public/resources/icon-packs/Phosphor Icons (Regular).json@@ -1,5 +1,6 @@{"name": "Phosphor Icons (Regular)",+ "file": "Phosphor Icons (Regular).zip","version": "2.1.2","website": "https://phosphoricons.com/"}\ No newline at end of filediff --git a/apps/website/src/assets/resources/icon-packs/Phosphor Icons (Regular).zip b/apps/website/public/resources/icon-packs/Phosphor Icons (Regular).zipsimilarity index 99%rename from apps/website/src/assets/resources/icon-packs/Phosphor Icons (Regular).ziprename to apps/website/public/resources/icon-packs/Phosphor Icons (Regular).zipindex 497ca6b860..67961ceee5 100644Binary files a/apps/website/src/assets/resources/icon-packs/Phosphor Icons (Regular).zip and b/apps/website/public/resources/icon-packs/Phosphor Icons (Regular).zip differdiff --git a/apps/website/src/components/Button.tsx b/apps/website/src/components/Button.tsxindex 3c2c3e455f..3611b93d0a 100644--- a/apps/website/src/components/Button.tsx+++ b/apps/website/src/components/Button.tsx@@ -1,6 +1,8 @@+import "./Button.css";+import { ComponentChildren } from "preact";+import Icon from "./Icon.js";-import "./Button.css";interface LinkProps {className?: string;@@ -9,6 +11,7 @@ interface LinkProps {children?: ComponentChildren;title?: string;onClick?: (e: MouseEvent) => void;+ download?: boolean;}interface ButtonProps extends Omit<LinkProps, "children"> {@@ -16,6 +19,7 @@ interface ButtonProps extends Omit<LinkProps, "children"> {iconSvg?: string;text: ComponentChildren;openExternally?: boolean;+ download?: boolean;outline?: boolean;}@@ -28,17 +32,18 @@ export default function Button({ iconSvg, text, className, outline, ...restProps{iconSvg && <><Icon svg={iconSvg} />{" "}</>}<span class="text">{text}</span></Link>- )+ );}-export function Link({ openExternally, children, ...restProps }: LinkProps) {+export function Link({ openExternally, children, download, ...restProps }: LinkProps) {return (<a{...restProps}- target={openExternally ? "_blank" : undefined}+ target={openExternally || download ? "_blank" : undefined}+ download={download}rel={openExternally ? "noopener noreferrer" : undefined}>{children}</a>- )+ );}diff --git a/apps/website/src/pages/Resources/Resources.css b/apps/website/src/pages/Resources/Resources.cssnew file mode 100644index 0000000000..cab1d5f1ea--- /dev/null+++ b/apps/website/src/pages/Resources/Resources.css@@ -0,0 +1,9 @@+.icon-packs .card-content {+ footer {+ padding: 0;+ border: 0;+ display: flex;+ align-items: center;+ justify-content: space-between;+ }+}diff --git a/apps/website/src/pages/Resources/Resources.tsx b/apps/website/src/pages/Resources/Resources.tsxindex 2c8e369cc5..e40124f971 100644--- a/apps/website/src/pages/Resources/Resources.tsx+++ b/apps/website/src/pages/Resources/Resources.tsx@@ -1,10 +1,13 @@+import "./Resources.css";+import { useTranslation } from "react-i18next";+import Button, { Link } from "../../components/Button";import Card from "../../components/Card";import Section from "../../components/Section";import { usePageTitle } from "../../hooks";-const iconPacksMeta = Object.values(import.meta.glob("../../assets/resources/icon-packs/*.json", {+const iconPacksMeta = Object.values(import.meta.glob("../../../public/resources/icon-packs/*.json", {eager: true}));@@ -13,7 +16,7 @@ export default function Resources() {usePageTitle(t("resources.title"));return (- <Section>+ <Section className="icon-packs"><h2>{t("resources.icon_packs")}</h2><div className="grid-3-cols">@@ -21,8 +24,12 @@ export default function Resources() {<Cardkey={meta.name}title={`${meta.name} ${meta.version}`}- moreInfoUrl={meta.website}- />+ >+ <footer>+ <Button href={`/resources/icon-packs/${meta.file}`} download text="Download" />+ <Link href={meta.website} openExternally>Website</Link>+ </footer>+ </Card>))}</div></Section>