Skip to content

Commit

Permalink
feat: change json file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
xrz-cloud committed Aug 12, 2024
1 parent 64db845 commit 25ea92b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
22 changes: 13 additions & 9 deletions docs/time.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ export interface Data {
src_update: Date;
}

const timeGetter = async () => {
return {
build: new Date(),
src_update: await fetch(
"https://api.github.com/repos/bili-vd-bak/aniclip-src"
)
.then((res) => res.json())
.then((res) => res.updated_at),
};
};

declare const data: Data;
export { data };
export { data, timeGetter };

export default defineLoader({
async load() {
return {
build: new Date(),
src_update: await fetch(
"https://api.github.com/repos/bili-vd-bak/aniclip-src"
)
.then((res) => res.json())
.then((res) => res.updated_at),
};
return timeGetter();
},
});
20 changes: 14 additions & 6 deletions docs/timeline/toml.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import * as toml from "@std/toml";
import { defineLoader } from "vitepress";
import path from "path";

import typeTrans from "../utils/typeTrans.ts";
import validName from "../utils/get-valid-name.ts";
import typeTrans from "../utils/typeTrans";
import validName from "../utils/get-valid-name";
import ssRealGen from "../utils/ss-real-gen";
import ffmpegCommandGen from "../utils/ffmpeg-command-gen";
import rootDir from "app-root-path";
import { timeGetter } from "../time.data";

const times = await timeGetter();

type t = "v_l" | "v_c" | "s_l" | "s_c" | "s_e" | "a_l";

Expand Down Expand Up @@ -177,23 +180,28 @@ export function preGen(list: { [key: string]: Data[] }) {
}
});
}
return list;
return { times, data: list };
}

function preGen2File(list: { [key: string]: Data[] }) {
const gened_list = preGen(list);
const gened_data = preGen(list),
gened_list = gened_data.data;
// fs.writeJsonSync(path.resolve(rootDir.path, "src/data.json"), preGen(gened_list));
fs.mkdirpSync(path.resolve(rootDir.path, "docs/public"));
fs.writeJsonSync(
path.resolve(rootDir.path, "docs/public/data.json"),
gened_list
gened_data
);
fs.removeSync(path.resolve(rootDir.path, "docs/public/timeline"));
fs.mkdirpSync(path.resolve(rootDir.path, "docs/public/timeline"));
for (const [time, ss] of Object.entries(gened_list)) {
fs.writeJsonSync(
path.resolve(rootDir.path, `docs/public/timeline/${time}.json`),
{ [time]: ss }
{ times, data: { [time]: ss } }
);
}
fs.copySync(
path.resolve(rootDir.path, "docs/public/timeline/AutoSyncLatest.json"),
path.resolve(rootDir.path, "docs/public/timeline/ASL.json")
);
}

0 comments on commit 25ea92b

Please sign in to comment.