Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: setup with vitepress #882

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
# config files
.eslintrc.js
karma*.conf.js

docs/**
57 changes: 57 additions & 0 deletions .github/workflows/build_deploy_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v3
- name: use pnpm
uses: pnpm/action-setup@v2
with:
version: 8.9.0
- name: use node 18
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- name: Install and Build Docs
run: |
pnpm i --filter docs
pnpm docs:build
touch docs/site/.nojekyll
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: "docs/site"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ dist

# vscode settings - to each her/his own
.vscode/settings.json

# docs
docs/site
docs/.vitepress/cache
191 changes: 191 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
// using the defineConfig helper will provide TypeScript-powered
// intellisense for config options
import { defineConfig } from "vitepress";
import { join } from "node:path";
import fs from "fs";
import path from "path";

import externalMarkdown, { ExternalMarkdownData } from "./theme/loaders/externalMarkdown";

// markdown
import MarkdownItImplicitFigures from "markdown-it-implicit-figures";
import MarkdownItPlantuml from "markdown-it-plantuml";

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "UI5 Ecosystem Showcase",
description: "Documentation",
lastUpdated: false, // disable git author info
cleanUrls: false,
srcDir: "src",
outDir: "site",
base: "/ui5-ecosystem-showcase/",
// ignoreDeadLinks: [
// // ignore all localhost links
// /^https?:\/\/localhost/,
// // ignore all links include "/ui5.sap.com/""
// /\/ui5.sap.com\//,
// ],
ignoreDeadLinks: true,

vue: {
template: {
compilerOptions: {
// treat all tags with a "ui5-" prefix as custom elements
isCustomElement: (tag: string) => tag.includes("ui5-"),
},
},
},

head: [["link", { rel: "icon", type: "image/svg+xml", href: "/icons/ui5/O.svg" }]],

themeConfig: {
logo: {
light: "/icons/ui5/B.svg",
dark: "/icons/ui5/O.svg",
},
externalLinkIcon: false,
outline: [1, 3],

nav: [
{ text: "Home", link: "/" },
{ text: "Overview", link: "/overview/" },
],

sidebar: [
{
text: "Packages",
items: generateSidebar(),
},
],

socialLinks: [
{
icon: {
svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Twitter</title><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path></svg>',
},
link: "https://twitter.com/hschaefer123",
},
{ icon: "github", link: "https://github.com/hschaefer123/ui5-vitepress" },
],

footer: {
message: `<a class="u-pi" href="/guide/trip-pin.html">π</a>`,
copyright: `Copyright © 2020-${new Date().getFullYear()} by YOU`,
},

search: {
provider: "local",
//hotKeys: [], // disable hotkeys to avoid search while using UI5 web components input
},
},

markdown: {
//theme: "material-theme-palenight", // pre rc5 default
// Add support for your own languages.
// https://github.com/shikijs/shiki/blob/main/docs/languages.md#supporting-your-own-languages-with-shiki
languages: [
{
// https://github.com/SAP-samples/vscode-abap-cds/blob/main/syntaxes/cds.tmLanguage.json
id: "abapcds",
scopeName: "source.abapcds",
path: join(__dirname, "syntaxes/abapcds.tmLanguage.json"),
aliases: ["abapcds"],
},
{
// https://github.com/SAP/cds-textmate-grammar/blob/main/syntaxes/cds.tmLanguage.json
id: "cds",
scopeName: "source.cds",
path: join(__dirname, "syntaxes/cds.tmLanguage.json"),
aliases: ["cds"],
},
{
// https://github.com/mechatroner/vscode_rainbow_csv/blob/master/syntaxes/csv.tmLanguage.json
id: "csvc",
scopeName: "text.csv",
path: join(__dirname, "syntaxes/csv.tmLanguage.json"),
aliases: ["csv", "csvc"],
},
{
// https://github.com/mechatroner/vscode_rainbow_csv/blob/master/syntaxes/csv.tmLanguage.json
id: "csvs",
scopeName: "text.scsv",
path: join(__dirname, "syntaxes/scsv.tmLanguage.json"),
aliases: ["csvs"],
},
{
// https://github.com/Huachao/vscode-restclient/blob/master/syntaxes/http.tmLanguage.json
id: "http",
scopeName: "source.http",
path: join(__dirname, "syntaxes/http.tmLanguage.json"),
aliases: ["http", "rest"],
},
],

// Configure the Markdown-it instance
config: (md) => {
// https://www.npmjs.com/package/markdown-it-implicit-figures
md.use(MarkdownItImplicitFigures, {
figcaption: true,
});
md.use(MarkdownItPlantuml, {
//imageFormat: 'png'
});
// https://github.com/gmunguia/markdown-it-plantuml/issues/35
md.use(MarkdownItPlantuml, {
openMarker: "```plantuml",
closeMarker: "```",
diagramName: "uml",
imageFormat: "svg",
});
// Textik https://textik.com/
md.use(MarkdownItPlantuml, {
openMarker: "```ditaa",
closeMarker: "```",
diagramName: "ditaa",
imageFormat: "png",
});
},
},

vite: {
build: {
chunkSizeWarningLimit: 4000, // chunk for local search index dominates
},
},

// themeConfig: {
// // https://vitepress.dev/reference/default-theme-config
// nav: [
// { text: 'Home', link: '/' },
// { text: 'Examples', link: '/markdown-examples' }
// ],

// sidebar: [
// {
// text: 'Packages',
// items: [
// { text: 'ui5-middleware-ui5', link: '/ui5-middleware-ui5' }
// ]
// }
// ],

// socialLinks: [
// { icon: 'github', link: 'https://github.com/vuejs/vitepress' }
// ]
// }
});

function generateSidebar(filepath?: string) {
const directoryPath = path.join(__dirname, "../src/packages");
const files = fs.readdirSync(directoryPath);
return files.map((file) => {
const filePath = path.join(directoryPath, file);
const isDirectory = fs.statSync(filePath).isDirectory();
// if it's a file, just return a link to the file
return {
text: file.replace(/\.md$/, ""),
link: `/packages/${file}`,
};
});
}
Loading