Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vitepress/components/BlogEntry/BlogEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const dateText = new Date(props.date).toLocaleDateString("en-US", {
}"
/>
</a>
<p class="description" v-html="props.description"></p>
<div class="description" v-html="props.description"></div>
<a class="readMore" :href="withBase(props.link)">
Read more
<span class="vpi-arrow-right"></span>
Expand Down
49 changes: 41 additions & 8 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,49 @@ export default defineConfig({
sitemap: {
hostname,
transformItems(items) {
return items.map((item) => {
if (item.url.includes("api/") || item.url.includes("cli/")) {
item = {
...item,
lastmod: undefined
};
function priorityMatch(a: {url: string}, b: {url: string}, matchers: ((url: string) => boolean)[]): number {
for (const matcher of matchers) {
const aMatch = matcher(a.url);
const bMatch = matcher(b.url);

if (aMatch && !bMatch)
return -1;
else if (!aMatch && bMatch)
return 1;
}

return item;
});
return 0;
}

return items
.map((item) => {
if (item.url.startsWith("api/") || item.url.startsWith("cli/")) {
item = {
...item,
lastmod: undefined
};
}

return item;
})
.sort((a, b) => {
return priorityMatch(a, b, [
(url) => url === "",
(url) => url === "blog/",
(url) => url.startsWith("blog/"),
(url) => url === "guide/",
(url) => url.startsWith("guide/"),
(url) => url === "cli/",
(url) => url.startsWith("cli/"),
(url) => url === "api/",
(url) => url.startsWith("api/functions/"),
(url) => url.startsWith("api/classes/"),
(url) => url.startsWith("api/type-aliases/"),
(url) => url.startsWith("api/enumerations/"),
(url) => url.startsWith("api/variables/"),
(url) => url.startsWith("api/")
]);
});
}
},
head: [
Expand Down
20 changes: 13 additions & 7 deletions .vitepress/config/BlogPageInfoPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,19 @@ export function BlogPageInfoPlugin({

let newCode = frontmatterCode + (
"# " + frontmatter.title + "\n\n" +
`<p class="blog-date">${
htmlEscape(new Date(frontmatter.date).toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric"
}))
}</p>`
[
"",
'<script setup lang="ts">',
`const articleDate = new Date(${JSON.stringify(new Date(frontmatter.date).toISOString())}).toLocaleDateString("en-US", {`,
' year: "numeric",',
' month: "long",',
' day: "numeric"',
"});",
"</script>",
"",
'<p class="blog-date">{{ articleDate }}</p>',
""
].join("\n")
);

if (frontmatter.image != null) {
Expand Down
3 changes: 3 additions & 0 deletions llama/addon/globals/addonLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
AddonThreadSafeLogCallbackFunction addonThreadSafeLoggerCallback;
bool addonJsLoggerCallbackSet = false;
int addonLoggerLogLevel = 5;
int addonLastLoggerLogLevel = 6;

static int addonGetGgmlLogLevelNumber(ggml_log_level level) {
switch (level) {
Expand All @@ -13,6 +14,7 @@ static int addonGetGgmlLogLevelNumber(ggml_log_level level) {
case GGML_LOG_LEVEL_INFO: return 4;
case GGML_LOG_LEVEL_NONE: return 5;
case GGML_LOG_LEVEL_DEBUG: return 6;
case GGML_LOG_LEVEL_CONT: return addonLastLoggerLogLevel;
}

return 1;
Expand Down Expand Up @@ -53,6 +55,7 @@ void addonCallJsLogCallback(

void addonLlamaCppLogCallback(ggml_log_level level, const char* text, void* user_data) {
int logLevelNumber = addonGetGgmlLogLevelNumber(level);
addonLastLoggerLogLevel = logLevelNumber;

if (logLevelNumber > addonLoggerLogLevel) {
return;
Expand Down
2 changes: 1 addition & 1 deletion llama/addon/globals/addonLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ using AddonThreadSafeLogCallbackFunction =
Napi::TypedThreadSafeFunction<AddonThreadSafeLogCallbackFunctionContext, addon_logger_log, addonCallJsLogCallback>;

Napi::Value setLogger(const Napi::CallbackInfo& info);
Napi::Value setLoggerLogLevel(const Napi::CallbackInfo& info);
Napi::Value setLoggerLogLevel(const Napi::CallbackInfo& info);
Loading