From d5b87e95ed65f7c011a63f1093fed1f78cb3f040 Mon Sep 17 00:00:00 2001 From: kawarimidoll Date: Tue, 21 Sep 2021 17:05:38 +0900 Subject: [PATCH] fix: could not use dynamic import in deno deploy --- diplodocus.ts | 27 --------------------------- diplodocus.yml | 18 ++++++++++++++++++ docs/docs/02_site_config.md | 17 ++++------------- mod.ts | 9 ++++----- 4 files changed, 26 insertions(+), 45 deletions(-) delete mode 100644 diplodocus.ts create mode 100644 diplodocus.yml diff --git a/diplodocus.ts b/diplodocus.ts deleted file mode 100644 index e2a32bb..0000000 --- a/diplodocus.ts +++ /dev/null @@ -1,27 +0,0 @@ -export default { - "sourceDir": "docs", - "siteName": "Diplodocus", - "description": "Static Asset Server for Deno Deploy", - - "navLinks": [ - { "path": "docs" }, - { "path": "examples" }, - { "path": "lorem" }, - { "path": "acknowledgements" }, - { - "title": "Links", - "items": [ - { - "path": "https://github.com/kawarimidoll/deno-diplodocus", - "title": "GitHub", - }, - { "path": "https://deno.land/x/diplodocus", "title": "deno.land/x" }, - ], - }, - ], - - "listPages": [ - { "title": "Docs", "path": "docs" }, - { "path": "lorem" }, - ], -}; diff --git a/diplodocus.yml b/diplodocus.yml new file mode 100644 index 0000000..a3151f8 --- /dev/null +++ b/diplodocus.yml @@ -0,0 +1,18 @@ +sourceDir: docs +siteName: Diplodocus +description: Static Asset Server for Deno Deploy +navLinks: + - path: docs + - path: examples + - path: lorem + - path: acknowledgements + - title: Links + items: + - path: "https://github.com/kawarimidoll/deno-diplodocus" + title: GitHub + - path: "https://deno.land/x/diplodocus" + title: deno.land/x +listPages: + - title: Docs + path: docs + - path: lorem diff --git a/docs/docs/02_site_config.md b/docs/docs/02_site_config.md index 22c2e25..ccb923f 100644 --- a/docs/docs/02_site_config.md +++ b/docs/docs/02_site_config.md @@ -3,8 +3,8 @@ Diplodocus works without any settings, but there are some configurable options. Diplodocus accepts YAML, JSON or TypeScript configuration files. The file should -be `diplodocus.(yaml|yml|json|ts)` in the same directory with the entry point -file of Deno Deploy such as `server.ts`. +be `diplodocus.(yaml|yml|json)` in the same directory with the entry point file +of Deno Deploy such as `server.ts`. ```sh ├── docs/ @@ -13,7 +13,7 @@ file of Deno Deploy such as `server.ts`. ``` If there are multiple configuration files, Diplodocus will choose one of them by -this priority: (high) `yaml` `yml` `json` `ts` (low). +this priority: (high) `yaml` `yml` `json` (low). ## Format @@ -31,19 +31,10 @@ sourceDir: docs } ``` -### diplodocus.ts - -```ts -export default { - sourceDir: "docs", -}; -``` - ## Available Keys These values below can be used to configure Diplodocus. All of them are -optional. If you use function-type key, the configuration file should be a -TypeScript file. +optional. ### sourceDir diff --git a/mod.ts b/mod.ts index 0db7233..a5028a9 100644 --- a/mod.ts +++ b/mod.ts @@ -138,13 +138,12 @@ export class Diplodocus { files.push(file.name); } console.log(files); - for (const ext of ["yaml", "yml", "json", "ts"]) { + for (const ext of ["yaml", "yml", "json"]) { const configFile = `diplodocus.${ext}`; if (files.includes(configFile)) { - const loadedData = ext === "ts" - ? (await import(`${Deno.cwd()}/${configFile}`)).default - : parseYaml(await Deno.readTextFile(configFile)); - userConfig = loadedData as UserConfig; + userConfig = parseYaml( + await Deno.readTextFile(configFile), + ) as UserConfig; break; } }