Skip to content

Commit fa21fcf

Browse files
committed
refactor: Updated the docs to use VitePress ^1.0.0-alpha.29
1 parent 376477f commit fa21fcf

File tree

19 files changed

+1564
-1204
lines changed

19 files changed

+1564
-1204
lines changed

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/vendor
22
/node_modules
3+
/docs/.vitepress/dist
4+
/docs/.vitepress/cache

docs/Makefile

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,47 @@
1+
MAJOR_VERSION?=4
12
TAG?=14-alpine
2-
CONTAINER?=$(shell basename $(dir $(CURDIR)))-docs
3-
DOCKERRUN=docker container run \
4-
--name ${CONTAINER} \
5-
--rm \
6-
-p 3002:3002 \
7-
-t \
8-
-v "${CURDIR}":/app \
9-
${CONTAINER}:${TAG}
10-
DOCSDEST?=../../../sites/nystudio107/web/docs/transcoder
3+
CONTAINER?=$(shell basename $(dir $(CURDIR)))-v${MAJOR_VERSION}-docs
4+
DOCS_DEV_PORT?=400${MAJOR_VERSION}
5+
DOCS_DEST?=../../../sites/nystudio107/web/docs/retour
6+
IMAGE_INFO=$(shell docker image inspect $(CONTAINER):$(TAG))
7+
IMAGE_NAME=${CONTAINER}:${TAG}
8+
DOCKER_RUN=docker container run --rm -it -v "${CURDIR}":/app
119

12-
.PHONY: docker build dev fix install lint clean npm
10+
.PHONY: build clean dev fix image-build image-check lint npm ssh
1311

14-
# Start the Docker container
15-
docker:
16-
docker build \
17-
. \
18-
-t ${CONTAINER}:${TAG} \
19-
--build-arg TAG=${TAG} \
20-
--no-cache
21-
# Build the production docs
22-
build: docker install
23-
${DOCKERRUN} \
24-
run docs:build
25-
rm -rf ${DOCSDEST}
26-
mv ./docs/.vitepress/dist ${DOCSDEST}
27-
# Start up the dev server
28-
dev: docker install
29-
${DOCKERRUN} \
30-
run docs:dev
31-
# Fix the docs via textlint
32-
fix: docker install
33-
${DOCKERRUN} \
34-
run docs:fix
35-
# Run an npm install
36-
install: docker
37-
${DOCKERRUN} \
38-
install
39-
# Lint the docs via textlint
40-
lint: docker install
41-
${DOCKERRUN} \
42-
run docs:lint
43-
# Remove node_modules/* & package-lock.json
12+
# Perform a dist build via npm run docs:build
13+
build: image-check
14+
${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} run docs:build
15+
rm -rf ${DOCS_DEST}
16+
mv ./docs/.vitepress/dist ${DOCS_DEST}
17+
# Remove node_modules/ & package-lock.json
4418
clean:
4519
rm -rf node_modules/
4620
rm -f package-lock.json
21+
# Run the development server via npm run docs:dev
22+
dev: image-check
23+
${DOCKER_RUN} --name ${CONTAINER}-$@ -e DOCS_DEV_PORT="${DOCS_DEV_PORT}" -p ${DOCS_DEV_PORT}:${DOCS_DEV_PORT} ${IMAGE_NAME} run docs:dev
24+
# Fix the docs with textlint via npm run docs:fix
25+
fix: image-check
26+
${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} run docs:fix
27+
# Build the Docker image & run npm install
28+
image-build:
29+
docker build . -t ${IMAGE_NAME} --build-arg TAG=${TAG} --no-cache
30+
${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} install
31+
# Ensure the image has been created
32+
image-check:
33+
ifeq ($(IMAGE_INFO), [])
34+
image-check: image-build
35+
endif
36+
# Lint the docs with textlint via npm run docs:lint
37+
lint: image-check
38+
${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} run docs:lint
4739
# Run the passed in npm command
48-
npm: docker
49-
${DOCKERRUN} \
50-
$(filter-out $@,$(MAKECMDGOALS))
40+
npm: image-check
41+
${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} $(filter-out $@,$(MAKECMDGOALS)) $(MAKEFLAGS)
42+
# Open a shell inside of the container
43+
ssh: image-check
44+
${DOCKER_RUN} --name ${CONTAINER}-$@ --entrypoint=/bin/sh ${IMAGE_NAME}
5145
%:
5246
@:
5347
# ref: https://stackoverflow.com/questions/6273608/how-to-pass-argument-to-makefile-from-command-line

docs/docs/.vitepress/config.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/docs/.vitepress/config.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import {defineConfig} from 'vitepress'
2+
3+
export default defineConfig({
4+
title: 'Transcoder Plugin',
5+
description: 'Documentation for the Transcoder plugin',
6+
base: '/docs/transcoder/',
7+
lang: 'en-US',
8+
head: [
9+
['meta', {content: 'https://github.com/nystudio107', property: 'og:see_also',}],
10+
['meta', {content: 'https://twitter.com/nystudio107', property: 'og:see_also',}],
11+
['meta', {content: 'https://youtube.com/nystudio107', property: 'og:see_also',}],
12+
['meta', {content: 'https://www.facebook.com/newyorkstudio107', property: 'og:see_also',}],
13+
],
14+
themeConfig: {
15+
socialLinks: [
16+
{icon: 'github', link: 'https://github.com/nystudio107'},
17+
{icon: 'twitter', link: 'https://twitter.com/nystudio107'},
18+
],
19+
logo: '/img/plugin-logo.svg',
20+
editLink: {
21+
pattern: 'https://github.com/nystudio107/craft-transcoder/edit/develop/docs/docs/:path',
22+
text: 'Edit this page on GitHub'
23+
},
24+
algolia: {
25+
appId: 'VWUWF9S521',
26+
apiKey: 'db5c03f88e474cbf0356841089be7ffa',
27+
indexName: 'transcoder'
28+
},
29+
lastUpdatedText: 'Last Updated',
30+
sidebar: [
31+
{
32+
text: 'Topics',
33+
items: [
34+
{text: 'Transcoder Plugin', link: '/'},
35+
{text: 'Transcoder Overview', link: '/overview.html'},
36+
{text: 'Configuring Transcoder', link: '/configuring.html'},
37+
{text: 'Using Transcoder', link: '/using.html'},
38+
],
39+
}
40+
],
41+
nav: [
42+
{text: 'Home', link: 'https://nystudio107.com/plugins/transcoder'},
43+
{text: 'Store', link: 'https://plugins.craftcms.com/transcoder'},
44+
{text: 'Changelog', link: 'https://nystudio107.com/plugins/transcoder/changelog'},
45+
{text: 'Issues', link: 'https://github.com/nystudio107/craft-transcoder/issues'},
46+
{
47+
text: 'v4', items: [
48+
{text: 'v4', link: '/'},
49+
{text: 'v3', link: 'https://nystudio107.com/docs/transcoder/v3/'},
50+
],
51+
},
52+
],
53+
},
54+
});

docs/docs/.vitepress/theme/SidebarBottom.vue renamed to docs/docs/.vitepress/theme/NYSLogo.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
target="_blank"
77
rel="noopener"
88
>
9-
<img
10-
src="/resources/img/nys-logo.svg"
9+
<img
10+
src="/img/nys-logo.svg"
1111
aria-label="nystudio107 logo"
12-
/>
12+
/>
1313
</a>
1414
</div>
1515
</template>
1616

17-
<script>
18-
export default {
19-
name: "SidebarBottom"
20-
}
17+
<script setup>
2118
</script>
2219

2320
<style scoped>

docs/docs/.vitepress/theme/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010
.DocSearch {
1111
--docsearch-primary-color: var(--c-brand) !important;
1212
}
13+
14+
a > img {
15+
display: inline-block;
16+
}

docs/docs/.vitepress/theme/index.js

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import Theme from 'vitepress/theme'
2+
import {h, watch} from 'vue'
3+
import './custom.css'
4+
5+
import NYSLogo from './NYSLogo.vue';
6+
7+
// Could also come from .env
8+
const GA_ID = 'UA-69117511-1';
9+
10+
export default {
11+
...Theme,
12+
Layout() {
13+
return h(Theme.Layout, null, {
14+
'aside-bottom': () => h(NYSLogo)
15+
}
16+
)
17+
},
18+
enhanceApp: (ctx) => {
19+
// Google analytics integration
20+
if (import.meta.env.PROD && GA_ID && typeof window !== 'undefined') {
21+
(function (i, s, o, g, r, a, m) {
22+
i['GoogleAnalyticsObject'] = r
23+
i[r] = i[r] || function () {
24+
(i[r].q = i[r].q || []).push(arguments)
25+
}
26+
i[r].l = 1 * new Date()
27+
a = s.createElement(o)
28+
m = s.getElementsByTagName(o)[0]
29+
a.async = 1
30+
a.src = g
31+
m.parentNode.insertBefore(a, m)
32+
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga')
33+
ga('create', GA_ID, 'auto')
34+
ga('set', 'anonymizeIp', true)
35+
// Send a page view any time the route changes
36+
watch(ctx.router.route, (newValue, oldValue) => {
37+
ga('set', 'page', newValue.path)
38+
ga('send', 'pageview')
39+
})
40+
}
41+
}
42+
}

docs/docs/@types/shims.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
declare module "*.vue" {
2+
import Vue from 'vue';
3+
export default Vue;
4+
}
5+
6+
declare module 'rollup-plugin-sitemap';
7+
declare module 'NYSLogo';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type SiteMapPluginUrls = { path: string; name: string; }[] | undefined;

0 commit comments

Comments
 (0)