mirror of
https://github.com/ryan4yin/nixos-and-flakes-book.git
synced 2024-11-24 17:13:12 +01:00
fix: SEO Improvement - add JSON-LD Scheme
This commit is contained in:
parent
a497f8010d
commit
42e7e7f53a
@ -6,15 +6,14 @@ import { PageData, defineConfig } from "vitepress";
|
|||||||
const links = [];
|
const links = [];
|
||||||
|
|
||||||
function getJSONLD(pageData: PageData) {
|
function getJSONLD(pageData: PageData) {
|
||||||
console.log(pageData.relativePath);
|
|
||||||
if (pageData.relativePath === "index.md") {
|
if (pageData.relativePath === "index.md") {
|
||||||
return `{
|
return `{
|
||||||
"@context":"http://schema.org",
|
"@context":"http://schema.org",
|
||||||
"@type":"WebSite",
|
"@type":"WebSite",
|
||||||
"url":"https:\/\/nixos-and-flakes.thiscute.world\/",
|
"url":"https:\/\/nixos-and-flakes.thiscute.world\/",
|
||||||
"inLanguage":"en",
|
"inLanguage":"en",
|
||||||
"description":"An unofficial book for beginners",
|
"description":"An unofficial and opinionated book for beginners",
|
||||||
"name":"NixOS & Flakes Book"
|
"name":"${pageData.title}"
|
||||||
}`;
|
}`;
|
||||||
} else if (pageData.relativePath === "zh/index.md") {
|
} else if (pageData.relativePath === "zh/index.md") {
|
||||||
return `{
|
return `{
|
||||||
@ -23,17 +22,18 @@ function getJSONLD(pageData: PageData) {
|
|||||||
"url":"https:\/\/nixos-and-flakes.thiscute.world\/zh\/",
|
"url":"https:\/\/nixos-and-flakes.thiscute.world\/zh\/",
|
||||||
"inLanguage":"zh-CN",
|
"inLanguage":"zh-CN",
|
||||||
"description":"一份非官方的新手指南",
|
"description":"一份非官方的新手指南",
|
||||||
"name":"NixOS 与 Flakes"
|
"name":"${pageData.title}"
|
||||||
}`;
|
}`;
|
||||||
} else {
|
} else {
|
||||||
|
let lang = pageData.relativePath.startsWith("zh/") ? "zh-CN" : "en";
|
||||||
let url = `https:\/\/nixos-and-flakes.thiscute.world\/${pageData.relativePath
|
let url = `https:\/\/nixos-and-flakes.thiscute.world\/${pageData.relativePath
|
||||||
.replace(/\.md$/, ".html")
|
.replace(/\.md$/, ".html")
|
||||||
.replace(/\/index\.html$/, "/")}`;
|
.replace(/\/index\.html$/, "/")}`;
|
||||||
return `{
|
return `{
|
||||||
"@context":"http://schema.org",
|
"@context":"http://schema.org",
|
||||||
"@type":"BlogPosting",
|
"@type":"TechArticle",
|
||||||
"headline":"NixOS \u0026 Nix Flakes - A Guide for Beginners",
|
"headline":"NixOS & Flakes Book",
|
||||||
"inLanguage":"en",
|
"inLanguage":"${lang}",
|
||||||
"mainEntityOfPage":{
|
"mainEntityOfPage":{
|
||||||
"@type":"WebPage",
|
"@type":"WebPage",
|
||||||
"@id":"${url}"
|
"@id":"${url}"
|
||||||
|
Loading…
Reference in New Issue
Block a user