2023-06-30 07:29:38 +00:00
|
|
|
import { generateSitemap as sitemap } from "sitemap-ts";
|
2023-06-30 05:17:42 +00:00
|
|
|
import { PageData, defineConfig } from "vitepress";
|
2023-06-23 06:33:04 +00:00
|
|
|
|
2023-06-30 04:11:27 +00:00
|
|
|
const links = [];
|
|
|
|
|
2023-06-30 05:17:42 +00:00
|
|
|
function getJSONLD(pageData: PageData) {
|
|
|
|
if (pageData.relativePath === "index.md") {
|
|
|
|
return `{
|
|
|
|
"@context":"http://schema.org",
|
|
|
|
"@type":"WebSite",
|
|
|
|
"url":"https:\/\/nixos-and-flakes.thiscute.world\/",
|
|
|
|
"inLanguage":"en",
|
2023-06-30 05:26:17 +00:00
|
|
|
"description":"An unofficial and opinionated book for beginners",
|
|
|
|
"name":"${pageData.title}"
|
2023-06-30 05:17:42 +00:00
|
|
|
}`;
|
|
|
|
} else if (pageData.relativePath === "zh/index.md") {
|
|
|
|
return `{
|
|
|
|
"@context":"http://schema.org",
|
|
|
|
"@type":"WebSite",
|
|
|
|
"url":"https:\/\/nixos-and-flakes.thiscute.world\/zh\/",
|
|
|
|
"inLanguage":"zh-CN",
|
|
|
|
"description":"一份非官方的新手指南",
|
2023-06-30 05:26:17 +00:00
|
|
|
"name":"${pageData.title}"
|
2023-06-30 05:17:42 +00:00
|
|
|
}`;
|
|
|
|
} else {
|
2023-06-30 05:26:17 +00:00
|
|
|
let lang = pageData.relativePath.startsWith("zh/") ? "zh-CN" : "en";
|
2023-06-30 05:17:42 +00:00
|
|
|
let url = `https:\/\/nixos-and-flakes.thiscute.world\/${pageData.relativePath
|
2023-06-30 07:29:38 +00:00
|
|
|
.replace(/\.md$/, "")
|
|
|
|
.replace(/\/index\$/, "/")}`;
|
2023-06-30 05:17:42 +00:00
|
|
|
return `{
|
|
|
|
"@context":"http://schema.org",
|
2023-06-30 05:26:17 +00:00
|
|
|
"@type":"TechArticle",
|
|
|
|
"headline":"NixOS & Flakes Book",
|
|
|
|
"inLanguage":"${lang}",
|
2023-06-30 05:17:42 +00:00
|
|
|
"mainEntityOfPage":{
|
|
|
|
"@type":"WebPage",
|
|
|
|
"@id":"${url}"
|
|
|
|
},
|
|
|
|
"keywords":"NixOS, Nix, Flakes, Linux, Tutorial",
|
|
|
|
"url":"${url}"
|
|
|
|
}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-23 06:33:04 +00:00
|
|
|
// https://vitepress.dev/reference/site-config
|
|
|
|
export default defineConfig({
|
2023-06-30 07:29:38 +00:00
|
|
|
// remove trailing `.html`
|
|
|
|
// https://vitepress.dev/guide/routing#generating-clean-url
|
|
|
|
cleanUrls: true,
|
2023-06-30 07:46:12 +00:00
|
|
|
// Whether to get the last updated timestamp for each page using Git.
|
|
|
|
lastUpdated: true,
|
2023-06-30 07:29:38 +00:00
|
|
|
|
2023-06-30 07:46:12 +00:00
|
|
|
// SEO Improvement - sitemap.xml & robots.txt
|
2023-06-30 04:11:27 +00:00
|
|
|
buildEnd: async ({ outDir }) => {
|
2023-06-30 07:29:38 +00:00
|
|
|
sitemap({
|
2023-06-30 04:11:27 +00:00
|
|
|
hostname: "https://nixos-and-flakes.thiscute.world/",
|
2023-06-30 07:29:38 +00:00
|
|
|
outDir: outDir,
|
|
|
|
generateRobotsTxt: true,
|
2023-06-30 04:11:27 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2023-06-30 07:46:12 +00:00
|
|
|
// SEO Improvement - JSON-LD
|
2023-06-30 05:17:42 +00:00
|
|
|
transformPageData(pageData) {
|
|
|
|
return {
|
|
|
|
frontmatter: {
|
|
|
|
...pageData.frontmatter,
|
|
|
|
head: [
|
|
|
|
["script", { type: "application/ld+json" }, getJSONLD(pageData)],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2023-06-30 04:11:27 +00:00
|
|
|
// markdown options
|
2023-06-23 14:41:34 +00:00
|
|
|
markdown: {
|
|
|
|
theme: "material-theme-palenight",
|
|
|
|
lineNumbers: true,
|
|
|
|
|
2023-06-23 17:23:37 +00:00
|
|
|
config: (md) => {
|
2023-06-30 07:46:12 +00:00
|
|
|
// add support for footnote
|
2023-06-23 17:23:37 +00:00
|
|
|
md.use(require("markdown-it-footnote"));
|
2023-06-23 14:41:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-06-30 08:01:57 +00:00
|
|
|
themeConfig: {
|
|
|
|
editLink: {
|
|
|
|
pattern:
|
|
|
|
"https://github.com/ryan4yin/nixos-and-flakes-book/edit/main/docs/:path",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-06-23 06:33:04 +00:00
|
|
|
locales: {
|
|
|
|
root: {
|
|
|
|
label: "English",
|
|
|
|
lang: "en",
|
|
|
|
link: "/",
|
|
|
|
title: "NixOS & Flakes Book",
|
2023-06-28 08:39:02 +00:00
|
|
|
description: "An unofficial and opinionated book for beginners",
|
2023-06-23 10:05:06 +00:00
|
|
|
|
|
|
|
themeConfig: {
|
|
|
|
// https://vitepress.dev/reference/default-theme-config
|
|
|
|
nav: [
|
|
|
|
{ text: "Home", link: "/" },
|
|
|
|
{ text: "Get Started", link: "/introduction/index.md" },
|
2023-06-24 04:47:31 +00:00
|
|
|
{ text: "Best Practices", link: "/best-practices/intro.md" },
|
2023-06-23 10:05:06 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
sidebar: [
|
|
|
|
{
|
|
|
|
text: "Get Started",
|
|
|
|
items: [
|
|
|
|
{ text: "Introduction", link: "/introduction/index.md" },
|
|
|
|
{
|
|
|
|
text: "Advantages and Disadvantages",
|
|
|
|
link: "/introduction/advantages-and-disadvantages.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Installation",
|
|
|
|
link: "/introduction/installation.md",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "The Nix Language",
|
|
|
|
items: [{ text: "Basics", link: "/the-nix-language/index.md" }],
|
|
|
|
},
|
2023-06-23 12:29:12 +00:00
|
|
|
{
|
|
|
|
text: "NixOS with Flakes",
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
text: "Get Started with NixOS",
|
|
|
|
link: "/nixos-with-flakes/get-started-with-nixos.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Introduction to Flakes",
|
|
|
|
link: "/nixos-with-flakes/introduction-to-flakes.md",
|
|
|
|
},
|
|
|
|
{
|
2023-06-23 15:18:01 +00:00
|
|
|
text: "NixOS with Flakes Enabled",
|
|
|
|
link: "/nixos-with-flakes/nixos-with-flakes-enabled.md",
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
2023-06-28 10:09:20 +00:00
|
|
|
text: "Getting Started with Home Manager",
|
2023-06-23 12:29:12 +00:00
|
|
|
link: "/nixos-with-flakes/start-using-home-manager.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Modularize the Configuration",
|
|
|
|
link: "/nixos-with-flakes/modularize-the-configuration.md",
|
|
|
|
},
|
|
|
|
{
|
2023-06-28 10:09:20 +00:00
|
|
|
text: "Updating the System",
|
2023-06-23 12:29:12 +00:00
|
|
|
link: "/nixos-with-flakes/update-the-system.md",
|
|
|
|
},
|
|
|
|
{
|
2023-06-28 10:09:20 +00:00
|
|
|
text: "Downgrading or Upgrading Packages",
|
2023-06-23 15:18:01 +00:00
|
|
|
link: "/nixos-with-flakes/downgrade-or-upgrade-packages.md",
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Other useful Tips",
|
|
|
|
link: "/nixos-with-flakes/other-useful-tips.md",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-06-23 14:19:10 +00:00
|
|
|
{
|
|
|
|
text: "Nixpkgs's Advanced Usage",
|
|
|
|
items: [
|
|
|
|
{ text: "Introduction", link: "/nixpkgs/intro.md" },
|
|
|
|
{ text: "callPackage", link: "/nixpkgs/callpackage.md" },
|
2023-06-23 15:18:01 +00:00
|
|
|
{ text: "Overridding", link: "/nixpkgs/overriding.md" },
|
2023-06-23 14:19:10 +00:00
|
|
|
{ text: "Overlays", link: "/nixpkgs/overlays.md" },
|
|
|
|
],
|
|
|
|
},
|
2023-06-23 14:22:13 +00:00
|
|
|
{
|
|
|
|
text: "Best Practices",
|
|
|
|
items: [
|
|
|
|
{ text: "Introduction", link: "/best-practices/intro.md" },
|
|
|
|
{
|
|
|
|
text: "Run downloaded binaries on NixOS",
|
|
|
|
link: "/best-practices/run-downloaded-binaries-on-nixos.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Simplify NixOS-related Commands",
|
|
|
|
link: "/best-practices/simplify-nixos-related-commands.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Debug with nix repl",
|
|
|
|
link: "/best-practices/debug-with-nix-repl.md",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-06-23 14:41:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
text: "Other Usage of Flakes",
|
|
|
|
items: [
|
|
|
|
{ text: "Introduction", link: "/other-usage-of-flakes/intro.md" },
|
|
|
|
{
|
|
|
|
text: "Flake Inputs",
|
|
|
|
link: "/other-usage-of-flakes/inputs.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Flake Outputs",
|
|
|
|
link: "/other-usage-of-flakes/outputs.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "The New CLI",
|
|
|
|
link: "/other-usage-of-flakes/the-new-cli.md",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-06-27 10:12:22 +00:00
|
|
|
{
|
|
|
|
text: "Dev Environemnts on NixOS",
|
|
|
|
items: [
|
2023-06-28 10:12:58 +00:00
|
|
|
{ text: "Introduction", link: "/development/intro.md" },
|
2023-06-27 10:12:22 +00:00
|
|
|
{
|
|
|
|
text: "Dev Environments",
|
|
|
|
link: "/development/dev-environments.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Packaging 101",
|
|
|
|
link: "/development/packaging-101.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Cross-platform Compilation",
|
|
|
|
link: "/development/cross-platform-compilation.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Distribution Building",
|
|
|
|
link: "/development/distributed-building.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Kernel Development",
|
|
|
|
link: "/development/kernel-development.md",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-06-23 14:41:34 +00:00
|
|
|
{
|
|
|
|
text: "Advanced Topics",
|
2023-06-28 10:12:58 +00:00
|
|
|
items: [{ text: "Links", link: "/advanced-topics/index.md" }],
|
2023-06-23 14:41:34 +00:00
|
|
|
},
|
2023-06-23 10:05:06 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
socialLinks: [
|
|
|
|
{
|
|
|
|
icon: "github",
|
|
|
|
link: "https://github.com/ryan4yin/nixos-and-flakes-book",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-06-23 06:33:04 +00:00
|
|
|
},
|
|
|
|
zh: {
|
|
|
|
label: "简体中文",
|
|
|
|
lang: "zh-CN",
|
|
|
|
link: "/zh/",
|
|
|
|
title: "NixOS 与 Flakes",
|
|
|
|
description: "一份非官方的新手指南",
|
|
|
|
|
2023-06-23 10:05:06 +00:00
|
|
|
themeConfig: {
|
|
|
|
// https://vitepress.dev/reference/default-theme-config
|
|
|
|
nav: [
|
2023-06-24 04:57:45 +00:00
|
|
|
{ text: "首页", link: "/zh/" },
|
|
|
|
{ text: "开始使用", link: "/zh/introduction/index.md" },
|
|
|
|
{ text: "最佳实践", link: "/zh/best-practices/intro.md" },
|
2023-06-23 10:05:06 +00:00
|
|
|
],
|
2023-06-23 06:33:04 +00:00
|
|
|
|
2023-06-23 10:05:06 +00:00
|
|
|
sidebar: [
|
|
|
|
{
|
|
|
|
text: "开始使用",
|
|
|
|
items: [
|
|
|
|
{ text: "简介", link: "/zh/introduction/index.md" },
|
|
|
|
{
|
|
|
|
text: "优缺点",
|
|
|
|
link: "/zh/introduction/advantages-and-disadvantages.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "安装",
|
|
|
|
link: "/zh/introduction/installation.md",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Nix 语言",
|
2023-06-23 12:29:12 +00:00
|
|
|
items: [
|
|
|
|
{ text: "快速入门", link: "/zh/the-nix-language/index.md" },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
text: "NixOS 与 Flakes",
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
text: "开始使用 NixOS",
|
2023-06-23 13:26:48 +00:00
|
|
|
link: "/zh/nixos-with-flakes/get-started-with-nixos.md",
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Flakes 简介",
|
2023-06-23 13:26:48 +00:00
|
|
|
link: "/zh/nixos-with-flakes/introduction-to-flakes.md",
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "使用 Flakes 管理 NixOS",
|
2023-06-23 15:18:01 +00:00
|
|
|
link: "/zh/nixos-with-flakes/nixos-with-flakes-enabled.md",
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
2023-06-23 15:45:36 +00:00
|
|
|
text: "安装使用 Home Manager",
|
2023-06-23 13:26:48 +00:00
|
|
|
link: "/zh/nixos-with-flakes/start-using-home-manager.md",
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "模块化系统配置",
|
2023-06-23 13:26:48 +00:00
|
|
|
link: "/zh/nixos-with-flakes/modularize-the-configuration.md",
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "更新系统",
|
2023-06-23 13:26:48 +00:00
|
|
|
link: "/zh/nixos-with-flakes/update-the-system.md",
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
2023-06-24 04:13:49 +00:00
|
|
|
text: "降级或升级软件包",
|
2023-06-23 15:18:01 +00:00
|
|
|
link: "/zh/nixos-with-flakes/downgrade-or-upgrade-packages.md",
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "其他杂七杂八的内容",
|
2023-06-23 13:26:48 +00:00
|
|
|
link: "/zh/nixos-with-flakes/other-useful-tips.md",
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Nixpkgs 高级用法",
|
2023-06-23 14:19:10 +00:00
|
|
|
items: [
|
2023-06-28 10:12:58 +00:00
|
|
|
{ text: "简介", link: "/zh/nixpkgs/intro.md" },
|
2023-06-23 14:19:10 +00:00
|
|
|
{ text: "callPackage", link: "/zh/nixpkgs/callpackage.md" },
|
2023-06-23 15:18:01 +00:00
|
|
|
{ text: "Overridding", link: "/zh/nixpkgs/overriding.md" },
|
2023-06-23 14:19:10 +00:00
|
|
|
{ text: "Overlays", link: "/zh/nixpkgs/overlays.md" },
|
|
|
|
],
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "NixOS 最佳实践",
|
2023-06-23 14:22:13 +00:00
|
|
|
items: [
|
|
|
|
{ text: "简介", link: "/zh/best-practices/intro.md" },
|
|
|
|
{
|
|
|
|
text: "运行非 NixOS 的二进制文件",
|
|
|
|
link: "/zh/best-practices/run-downloaded-binaries-on-nixos.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "使用 Makefile 简化常用命令",
|
|
|
|
link: "/zh/best-practices/simplify-nixos-related-commands.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "使用 nix repl 查看源码、调试配置",
|
|
|
|
link: "/zh/best-practices/debug-with-nix-repl.md",
|
|
|
|
},
|
|
|
|
],
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Flakes 的其他玩法",
|
2023-06-23 14:41:34 +00:00
|
|
|
items: [
|
2023-06-28 10:12:58 +00:00
|
|
|
{ text: "简介", link: "/zh/other-usage-of-flakes/intro.md" },
|
2023-06-23 14:41:34 +00:00
|
|
|
{
|
|
|
|
text: "Flake Inputs",
|
|
|
|
link: "/zh/other-usage-of-flakes/inputs.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Flake Outputs",
|
|
|
|
link: "/zh/other-usage-of-flakes/outputs.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "The New CLI",
|
|
|
|
link: "/zh/other-usage-of-flakes/the-new-cli.md",
|
|
|
|
},
|
|
|
|
],
|
2023-06-23 12:29:12 +00:00
|
|
|
},
|
2023-06-27 02:53:11 +00:00
|
|
|
{
|
|
|
|
text: "在 NixOS 上进行开发工作",
|
|
|
|
items: [
|
2023-06-28 10:12:58 +00:00
|
|
|
{ text: "简介", link: "/zh/development/intro.md" },
|
2023-06-27 02:53:11 +00:00
|
|
|
{
|
|
|
|
text: "各语言的开发环境",
|
|
|
|
link: "/zh/development/dev-environments.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "软件打包",
|
|
|
|
link: "/zh/development/packaging-101.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "跨平台编译",
|
|
|
|
link: "/zh/development/cross-platform-compilation.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "分布式构建",
|
|
|
|
link: "/zh/development/distributed-building.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "内核开发",
|
|
|
|
link: "/zh/development/kernel-development.md",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-06-23 12:29:12 +00:00
|
|
|
{
|
|
|
|
text: "其他进阶话题",
|
2023-06-28 10:12:58 +00:00
|
|
|
items: [{ text: "简介", link: "/zh/advanced-topics/index.md" }],
|
2023-06-23 10:05:06 +00:00
|
|
|
},
|
|
|
|
],
|
2023-06-23 06:33:04 +00:00
|
|
|
|
2023-06-23 10:05:06 +00:00
|
|
|
socialLinks: [
|
|
|
|
{
|
|
|
|
icon: "github",
|
|
|
|
link: "https://github.com/ryan4yin/nixos-and-flakes-book",
|
|
|
|
},
|
|
|
|
],
|
2023-06-23 06:33:04 +00:00
|
|
|
},
|
2023-06-23 10:05:06 +00:00
|
|
|
},
|
2023-06-23 06:33:04 +00:00
|
|
|
},
|
2023-06-23 14:41:34 +00:00
|
|
|
});
|