@docsector/docsector-reader 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/docsector.js +1 -1
- package/package.json +1 -1
- package/src/components/DPageBar.vue +18 -5
- package/src/quasar.factory.js +15 -2
package/bin/docsector.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docsector/docsector-reader",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "A documentation rendering engine built with Vue 3, Quasar v2 and Vite. Transform Markdown into beautiful, navigable documentation sites.",
|
|
5
5
|
"productName": "Docsector Reader",
|
|
6
6
|
"author": "Rodrigo de Araujo Vieira",
|
|
@@ -3,18 +3,29 @@ import { ref, computed } from 'vue'
|
|
|
3
3
|
import { useRoute } from 'vue-router'
|
|
4
4
|
import { useStore } from 'vuex'
|
|
5
5
|
import { useI18n } from 'vue-i18n'
|
|
6
|
-
import { copyToClipboard } from 'quasar'
|
|
6
|
+
import { copyToClipboard, useQuasar } from 'quasar'
|
|
7
7
|
|
|
8
8
|
import gitDates from 'virtual:docsector-git-dates'
|
|
9
9
|
|
|
10
|
+
const $q = useQuasar()
|
|
10
11
|
const store = useStore()
|
|
11
12
|
const route = useRoute()
|
|
12
13
|
const { t, locale } = useI18n()
|
|
13
14
|
|
|
14
15
|
const copied = ref(false)
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
-
const
|
|
17
|
+
const OPENAI_PATH = 'M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365l2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5z'
|
|
18
|
+
const CLAUDE_PATH = 'M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z'
|
|
19
|
+
|
|
20
|
+
function buildIconURI (path, fillRule) {
|
|
21
|
+
const fill = $q.dark.isActive ? '#ccc' : '#555'
|
|
22
|
+
const fr = fillRule ? ` fill-rule="${fillRule}"` : ''
|
|
23
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" fill="${fill}"${fr} viewBox="0 0 24 24"><path d="${path}"/></svg>`
|
|
24
|
+
return `img:data:image/svg+xml,${encodeURIComponent(svg)}`
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const openaiIcon = computed(() => buildIconURI(OPENAI_PATH))
|
|
28
|
+
const claudeIcon = computed(() => buildIconURI(CLAUDE_PATH, 'evenodd'))
|
|
18
29
|
|
|
19
30
|
const subpage = computed(() => {
|
|
20
31
|
const rel = store.state.page.relative
|
|
@@ -56,11 +67,13 @@ const rawMarkdown = computed(() => {
|
|
|
56
67
|
})
|
|
57
68
|
|
|
58
69
|
const markdownURL = computed(() => {
|
|
59
|
-
|
|
70
|
+
const path = route.path.replace(/\/+$/, '')
|
|
71
|
+
return `${path}.md`
|
|
60
72
|
})
|
|
61
73
|
|
|
62
74
|
const fullMarkdownURL = computed(() => {
|
|
63
|
-
|
|
75
|
+
const path = route.path.replace(/\/+$/, '')
|
|
76
|
+
return `${window.location.origin}${path}.md`
|
|
64
77
|
})
|
|
65
78
|
|
|
66
79
|
const chatgptURL = computed(() => {
|
package/src/quasar.factory.js
CHANGED
|
@@ -360,7 +360,7 @@ function createMarkdownEndpointPlugin (projectRoot) {
|
|
|
360
360
|
if (!file) return next()
|
|
361
361
|
|
|
362
362
|
const content = readFileSync(file, 'utf-8')
|
|
363
|
-
res.setHeader('Content-Type', 'text/
|
|
363
|
+
res.setHeader('Content-Type', 'text/markdown; charset=utf-8')
|
|
364
364
|
res.end(content)
|
|
365
365
|
return
|
|
366
366
|
}
|
|
@@ -374,7 +374,7 @@ function createMarkdownEndpointPlugin (projectRoot) {
|
|
|
374
374
|
const file = resolveMarkdownFile(mdPath, lang)
|
|
375
375
|
if (file) {
|
|
376
376
|
const content = readFileSync(file, 'utf-8')
|
|
377
|
-
res.setHeader('Content-Type', 'text/
|
|
377
|
+
res.setHeader('Content-Type', 'text/markdown; charset=utf-8')
|
|
378
378
|
res.end(content)
|
|
379
379
|
return
|
|
380
380
|
}
|
|
@@ -438,6 +438,19 @@ function createMarkdownBuildPlugin (projectRoot) {
|
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
console.log(`\x1b[36m[docsector]\x1b[0m Generated ${count} static .md files`)
|
|
441
|
+
|
|
442
|
+
// Generate _headers file for Cloudflare Pages (append if exists)
|
|
443
|
+
const headersPath = resolve(distDir, '_headers')
|
|
444
|
+
const headersRule = '/*.md\n Content-Type: text/markdown; charset=utf-8\n'
|
|
445
|
+
if (existsSync(headersPath)) {
|
|
446
|
+
const existing = readFileSync(headersPath, 'utf-8')
|
|
447
|
+
if (!existing.includes('*.md')) {
|
|
448
|
+
writeFileSync(headersPath, existing.trimEnd() + '\n\n' + headersRule)
|
|
449
|
+
}
|
|
450
|
+
} else {
|
|
451
|
+
writeFileSync(headersPath, headersRule)
|
|
452
|
+
}
|
|
453
|
+
console.log(`\x1b[36m[docsector]\x1b[0m Added _headers rule for .md files`)
|
|
441
454
|
}
|
|
442
455
|
}
|
|
443
456
|
}
|