diff --git a/.idea/frontmatter.iml b/.idea/frontmatter.iml
index a7e30229f..7a8edeeaf 100644
--- a/.idea/frontmatter.iml
+++ b/.idea/frontmatter.iml
@@ -6,6 +6,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/packages/crypto-frontmatter/package.json b/packages/crypto-frontmatter/package.json
index 4e1ee9e78..47af774fd 100644
--- a/packages/crypto-frontmatter/package.json
+++ b/packages/crypto-frontmatter/package.json
@@ -5,8 +5,20 @@
"repository": {
"url": "git+https://github.com/levaintech/frontmatter"
},
- "main": "./dist/index.js",
- "types": "./dist/index.d.ts",
+ "exports": {
+ ".": "./dist/index.js",
+ "./*": "./dist/*.js"
+ },
+ "typesVersions": {
+ "*": {
+ "index.d.ts": [
+ "dist/index.d.ts"
+ ],
+ "*": [
+ "dist/*"
+ ]
+ }
+ },
"files": [
"dist"
],
diff --git a/packages/crypto-frontmatter/src/caip19.ts b/packages/crypto-frontmatter/src/caip19.ts
new file mode 100644
index 000000000..4ea06f1c9
--- /dev/null
+++ b/packages/crypto-frontmatter/src/caip19.ts
@@ -0,0 +1,9 @@
+/**
+ * Decode CAIP-19 into CAIP-2, Asset TYPE, and Asset REFERENCE
+ * @return {[string, string, string]}
+ */
+export function decodeCaip19(caip19: string): string[] {
+ const [caip2, asset] = caip19.split('/');
+ const [type, reference] = asset.split(':');
+ return [caip2, type, reference];
+}
diff --git a/packages/crypto-frontmatter/src/content.ts b/packages/crypto-frontmatter/src/content.ts
new file mode 100644
index 000000000..0f987766d
--- /dev/null
+++ b/packages/crypto-frontmatter/src/content.ts
@@ -0,0 +1,43 @@
+import { readFile } from 'fs/promises';
+import { join } from 'path';
+
+import { decodeCaip19 } from './caip19';
+import { FrontmatterIndex, getFrontmatterCollection } from './index';
+
+export interface FrontmatterContent extends FrontmatterIndex {
+ html: string;
+}
+
+/**
+ * Get FrontmatterContent using CAIP-19, returns undefined if not found
+ * This includes the HTML content of the Frontmatter.
+ *
+ * @param caip19 {string}
+ * @see FrontmatterContent.html
+ * @return {FrontmatterContent | undefined}
+ */
+export async function getFrontmatterContent(caip19: string): Promise {
+ const [caip2, type, reference] = decodeCaip19(caip19);
+ const collection = getFrontmatterCollection(caip2, type);
+ const index = collection.find((value: FrontmatterIndex) => {
+ const [, , aReference] = decodeCaip19(value.path);
+ return aReference.toLowerCase() === reference.toLowerCase();
+ });
+ if (index === undefined) {
+ return undefined;
+ }
+
+ const [caip2Type, caip2Reference] = caip2.split(':');
+ const path = join(
+ 'node_modules',
+ '@crypto-frontmatter',
+ `${caip2Type}-${caip2Reference}-${type}`,
+ 'dist',
+ 'Frontmatter',
+ `${index.fileId}.json`,
+ );
+ const contents = await readFile(path, {
+ encoding: 'utf-8',
+ });
+ return JSON.parse(contents);
+}
diff --git a/packages/crypto-frontmatter/src/content.unit.ts b/packages/crypto-frontmatter/src/content.unit.ts
new file mode 100644
index 000000000..cfbc1a30a
--- /dev/null
+++ b/packages/crypto-frontmatter/src/content.unit.ts
@@ -0,0 +1,38 @@
+import { expect, it } from '@jest/globals';
+
+import { getFrontmatterContent } from './content';
+
+it('should getFrontmatterContent of eip155:1/erc20:0x00000000008943c65cAf789FFFCF953bE156f6f8', async () => {
+ const frontmatterContent = await getFrontmatterContent('eip155:1/erc20:0x00000000008943c65cAf789FFFCF953bE156f6f8');
+ expect(frontmatterContent).toStrictEqual({
+ fileId: expect.stringMatching(/[0-f]{64}/),
+ type: 'Frontmatter',
+ path: 'eip155:1/erc20:0x00000000008943c65cAf789FFFCF953bE156f6f8',
+ modifiedDate: expect.any(Number),
+ fields: {
+ caip2: 'eip155:1',
+ namespace: 'erc20',
+ title: 'Dharma USD Coin',
+ symbol: 'dUSDC',
+ decimals: 8,
+ links: [
+ {
+ name: 'explorer',
+ url: 'https://etherscan.io/token/0x00000000008943c65cAf789FFFCF953bE156f6f8',
+ },
+ ],
+ images: [
+ {
+ type: 'logo',
+ mine: 'image/png',
+ size: {
+ width: 512,
+ height: 512,
+ },
+ path: expect.stringMatching(/[0-f]{64}\.logo\.png/),
+ },
+ ],
+ },
+ html: 'Dharma USD Coin
',
+ });
+});
diff --git a/packages/crypto-frontmatter/src/frontmatter.ts b/packages/crypto-frontmatter/src/frontmatter.ts
deleted file mode 100644
index d46ba2e1e..000000000
--- a/packages/crypto-frontmatter/src/frontmatter.ts
+++ /dev/null
@@ -1,162 +0,0 @@
-export interface FrontmatterLink {
- name: string;
- url: string;
-}
-
-export interface FrontmatterImage {
- type: string;
- mine: string;
- size: {
- width: number;
- height: number;
- };
- path: string;
-}
-
-export interface FrontmatterIndex {
- path: string;
- fileId: string;
- modifiedDate: number;
- type: string;
- fields: {
- symbol: string;
- decimals: number;
- title?: string;
- description?: string;
- tags?: string[];
- links?: FrontmatterLink[];
- images?: FrontmatterImage[];
- };
-}
-
-export interface FrontmatterContent extends FrontmatterIndex {
- html: string;
-}
-
-export const SupportedCollections = [
- ['eip155:1', 'erc20'],
- ['eip155:10', 'erc20'],
- ['eip155:56', 'erc20'],
- ['eip155:137', 'erc20'],
- ['eip155:8453', 'erc20'],
- ['eip155:42161', 'erc20'],
- ['eip155:42220', 'erc20'],
- ['eip155:43114', 'erc20'],
- ['eip155:1313161554', 'erc20'],
-];
-
-/**
- * Decode CAIP-19 into CAIP-2, Asset TYPE, and Asset REFERENCE
- * @return {[string, string, string]}
- */
-export function decodeCaip19(caip19: string): string[] {
- const [caip2, asset] = caip19.split('/');
- const [type, reference] = asset.split(':');
- return [caip2, type, reference];
-}
-
-/**
- * Statically import (via CJS require) @crypto-frontmatter module with CAIP-2 and Asset TYPE
- * This is a workaround to allow dynamic import of @crypto-frontmatter module for use within webpack.
- *
- * All @crypto-frontmatter modules are statically mapped here and must be installed as a project dependency
- * if you want to use it.
- * For example, you must install @crypto-frontmatter/eip155-1-erc20 if you want to use eip155:1/erc frontmatter.
- *
- * @param caip2 {string}
- * @param type {string}
- * @param path {string}
- * @return {any}
- */
-export function requireCryptoFrontmatter(caip2: string, type: string, path: string): any {
- /* eslint-disable no-undef */
- switch (`${caip2}/${type}`) {
- case 'eip155:1/erc20':
- return require('@crypto-frontmatter/eip155-1-erc20/dist/Frontmatter/' + path);
- case 'eip155:10/erc20':
- return require('@crypto-frontmatter/eip155-10-erc20/dist/Frontmatter/' + path);
- case 'eip155:56/erc20':
- return require('@crypto-frontmatter/eip155-56-erc20/dist/Frontmatter/' + path);
- case 'eip155:137/erc20':
- return require('@crypto-frontmatter/eip155-137-erc20/dist/Frontmatter/' + path);
- case 'eip155:8453/erc20':
- return require('@crypto-frontmatter/eip155-8453-erc20/dist/Frontmatter/' + path);
- case 'eip155:42161/erc20':
- return require('@crypto-frontmatter/eip155-42161-erc20/dist/Frontmatter/' + path);
- case 'eip155:42220/erc20':
- return require('@crypto-frontmatter/eip155-42220-erc20/dist/Frontmatter/' + path);
- case 'eip155:43114/erc20':
- return require('@crypto-frontmatter/eip155-43114-erc20/dist/Frontmatter/' + path);
- case 'eip155:1313161554/erc20':
- return require('@crypto-frontmatter/eip155-1313161554-erc20/dist/Frontmatter/' + path);
- default:
- throw new Error(`Unknown CAIP-2: ${caip2} and Asset TYPE: ${type}`);
- }
- /* eslint-enable no-undef */
-}
-
-/**
- * Get FrontmatterIndex collection of CAIP-2 and Asset TYPE
- * @param caip2 {string}
- * @param type {string}
- * @return {FrontmatterIndex[]}
- */
-export function getFrontmatterCollection(caip2: string, type: string): FrontmatterIndex[] {
- return requireCryptoFrontmatter(caip2, type, 'index.json');
-}
-
-/**
- * Get a single FrontmatterIndex using CAIP-19, returns undefined if not found
- * @param caip19 {string}
- * @return {FrontmatterIndex | undefined}
- */
-export function getFrontmatterIndex(caip19: string): FrontmatterIndex | undefined {
- const [caip2, type, reference] = decodeCaip19(caip19);
- const collection = getFrontmatterCollection(caip2, type);
- const index = collection.find((value: FrontmatterIndex) => {
- const [, , aReference] = decodeCaip19(value.path);
- return aReference.toLowerCase() === reference.toLowerCase();
- });
- if (index === undefined) {
- return undefined;
- }
-
- // Remove unused fields
- return {
- path: index.path,
- fileId: index.fileId,
- modifiedDate: index.modifiedDate,
- type: index.type,
- fields: index.fields,
- };
-}
-
-/**
- * Get FrontmatterContent using CAIP-19, returns undefined if not found
- * This includes the HTML content of the Frontmatter.
- *
- * @param caip19 {string}
- * @see FrontmatterContent.html
- * @return {FrontmatterContent | undefined}
- */
-export function getFrontmatterContent(caip19: string): FrontmatterContent | undefined {
- const [caip2, type, reference] = decodeCaip19(caip19);
- const collection = getFrontmatterCollection(caip2, type);
- const index = collection.find((value: FrontmatterIndex) => {
- const [, , aReference] = decodeCaip19(value.path);
- return aReference.toLowerCase() === reference.toLowerCase();
- });
- if (index === undefined) {
- return undefined;
- }
-
- const content = requireCryptoFrontmatter(caip2, type, index.fileId + '.json');
- return {
- path: content.path,
- fileId: content.fileId,
- modifiedDate: content.modifiedDate,
- type: content.type,
- fields: content.fields,
- html: content.html,
- };
-}
diff --git a/packages/crypto-frontmatter/src/index.ts b/packages/crypto-frontmatter/src/index.ts
index 146adec57..66ab7747e 100644
--- a/packages/crypto-frontmatter/src/index.ts
+++ b/packages/crypto-frontmatter/src/index.ts
@@ -1 +1,113 @@
-export * from './frontmatter';
+import { decodeCaip19 } from './caip19';
+
+export interface FrontmatterLink {
+ name: string;
+ url: string;
+}
+
+export interface FrontmatterImage {
+ type: string;
+ mine: string;
+ size: {
+ width: number;
+ height: number;
+ };
+ path: string;
+}
+
+export interface FrontmatterIndex {
+ path: string;
+ fileId: string;
+ modifiedDate: number;
+ type: string;
+ fields: {
+ caip2: string;
+ namespace: string;
+ symbol: string;
+ decimals: number;
+ title?: string;
+ description?: string;
+ tags?: string[];
+ links?: FrontmatterLink[];
+ images?: FrontmatterImage[];
+ };
+}
+
+export const SupportedCollections = [
+ ['eip155:1', 'erc20'],
+ ['eip155:10', 'erc20'],
+ ['eip155:56', 'erc20'],
+ ['eip155:137', 'erc20'],
+ ['eip155:8453', 'erc20'],
+ ['eip155:42161', 'erc20'],
+ ['eip155:42220', 'erc20'],
+ ['eip155:43114', 'erc20'],
+ ['eip155:1313161554', 'erc20'],
+];
+
+/**
+ * Statically import (via CJS require) @crypto-frontmatter module with CAIP-2 and Asset TYPE
+ * This is a workaround to allow dynamic import of @crypto-frontmatter module for use within webpack.
+ *
+ * All @crypto-frontmatter modules are statically mapped here and must be installed as a project dependency
+ * if you want to use it.
+ * For example, you must install @crypto-frontmatter/eip155-1-erc20 if you want to use eip155:1/erc frontmatter.
+ *
+ * @param caip2 {string}
+ * @param type {string}
+ * @param path {string}
+ * @return {any}
+ */
+export function requireCryptoFrontmatter(caip2: string, type: string, path: string): any {
+ /* eslint-disable no-undef */
+ switch (`${caip2}/${type}`) {
+ case 'eip155:1/erc20':
+ return require('@crypto-frontmatter/eip155-1-erc20/dist/Frontmatter/' + path);
+ case 'eip155:10/erc20':
+ return require('@crypto-frontmatter/eip155-10-erc20/dist/Frontmatter/' + path);
+ case 'eip155:56/erc20':
+ return require('@crypto-frontmatter/eip155-56-erc20/dist/Frontmatter/' + path);
+ case 'eip155:137/erc20':
+ return require('@crypto-frontmatter/eip155-137-erc20/dist/Frontmatter/' + path);
+ case 'eip155:8453/erc20':
+ return require('@crypto-frontmatter/eip155-8453-erc20/dist/Frontmatter/' + path);
+ case 'eip155:42161/erc20':
+ return require('@crypto-frontmatter/eip155-42161-erc20/dist/Frontmatter/' + path);
+ case 'eip155:42220/erc20':
+ return require('@crypto-frontmatter/eip155-42220-erc20/dist/Frontmatter/' + path);
+ case 'eip155:43114/erc20':
+ return require('@crypto-frontmatter/eip155-43114-erc20/dist/Frontmatter/' + path);
+ case 'eip155:1313161554/erc20':
+ return require('@crypto-frontmatter/eip155-1313161554-erc20/dist/Frontmatter/' + path);
+ default:
+ throw new Error(`Unknown CAIP-2: ${caip2} and Asset TYPE: ${type}`);
+ }
+ /* eslint-enable no-undef */
+}
+
+/**
+ * Get FrontmatterIndex collection of CAIP-2 and Asset TYPE
+ * requireCryptoFrontmatter is used to statically import the `@crypto-frontmatter` module using the Node.JS require
+ * architecture
+ *
+ * @param caip2 {string}
+ * @param type {string}
+ * @return {FrontmatterIndex[]}
+ */
+export function getFrontmatterCollection(caip2: string, type: string): FrontmatterIndex[] {
+ return requireCryptoFrontmatter(caip2, type, 'index.json');
+}
+
+/**
+ * Get a single FrontmatterIndex using CAIP-19, returns undefined if not found
+ * @param caip19 {string}
+ * @return {FrontmatterIndex | undefined}
+ */
+export function getFrontmatterIndex(caip19: string): FrontmatterIndex | undefined {
+ const [caip2, type, reference] = decodeCaip19(caip19);
+ const collection = getFrontmatterCollection(caip2, type);
+ return collection.find((value: FrontmatterIndex) => {
+ const [, , aReference] = decodeCaip19(value.path);
+ return aReference.toLowerCase() === reference.toLowerCase();
+ });
+}
diff --git a/packages/crypto-frontmatter/src/frontmatter.unit.ts b/packages/crypto-frontmatter/src/index.unit.ts
similarity index 56%
rename from packages/crypto-frontmatter/src/frontmatter.unit.ts
rename to packages/crypto-frontmatter/src/index.unit.ts
index c7a7047f1..b164ac6c8 100644
--- a/packages/crypto-frontmatter/src/frontmatter.unit.ts
+++ b/packages/crypto-frontmatter/src/index.unit.ts
@@ -1,6 +1,6 @@
import { expect, it } from '@jest/globals';
-import { getFrontmatterCollection, getFrontmatterContent, getFrontmatterIndex } from './frontmatter';
+import { getFrontmatterCollection, getFrontmatterIndex } from './index';
it('should getFrontmatterCollection of eip155:1/erc20', async () => {
const collection = getFrontmatterCollection('eip155:1', 'erc20');
@@ -23,6 +23,8 @@ it('should getFrontmatterIndex of eip155:1/erc20:0x00000000008943c65cAf789FFFCF9
path: 'eip155:1/erc20:0x00000000008943c65cAf789FFFCF953bE156f6f8',
modifiedDate: expect.any(Number),
fields: {
+ caip2: 'eip155:1',
+ namespace: 'erc20',
title: 'Dharma USD Coin',
symbol: 'dUSDC',
decimals: 8,
@@ -46,36 +48,3 @@ it('should getFrontmatterIndex of eip155:1/erc20:0x00000000008943c65cAf789FFFCF9
},
});
});
-
-it('should getFrontmatterContent of eip155:1/erc20:0x00000000008943c65cAf789FFFCF953bE156f6f8', async () => {
- const frontmatterContent = getFrontmatterContent('eip155:1/erc20:0x00000000008943c65cAf789FFFCF953bE156f6f8');
- expect(frontmatterContent).toStrictEqual({
- fileId: expect.stringMatching(/[0-f]{64}/),
- type: 'Frontmatter',
- path: 'eip155:1/erc20:0x00000000008943c65cAf789FFFCF953bE156f6f8',
- modifiedDate: expect.any(Number),
- fields: {
- title: 'Dharma USD Coin',
- symbol: 'dUSDC',
- decimals: 8,
- links: [
- {
- name: 'explorer',
- url: 'https://etherscan.io/token/0x00000000008943c65cAf789FFFCF953bE156f6f8',
- },
- ],
- images: [
- {
- type: 'logo',
- mine: 'image/png',
- size: {
- width: 512,
- height: 512,
- },
- path: expect.stringMatching(/[0-f]{64}\.logo\.png/),
- },
- ],
- },
- html: 'Dharma USD Coin
',
- });
-});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 32cb3ed9e..6586bd107 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -217,8 +217,8 @@ importers:
specifier: ^1.7.0
version: 1.7.0(react@18.2.0)
next:
- specifier: 14.0.1
- version: 14.0.1(@babel/core@7.23.2)(react-dom@18.2.0)(react@18.2.0)
+ specifier: 14.0.2
+ version: 14.0.2(@babel/core@7.23.2)(react-dom@18.2.0)(react@18.2.0)
react:
specifier: 18.2.0
version: 18.2.0
@@ -293,8 +293,8 @@ importers:
workspace/eslint-config-next:
dependencies:
'@next/eslint-plugin-next':
- specifier: 14.0.1
- version: 14.0.1
+ specifier: 14.0.2
+ version: 14.0.2
eslint-config-prettier:
specifier: ^9.0.0
version: 9.0.0(eslint@8.53.0)
@@ -1071,18 +1071,18 @@ packages:
resolution: {integrity: sha512-n5JEf16Wr4mdkRMZ8wMP/wN9/sHmTjRPbouXjJH371mZ2LEGDl72t8tEsMRNFerQN/QJtivOxqK1frdGa4QK5Q==}
engines: {node: '>=10'}
- /@next/env@14.0.1:
- resolution: {integrity: sha512-Ms8ZswqY65/YfcjrlcIwMPD7Rg/dVjdLapMcSHG26W6O67EJDF435ShW4H4LXi1xKO1oRc97tLXUpx8jpLe86A==}
+ /@next/env@14.0.2:
+ resolution: {integrity: sha512-HAW1sljizEaduEOes/m84oUqeIDAUYBR1CDwu2tobNlNDFP3cSm9d6QsOsGeNlIppU1p/p1+bWbYCbvwjFiceA==}
dev: false
- /@next/eslint-plugin-next@14.0.1:
- resolution: {integrity: sha512-bLjJMwXdzvhnQOnxvHoTTUh/+PYk6FF/DCgHi4BXwXCINer+o1ZYfL9aVeezj/oI7wqGJOqwGIXrlBvPbAId3w==}
+ /@next/eslint-plugin-next@14.0.2:
+ resolution: {integrity: sha512-APrYFsXfAhnysycqxHcpg6Y4i7Ukp30GzVSZQRKT3OczbzkqGjt33vNhScmgoOXYBU1CfkwgtXmNxdiwv1jKmg==}
dependencies:
glob: 7.1.7
dev: false
- /@next/swc-darwin-arm64@14.0.1:
- resolution: {integrity: sha512-JyxnGCS4qT67hdOKQ0CkgFTp+PXub5W1wsGvIq98TNbF3YEIN7iDekYhYsZzc8Ov0pWEsghQt+tANdidITCLaw==}
+ /@next/swc-darwin-arm64@14.0.2:
+ resolution: {integrity: sha512-i+jQY0fOb8L5gvGvojWyZMfQoQtDVB2kYe7fufOEiST6sicvzI2W5/EXo4lX5bLUjapHKe+nFxuVv7BA+Pd7LQ==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
@@ -1090,8 +1090,8 @@ packages:
dev: false
optional: true
- /@next/swc-darwin-x64@14.0.1:
- resolution: {integrity: sha512-625Z7bb5AyIzswF9hvfZWa+HTwFZw+Jn3lOBNZB87lUS0iuCYDHqk3ujuHCkiyPtSC0xFBtYDLcrZ11mF/ap3w==}
+ /@next/swc-darwin-x64@14.0.2:
+ resolution: {integrity: sha512-zRCAO0d2hW6gBEa4wJaLn+gY8qtIqD3gYd9NjruuN98OCI6YyelmhWVVLlREjS7RYrm9OUQIp/iVJFeB6kP1hg==}
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
@@ -1099,8 +1099,8 @@ packages:
dev: false
optional: true
- /@next/swc-linux-arm64-gnu@14.0.1:
- resolution: {integrity: sha512-iVpn3KG3DprFXzVHM09kvb//4CNNXBQ9NB/pTm8LO+vnnnaObnzFdS5KM+w1okwa32xH0g8EvZIhoB3fI3mS1g==}
+ /@next/swc-linux-arm64-gnu@14.0.2:
+ resolution: {integrity: sha512-tSJmiaon8YaKsVhi7GgRizZoV0N1Sx5+i+hFTrCKKQN7s3tuqW0Rov+RYdPhAv/pJl4qiG+XfSX4eJXqpNg3dA==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
@@ -1108,8 +1108,8 @@ packages:
dev: false
optional: true
- /@next/swc-linux-arm64-musl@14.0.1:
- resolution: {integrity: sha512-mVsGyMxTLWZXyD5sen6kGOTYVOO67lZjLApIj/JsTEEohDDt1im2nkspzfV5MvhfS7diDw6Rp/xvAQaWZTv1Ww==}
+ /@next/swc-linux-arm64-musl@14.0.2:
+ resolution: {integrity: sha512-dXJLMSEOwqJKcag1BeX1C+ekdPPJ9yXbWIt3nAadhbLx5CjACoB2NQj9Xcqu2tmdr5L6m34fR+fjGPs+ZVPLzA==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
@@ -1117,8 +1117,8 @@ packages:
dev: false
optional: true
- /@next/swc-linux-x64-gnu@14.0.1:
- resolution: {integrity: sha512-wMqf90uDWN001NqCM/auRl3+qVVeKfjJdT9XW+RMIOf+rhUzadmYJu++tp2y+hUbb6GTRhT+VjQzcgg/QTD9NQ==}
+ /@next/swc-linux-x64-gnu@14.0.2:
+ resolution: {integrity: sha512-WC9KAPSowj6as76P3vf1J3mf2QTm3Wv3FBzQi7UJ+dxWjK3MhHVWsWUo24AnmHx9qDcEtHM58okgZkXVqeLB+Q==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
@@ -1126,8 +1126,8 @@ packages:
dev: false
optional: true
- /@next/swc-linux-x64-musl@14.0.1:
- resolution: {integrity: sha512-ol1X1e24w4j4QwdeNjfX0f+Nza25n+ymY0T2frTyalVczUmzkVD7QGgPTZMHfR1aLrO69hBs0G3QBYaj22J5GQ==}
+ /@next/swc-linux-x64-musl@14.0.2:
+ resolution: {integrity: sha512-KSSAwvUcjtdZY4zJFa2f5VNJIwuEVnOSlqYqbQIawREJA+gUI6egeiRu290pXioQXnQHYYdXmnVNZ4M+VMB7KQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
@@ -1135,8 +1135,8 @@ packages:
dev: false
optional: true
- /@next/swc-win32-arm64-msvc@14.0.1:
- resolution: {integrity: sha512-WEmTEeWs6yRUEnUlahTgvZteh5RJc4sEjCQIodJlZZ5/VJwVP8p2L7l6VhzQhT4h7KvLx/Ed4UViBdne6zpIsw==}
+ /@next/swc-win32-arm64-msvc@14.0.2:
+ resolution: {integrity: sha512-2/O0F1SqJ0bD3zqNuYge0ok7OEWCQwk55RPheDYD0va5ij7kYwrFkq5ycCRN0TLjLfxSF6xI5NM6nC5ux7svEQ==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [win32]
@@ -1144,8 +1144,8 @@ packages:
dev: false
optional: true
- /@next/swc-win32-ia32-msvc@14.0.1:
- resolution: {integrity: sha512-oFpHphN4ygAgZUKjzga7SoH2VGbEJXZa/KL8bHCAwCjDWle6R1SpiGOdUdA8EJ9YsG1TYWpzY6FTbUA+iAJeww==}
+ /@next/swc-win32-ia32-msvc@14.0.2:
+ resolution: {integrity: sha512-vJI/x70Id0oN4Bq/R6byBqV1/NS5Dl31zC+lowO8SDu1fHmUxoAdILZR5X/sKbiJpuvKcCrwbYgJU8FF/Gh50Q==}
engines: {node: '>= 10'}
cpu: [ia32]
os: [win32]
@@ -1153,8 +1153,8 @@ packages:
dev: false
optional: true
- /@next/swc-win32-x64-msvc@14.0.1:
- resolution: {integrity: sha512-FFp3nOJ/5qSpeWT0BZQ+YE1pSMk4IMpkME/1DwKBwhg4mJLB9L+6EXuJi4JEwaJdl5iN+UUlmUD3IsR1kx5fAg==}
+ /@next/swc-win32-x64-msvc@14.0.2:
+ resolution: {integrity: sha512-Ut4LXIUvC5m8pHTe2j0vq/YDnTEyq6RSR9vHYPqnELrDapPhLNz9Od/L5Ow3J8RNDWpEnfCiQXuVdfjlNEJ7ug==}
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
@@ -4987,8 +4987,8 @@ packages:
/natural-compare@1.4.0:
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
- /next@14.0.1(@babel/core@7.23.2)(react-dom@18.2.0)(react@18.2.0):
- resolution: {integrity: sha512-s4YaLpE4b0gmb3ggtmpmV+wt+lPRuGtANzojMQ2+gmBpgX9w5fTbjsy6dXByBuENsdCX5pukZH/GxdFgO62+pA==}
+ /next@14.0.2(@babel/core@7.23.2)(react-dom@18.2.0)(react@18.2.0):
+ resolution: {integrity: sha512-jsAU2CkYS40GaQYOiLl9m93RTv2DA/tTJ0NRlmZIBIL87YwQ/xR8k796z7IqgM3jydI8G25dXvyYMC9VDIevIg==}
engines: {node: '>=18.17.0'}
hasBin: true
peerDependencies:
@@ -5002,7 +5002,7 @@ packages:
sass:
optional: true
dependencies:
- '@next/env': 14.0.1
+ '@next/env': 14.0.2
'@swc/helpers': 0.5.2
busboy: 1.6.0
caniuse-lite: 1.0.30001561
@@ -5012,15 +5012,15 @@ packages:
styled-jsx: 5.1.1(@babel/core@7.23.2)(react@18.2.0)
watchpack: 2.4.0
optionalDependencies:
- '@next/swc-darwin-arm64': 14.0.1
- '@next/swc-darwin-x64': 14.0.1
- '@next/swc-linux-arm64-gnu': 14.0.1
- '@next/swc-linux-arm64-musl': 14.0.1
- '@next/swc-linux-x64-gnu': 14.0.1
- '@next/swc-linux-x64-musl': 14.0.1
- '@next/swc-win32-arm64-msvc': 14.0.1
- '@next/swc-win32-ia32-msvc': 14.0.1
- '@next/swc-win32-x64-msvc': 14.0.1
+ '@next/swc-darwin-arm64': 14.0.2
+ '@next/swc-darwin-x64': 14.0.2
+ '@next/swc-linux-arm64-gnu': 14.0.2
+ '@next/swc-linux-arm64-musl': 14.0.2
+ '@next/swc-linux-x64-gnu': 14.0.2
+ '@next/swc-linux-x64-musl': 14.0.2
+ '@next/swc-win32-arm64-msvc': 14.0.2
+ '@next/swc-win32-ia32-msvc': 14.0.2
+ '@next/swc-win32-x64-msvc': 14.0.2
transitivePeerDependencies:
- '@babel/core'
- babel-plugin-macros
@@ -5992,8 +5992,8 @@ packages:
engines: {node: '>=10.0.0'}
dev: false
- /streamx@2.15.2:
- resolution: {integrity: sha512-b62pAV/aeMjUoRN2C/9F0n+G8AfcJjNC0zw/ZmOHeFsIe4m4GzjVW9m6VHXVjk536NbdU9JRwKMJRfkc+zUFTg==}
+ /streamx@2.15.3:
+ resolution: {integrity: sha512-8UmzFRA08VahBuaw6UxQAX+NAmMtPVkPDWUtLhyHRaU2uxiw3+keTuSJRJfAfpqo7M3TSAhYtdRzYqG/j02hzA==}
dependencies:
fast-fifo: 1.3.2
queue-tick: 1.0.1
@@ -6248,7 +6248,7 @@ packages:
dependencies:
b4a: 1.6.4
fast-fifo: 1.3.2
- streamx: 2.15.2
+ streamx: 2.15.3
dev: false
/test-exclude@6.0.0:
diff --git a/website/app/[caip2]/[asset]/page.tsx b/website/app/[caip2]/[asset]/page.tsx
index b135646d5..f8920dabd 100644
--- a/website/app/[caip2]/[asset]/page.tsx
+++ b/website/app/[caip2]/[asset]/page.tsx
@@ -1,11 +1,10 @@
import {
- decodeCaip19,
FrontmatterIndex,
getFrontmatterCollection,
- getFrontmatterContent,
getFrontmatterIndex,
SupportedCollections,
} from 'crypto-frontmatter';
+import { getFrontmatterContent } from 'crypto-frontmatter/content';
import { Metadata } from 'next';
import { notFound } from 'next/navigation';
import type { ReactElement } from 'react';
@@ -21,11 +20,8 @@ function asCaip19(caip2: string, asset: string): string {
export async function generateStaticParams(): Promise[0]['params'][]> {
return SupportedCollections.flatMap(([caip2, type]) => {
return getFrontmatterCollection(caip2, type).map((frontmatter) => {
- const [caip2, type, reference] = decodeCaip19(frontmatter.path);
- return {
- caip2,
- asset: `${type}:${reference}`,
- };
+ const [caip2, asset] = frontmatter.path.split('/');
+ return { caip2, asset };
});
});
}
@@ -62,7 +58,7 @@ export default async function Page(props: {
};
}): Promise {
const caip19 = asCaip19(props.params.caip2, props.params.asset);
- const frontmatterContent = getFrontmatterContent(caip19);
+ const frontmatterContent = await getFrontmatterContent(caip19);
if (frontmatterContent === undefined) {
return notFound();
}
diff --git a/website/components/contented/FrontmatterImage.tsx b/website/components/contented/FrontmatterImage.tsx
index 48c9b707d..6dd198120 100644
--- a/website/components/contented/FrontmatterImage.tsx
+++ b/website/components/contented/FrontmatterImage.tsx
@@ -1,5 +1,5 @@
'use client';
-import { decodeCaip19, FrontmatterIndex, requireCryptoFrontmatter } from 'crypto-frontmatter';
+import { FrontmatterIndex, requireCryptoFrontmatter } from 'crypto-frontmatter';
import Image from 'next/image';
import type { ReactElement } from 'react';
@@ -9,10 +9,9 @@ export function FrontmatterImage(props: { frontmatter: FrontmatterIndex; type: '
return <>>;
}
- const [caip2, type] = decodeCaip19(props.frontmatter.path);
return (
{
const reference = filePath.replace(/\/README\.md$/, '');
const caip19 = `${options.caip2}/${options.namespace}:${reference}`;
+ // Remove all non-essential fields
return {
- ...fileContent,
+ path: caip19,
+ fileId: fileContent.fileId,
+ modifiedDate: fileContent.modifiedDate,
+ type: fileContent.type,
fields: {
...fileContent.fields,
+ caip2: options.caip2,
+ namespace: options.namespace,
images: await computeImageField(fileContent, filePath),
},
- path: caip19,
- sections: [],
- headings: [],
+ html: fileContent.html,
};
},
},
diff --git a/workspace/contented-config/package.json b/workspace/contented-config/package.json
index a9655f8a6..e227c6141 100644
--- a/workspace/contented-config/package.json
+++ b/workspace/contented-config/package.json
@@ -3,6 +3,9 @@
"private": true,
"type": "module",
"main": "./index.mjs",
+ "scripts": {
+ "build": ""
+ },
"dependencies": {
"@contentedjs/contented": "^7.1.0",
"@contentedjs/contented-pipeline-md": "^7.1.0",
diff --git a/workspace/contented-config/turbo.json b/workspace/contented-config/turbo.json
new file mode 100644
index 000000000..2f05429e5
--- /dev/null
+++ b/workspace/contented-config/turbo.json
@@ -0,0 +1,9 @@
+{
+ "$schema": "https://turborepo.org/schema.json",
+ "extends": ["//"],
+ "pipeline": {
+ "build": {
+ "inputs": ["index.mjs"]
+ }
+ }
+}
diff --git a/workspace/eslint-config-next/package.json b/workspace/eslint-config-next/package.json
index 14b91dcc8..0fd084028 100644
--- a/workspace/eslint-config-next/package.json
+++ b/workspace/eslint-config-next/package.json
@@ -3,7 +3,7 @@
"private": true,
"main": "./index.js",
"dependencies": {
- "@next/eslint-plugin-next": "14.0.1",
+ "@next/eslint-plugin-next": "14.0.2",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-react": "^7.33.2",