μΊμ
Simpesysλ μ΄μ μ μμ±ν λ¬Έμμ HTMLμ μ¬μ¬μ©νλ μ¦λΆ λ λλ§μ μ§μνλ€. μΊμλ₯Ό μ¬μ©νλ©΄ λ΄μ©κ³Ό μ€μ μ΄ κ°μ λ¬Έμμ λν λ λλ§ κ³Όμ μ μλ΅ν¨μΌλ‘μ¨ λΉλ μ±λ₯μ κ°μ ν μ μλ€. μΊμλ κΈ°λ³Έμ μΌλ‘ λΉνμ±νλμ΄ μλ€. init({ cache: true })μ νΈμΆνλ©΄ μΊμλ₯Ό νμ±νν μ μλ€.
κ°μ νλ‘μΈμ€ λ΄μμ λ κ° μ΄μμ Simpesys μΈμ€ν΄μ€ μ¬μ΄μ μΊμλ₯Ό 곡μ νκΈ° μν΄μλ μ΄μ μΈμ€ν΄μ€μ μΊμλ₯Ό μ λ¬νλ©΄ λλ€.
import { Simpesys } from "@simpesys/core";
const first = await new Simpesys().init({ cache: true });
const second = await new Simpesys().init({
cache: {
previous: first.getCache(),
},
});
μ μμλ 첫 λ²μ§Έ μΈμ€ν΄μ€μ μΊμλ₯Ό getCache()λ‘ μ»μ΄ λ λ²μ§Έ μΈμ€ν΄μ€μ cache.previousμ μ λ¬νλ€.
| μ΅μ | νμ | μ€λͺ |
|---|---|---|
cache.version |
string |
μΊμλ₯Ό ꡬλΆνλ λ²μ . |
cache.previous |
Cache |
μ¬μ¬μ©ν μΊμ. |
renderInternalLink, configureMarkdownConverter λ± λ λλ§ ν
μ μ§μ μ§μ ν κ²½μ°μλ μ΄μ μΊμλ₯Ό μ¬μ¬μ©ν λ cache.version κ°μ λͺ
μμ μΌλ‘ μ§μ ν΄μΌ νλ€. ν
μ ꡬνμ λ³κ²½νλ©΄ λ²μ μ κ°±μ νλ€.
await new Simpesys(config).init({
cache: { previous, version: "v2" },
});
νλ‘μΈμ€λ₯Ό μ¬μμνλ©΄ μΈλ©λͺ¨λ¦¬ μΊμλ μ¬λΌμ§λ€. μ ν리μΌμ΄μ μμ μΊμλ₯Ό νμΌμμ€ν μ μ μ₯ν΄λλ©΄ λ€λ₯Έ νλ‘μΈμ€μ μΈμ€ν΄μ€μμ μ¬μ¬μ©ν μ μλ€.
import { type Cache, Simpesys } from "@simpesys/core";
const cacheDirectory = ".simpesys";
const cachePath = `${cacheDirectory}/cache.json`;
let previous: Cache | undefined;
try {
previous = JSON.parse(await Deno.readTextFile(cachePath));
} catch (error) {
if (!(error instanceof Deno.errors.NotFound || error instanceof SyntaxError)) {
throw error;
}
}
const simpesys = await new Simpesys().init({
cache: { previous },
});
const next = simpesys.getCache();
if (next) {
await Deno.mkdir(cacheDirectory, { recursive: true });
await Deno.writeTextFile(cachePath, JSON.stringify(next));
}