framework icon indicating copy to clipboard operation
framework copied to clipboard

Footer “edit me” link

Open mbostock opened this issue 1 year ago • 5 comments

If a project is hosted on GitHub (or other hosting service), it’d be nice if we could automatically generate an “edit me” link in the footer.

mbostock avatar Oct 23 '23 21:10 mbostock

I was imagining the page generator (parseMarkdown?) would have access to the path (and pass it probably in the context), so we could (or a theme could) add a “view source” component — which might point to a github repo or something else. Maybe in the page footer (#55).

Fil avatar Oct 26 '23 17:10 Fil

related #739

Fil avatar Feb 13 '24 14:02 Fil

Here's my take on this, in observablehq.config.js:

const SOURCE_REPO = "https://github.com/USER/PROJECT/blob/main/docs";

const VIEW_SOURCE = `
<style>
a.view-source {
  position: absolute;
  top: 0;
  right: 0;
  font: 700 18px var(--sans-serif);
  text-decoration: none !important;
  padding: 0 4px;
}
a.view-source:not(:hover,:focus) {
  color: inherit;
}
</style>
<a class="view-source" target="_blank" aria-label="view source" title="view source" href="${SOURCE_REPO}">⚉</a>
<script type="module">
const a = document.querySelector(".view-source");
a.setAttribute("href", a.getAttribute("href") + (document.location.pathname.replace(/[/]$/, "/index")) + ".md?plain=1"
);
</script>
`;


export default {
  header: ${VIEW_SOURCE}
};

Fil avatar Mar 12 '24 21:03 Fil

Would be nice to support non-GitHub hosted (but still open source) websites!

jaanli avatar Mar 13 '24 15:03 jaanli

I think we have enough possibilities now for a user to add their own links in header or footer. It could be nice to support passing these options as functions that would receive a bit of context (page name, page url)?

Fil avatar Mar 23 '24 17:03 Fil